From 105f7ca6ff97a3d83ab963e27a34e2c6a557fba4 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Fri, 3 Jan 2020 10:17:00 +0100 Subject: [PATCH] Add start --- maza | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/maza b/maza index 58d6eda..0ae1568 100755 --- a/maza +++ b/maza @@ -3,8 +3,13 @@ # START set -e +# VARIABLES PROGNAME=$(basename $0) CONFIG=($HOME/.maza/) +HOST_FILE=(/etc/hosts) +COLOR_RED=`tput setaf 1` +COLOR_GREEN=`tput setaf 2` +COLOR_RESET=`tput sgr0` LIST="list" START_TAG="## MAZA - List ad blocking" END_TAG="## END MAZA" @@ -22,6 +27,7 @@ Usage: $PROGNAME [OPTION] Simple and efficient local ad blocking throughout the network. Options: +status Check if it's active or not update Update the list of DNS to be blocked start Activate blocking DNS. stop Stop blocking DNS. @@ -31,8 +37,14 @@ EOF 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() { # Make conf folder rm -f $CONFIG/$LIST @@ -53,7 +65,17 @@ update() { ## Add end tag DNS list in first line echo $END_TAG >> "$CONFIG/$LIST" # 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 @@ -64,17 +86,21 @@ while [ $# -gt 0 ] ; do --help) usage ;; + status) + isArg="1" + status + ;; update) isArg="1" update ;; start) - echo "Start" isArg="1" + start ;; stop) - echo "Stop" isArg="1" + stop ;; *) esac