modifying wtmp function to allow only updating certain variables to avoid overlaps, especially with online/offline status during a longer runtime of status-misc.sh

This commit is contained in:
2016-12-26 12:57:20 +01:00
parent 3e0ec4d05a
commit 1984a70b99
3 changed files with 21 additions and 8 deletions

View File

@@ -12,10 +12,22 @@ source "$TMP"
# WRITE TMP
function wtmp {
> $TMP
echo "var_mailqueue_runs=$var_mailqueue_runs" >> $TMP
echo "var_conn=$var_conn" >> $TMP
echo "var_ip4=$var_ip4" >> $TMP
echo "var_ip6=$var_ip6" >> $TMP
echo "var_vpn=$var_vpn" >> $TMP
if [ "$1" = "" ]; then # no argument given
> $TMP
echo "var_mailqueue_runs=$var_mailqueue_runs" >> $TMP
echo "var_conn=$var_conn" >> $TMP
echo "var_ip4=$var_ip4" >> $TMP
echo "var_ip6=$var_ip6" >> $TMP
echo "var_vpn=$var_vpn" >> $TMP
echo "var_ns=$var_ns" >> $TMP
else # certain variables given, so only update these variables' values (avoids overlaps, esp. if status-misc.sh needs longer to be executed)
NO=$#
for ((i = 1; i <= $NO; i++)); do
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
done
fi
}