Browse Source

improve selective status update which makes most preset values unnecessary

master
mxmehl 5 years ago
parent
commit
0b871f8099
  1. 5
      config.cfg.sample
  2. 7
      shared-functions.so

5
config.cfg.sample

@ -3,10 +3,7 @@ TMP=/tmp/status
# Default values when first starting the tool
var_conn="on"
var_mailqueue_runs=9
var_ip4=127.0.0.1
var_ip6=::1
var_vpn="off"
var_mailqueue_runs=0
# status-ip.sh
IPSERV4="http://returns.plain-ipv4"

7
shared-functions.so

@ -26,7 +26,12 @@ function wtmp {
VAR_NAME=${!i} # variable name
VAR_VAL=${!VAR_NAME} # value of the variable's name
sed -Ei "s/^$VAR_NAME=.*/$VAR_NAME=$VAR_VAL/" $TMP
if [ $(grep -q "^$VAR_NAME=" $TMP; echo $?) == 0 ] ; then # variable already exists in status file
sed -Ei "s/^$VAR_NAME=.*/$VAR_NAME=$VAR_VAL/" $TMP
else
echo "$VAR_NAME=$VAR_VAL" >> $TMP
fi
done
fi

Loading…
Cancel
Save