82 lines
1.9 KiB
Bash
Executable File
82 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CURDIR=$(dirname "$(readlink -f "$0")")
|
|
source "$CURDIR"/shared-functions.so
|
|
|
|
OUT=
|
|
TOOL=
|
|
|
|
# ONLINE STATUS
|
|
function isonline {
|
|
if [ "$var_conn" = "off" ]; then
|
|
return 1
|
|
else
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
# connection status
|
|
TOOL="$TOOL;conn=$var_conn"
|
|
|
|
# NUMBER OF UNSENT EMAILS
|
|
function check_mailqueue {
|
|
QUEUE=$($MSMTP_LIST | grep -o "^From: " | wc -l)
|
|
OUT="$OUT;mq=$QUEUE"
|
|
|
|
# If $QUEUE > 0 and >10 runs, show notification
|
|
if [ "$QUEUE" -gt 0 ]; then
|
|
var_mailqueue_runs=$(($var_mailqueue_runs + 1))
|
|
else
|
|
var_mailqueue_runs=0 # reset counter if queue is empty again
|
|
fi
|
|
if [ "$QUEUE" -gt 0 ] && [ "$var_mailqueue_runs" -gt 9 ]; then
|
|
notify-send "There are mails in the mailqueue. Remember sending them manually or switch online status."
|
|
var_mailqueue_runs=0 # reset counter
|
|
fi
|
|
}
|
|
|
|
# SVN STATUS
|
|
function check_svn {
|
|
if isonline; then
|
|
STATUS=$(curl -m 5 -s -o - $SVNSTATUS)
|
|
EXIT="$?"
|
|
if ([ "$EXIT" == 4 ] || [ "$EXIT" == 6 ] || [ "$EXIT" == 28 ]); then
|
|
SVN="t/o"
|
|
else
|
|
SVN=$(echo $STATUS | cut -d";" -f1)
|
|
SVN_REV=$(echo $STATUS | cut -d";" -f2)
|
|
fi
|
|
else
|
|
SVN="off"
|
|
SVN_REV="off"
|
|
fi
|
|
OUT="$OUT;web=$SVN"
|
|
TOOL="$TOOL;web=$SVN_REV"
|
|
}
|
|
|
|
# NAMESERVER STATUS
|
|
function check_ns {
|
|
NS=$(grep -m3 "^nameserver" /etc/resolv.conf | cut -d" " -f2 | paste -sd',') # first nameserver in /etc/resolv.conf
|
|
if [ "$var_ns" == "" ]; then # var_ns is only set with status-interaction.sh, no default value in config.cfg
|
|
OUT="$OUT;ns=default"
|
|
else
|
|
OUT="$OUT;ns=$var_ns"
|
|
fi
|
|
TOOL="$TOOL;ns=$NS"
|
|
}
|
|
|
|
|
|
# OUTPUT INFO ON STATUSBAR
|
|
check_mailqueue
|
|
check_svn
|
|
check_ns
|
|
# Replace ; by | to make it look nicely
|
|
OUT=$(echo $OUT | sed -r 's/^;//')
|
|
OUT=$(echo $OUT | sed -r 's/;/ \| /g')
|
|
TOOL=$(echo $TOOL | sed -r 's/^;//')
|
|
TOOL=$(echo $TOOL | sed -r 's/;/ \| /g')
|
|
echo "$OUT"
|
|
echo "$TOOL"
|
|
|
|
wtmp var_mailqueue_runs # write updated values back to status file
|