X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=scripts.git;a=blobdiff_plain;f=dns323-op.sh;h=08e3922e65c68bf57769a680e99eaee62049d39d;hp=f8fac166e701e7c37a512d270b239a03b45ed4b7;hb=HEAD;hpb=844f03ff70febed3f8a500729f7a67c0bf995d35 diff --git a/dns323-op.sh b/dns323-op.sh index f8fac16..08e3922 100755 --- a/dns323-op.sh +++ b/dns323-op.sh @@ -22,6 +22,32 @@ set -e +export VT_RESET=$'\e[0m' +export VT_BOLD=$'\e[1m' +export VT_UNDERLINE=$'\e[4m' +export VT_BLINK=$'\e[5m' + +export VT_SET_TITLE=$'\e]0;' +export VT_END_TITLE=$'\007' + +export VT_BLACK_FG=$'\e[30m' +export VT_RED_FG=$'\e[31m' +export VT_GREEN_FG=$'\e[32m' +export VT_YELLOW_FG=$'\e[33m' +export VT_BLUE_FG=$'\e[34m' +export VT_MAGENTA_FG=$'\e[35m' +export VT_CYAN_FG=$'\e[36m' +export VT_WHITE_FG=$'\e[37m' + +export VT_BLACK_BG=$'\e[40m' +export VT_RED_BG=$'\e[41m' +export VT_GREEN_BG=$'\e[42m' +export VT_YELLOW_BG=$'\e[43m' +export VT_BLUE_BG=$'\e[44m' +export VT_MAGENTA_BG=$'\e[45m' +export VT_CYAN_BG=$'\e[46m' +export VT_WHITE_BG=$'\e[47m' + function rm_temp () { if [[ ${TMP} ]]; then rm ${TMP} @@ -32,7 +58,8 @@ function rm_temp () { function authentify_on_dns323 () { if [[ ! ${already_authentified} ]]; then echo "Authentifying on ${DNS323_HOSTNAME}." - curl -s > /dev/null \ + curl > /dev/null \ + -s \ -L http://${DNS323_HOSTNAME}/goform/formLogin \ -d "f_LOGIN_NAME=admin&f_LOGIN_PASSWD=${DNS323_ADMIN_PASSWORD}&f_login_type=0" \ || (echo "Failed." >&2 && exit 1) @@ -68,7 +95,7 @@ EOF trap rm_temp SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM ERR if [[ ${DNS323_HOSTNAME} ]] && \ - [[ ${DNS323_ADMIN_PASSWORD} ]]; then + [[ ${DNS323_ADMIN_PASSWORD} ]]; then while [[ $1 ]]; do @@ -107,21 +134,26 @@ if [[ ${DNS323_HOSTNAME} ]] && \ sed -e "s/^[ \t]*//" | while read line; do label=$(echo ${line} | sed -e "s/:.*$//") value=$(echo ${line} | sed -e "s/^[^0-9]*\([0-9]*\).*$/\1/") - comment="" case ${label} in "Total Hard Drive Capacity") total=${value} ;; "Used Space") - comment="($(((value*100)/total))%)" + line="${line} ($(((value*100)/total))%)" ;; "Unused Space") - comment="($(((value*100)/total))%)" + line="${line} ($(((value*100)/total))%)" + ;; + "Sync Time Remaining") + state=$(echo ${line} | sed -e "s/^[^:]*:[^A-Za-z]*//") + if [[ ! "${state}" == "Completed" ]]; then + line="${VT_RED_FG}${VT_BOLD}${line} !!! THIS IS NOT NORMAL !!!${VT_RESET}" + fi ;; *) ;; esac - echo "${line} ${comment}" + echo "${line}" done grep "var temper" ${TMP} | sed -e "s/^.*\"\([0-9]*\):\([0-9]*\)\".*$/Temperature: \1F \/ \2C/" @@ -155,7 +187,8 @@ if [[ ${DNS323_HOSTNAME} ]] && \ check_unmounted - curl -s > /dev/null \ + curl > /dev/null \ + -s \ -L http://${DNS323_HOSTNAME}/goform/System_restart \ -d ""