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
}

View File

@@ -41,4 +41,4 @@ else
echo "<tool>Offline status is set. Turn on to enable checks</tool>"
fi
wtmp # Write changes back
wtmp var_ip4 var_ip6 var_vpn # Write changes back

View File

@@ -52,6 +52,7 @@ function check_svn {
TOOL="$TOOL;svn=$SVN_REV"
}
# OUTPUT INFO ON STATUSBAR
check_mailqueue
check_svn
@@ -64,4 +65,4 @@ echo "<tool>$TOOL</tool>"
echo "<img>/usr/share/icons/gnome/16x16/actions/format-justify-fill.png</img>"
echo "<click>xfce4-terminal -x $CURDIR/status-interaction.sh &</click>"
wtmp
wtmp var_mailqueue_runs # write updated values back to status file