Add start

This commit is contained in:
Andros Fenollosa 2020-01-03 10:17:00 +01:00
parent c2dbfdb04e
commit 105f7ca6ff

34
maza
View File

@ -3,8 +3,13 @@
# START # START
set -e set -e
# VARIABLES
PROGNAME=$(basename $0) PROGNAME=$(basename $0)
CONFIG=($HOME/.maza/) CONFIG=($HOME/.maza/)
HOST_FILE=(/etc/hosts)
COLOR_RED=`tput setaf 1`
COLOR_GREEN=`tput setaf 2`
COLOR_RESET=`tput sgr0`
LIST="list" LIST="list"
START_TAG="## MAZA - List ad blocking" START_TAG="## MAZA - List ad blocking"
END_TAG="## END MAZA" END_TAG="## END MAZA"
@ -22,6 +27,7 @@ Usage: $PROGNAME [OPTION]
Simple and efficient local ad blocking throughout the network. Simple and efficient local ad blocking throughout the network.
Options: Options:
status Check if it's active or not
update Update the list of DNS to be blocked update Update the list of DNS to be blocked
start Activate blocking DNS. start Activate blocking DNS.
stop Stop blocking DNS. stop Stop blocking DNS.
@ -31,8 +37,14 @@ EOF
exit 1 exit 1
} }
status() {
if grep -qF "$START_TAG" "$HOST_FILE";then
echo "${COLOR_GREEN}ENABLED${COLOR_RESET}"
else
echo "${COLOR_RED}DISABLED${COLOR_RESET}"
fi
}
## UPDATE
update() { update() {
# Make conf folder # Make conf folder
rm -f $CONFIG/$LIST rm -f $CONFIG/$LIST
@ -53,7 +65,17 @@ update() {
## Add end tag DNS list in first line ## Add end tag DNS list in first line
echo $END_TAG >> "$CONFIG/$LIST" echo $END_TAG >> "$CONFIG/$LIST"
# Notify user # Notify user
echo "Done!" echo "${COLOR_GREEN}Done!${COLOR_RESET}"
}
start() {
cat "$CONFIG/$LIST" "$HOST_FILE" >> "$HOST_FILE"
# Notify user
echo "${COLOR_GREEN}ENABLED!${COLOR_RESET}"
}
stop() {
echo "stopdf"
} }
# CONTROLE ARGUMENTS # CONTROLE ARGUMENTS
@ -64,17 +86,21 @@ while [ $# -gt 0 ] ; do
--help) --help)
usage usage
;; ;;
status)
isArg="1"
status
;;
update) update)
isArg="1" isArg="1"
update update
;; ;;
start) start)
echo "Start"
isArg="1" isArg="1"
start
;; ;;
stop) stop)
echo "Stop"
isArg="1" isArg="1"
stop
;; ;;
*) *)
esac esac