From c96d8ad71d15da3ee547d1eab428a3f3f37f2e75 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 24 Jul 2011 14:20:24 -0500 Subject: [PATCH] * usr/bin/byobu-statusd, usr/lib/byobu/.shutil: - clean up a regression caused by Scott's last patch (for the once run 99999999 notifications) --- debian/changelog | 4 +++- usr/bin/byobu-statusd | 32 +++++++++++++++----------------- usr/lib/byobu/.shutil | 15 +++++++-------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/debian/changelog b/debian/changelog index cc570eb4..033adc28 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ byobu (4.22) unreleased; urgency=low - * UNRELEASED + * usr/bin/byobu-statusd, usr/lib/byobu/.shutil: + - clean up a regression caused by Scott's last patch (for the once + run 99999999 notifications) -- Dustin Kirkland Fri, 22 Jul 2011 11:14:37 -0500 diff --git a/usr/bin/byobu-statusd b/usr/bin/byobu-statusd index 2762c934..04aedc71 100755 --- a/usr/bin/byobu-statusd +++ b/usr/bin/byobu-statusd @@ -38,7 +38,7 @@ while true; do rm -f "$BYOBU_RUN_DIR/status"/* "$BYOBU_RUN_DIR/.last"/* exit 0 fi - getnow; now=${_RET} + get_now; now=${_RET} # Re-source configuration, if changed since last run for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc"; do [ -r "$i" ] && [ "$i" -nt "$BYOBU_RUN_DIR/status" ] && . "$i" @@ -48,30 +48,28 @@ while true; do */time_binary|*/Makefile.am) continue ;; esac i=${i##*/} - cache="$BYOBU_RUN_DIR/status/$i" - last="$BYOBU_RUN_DIR/.last/$i" + cachepath="$BYOBU_RUN_DIR/status/$i" + lastpath="$BYOBU_RUN_DIR/.last/$i" # Check if this status is enabled eval x="\$$i" if [ "$x" != "1" ]; then - rm -f "$cache" "$last" + # This item is disabled; clean up and continue + rm -f "$cachepath" "$lastpath" continue fi - [ -r "$last" ] && read lastrun < "$last" || lastrun=0 - - # if, for any reason the lastrun has a value greater that - # current time, we should run again - [ $lastrun -le $now ] || lastrun=0 - + [ -r "$lastpath" ] && read lastrun < "$lastpath" || lastrun=0 status_freq "$i" expiry=$(($lastrun+$_RET)) find_script "$i" && path="$_RET" || path=/dev/null - if [ $now -ge $expiry ] || [ "$path" -nt "$last" ]; then - # Re-source status function, if changed since last run - if [ "$path" -nt "$last" ] || [ ! -e "$last" ]; then - . "$path" - fi - "__$i" > "$cache" - echo "$now" > "$last" + # Re-source status function, if changed since last run + if [ "$path" -nt "$lastpath" ] || [ ! -e "$lastpath" ]; then + . "$path" + lastrun=0 + fi + # Update cache now, if necessary + if [ $now -ge $expiry ] || [ "$lastrun" = "0" ]; then + "__$i" > "$cachepath" + echo "$now" > "$lastpath" fi done sleep 2 diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index 5b47ef11..0626a20f 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -257,18 +257,17 @@ status_freq() { esac } -getnow() { _RET=$(date +%s); } -if [ -n "${BASH_VERSION}" -a -n "${SECONDS}" ]; then - getnow() { +get_now() { + if [ -n "${BASH_VERSION}" ] && [ -n "${SECONDS}" ]; then _RET=${SECONDS} - } -elif [ -r /proc/cpuinfo ]; then - getnow() { + elif [ -r /proc/cpuinfo ]; then # return the integer part of the first item in /proc/uptime local s c read s c < /proc/uptime _RET=${s%.*} - } -fi + else + _RET=$(date +%s); + fi +} # vi: syntax=sh ts=4 noexpandtab