* usr/bin/byobu-statusd, usr/lib/byobu/.shutil:

- clean up a regression caused by Scott's last patch (for the once
    run 99999999 notifications)
This commit is contained in:
Dustin Kirkland 2011-07-24 14:20:24 -05:00
commit c96d8ad71d
3 changed files with 25 additions and 26 deletions

4
debian/changelog vendored
View file

@ -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 <kirkland@ubuntu.com> Fri, 22 Jul 2011 11:14:37 -0500

View file

@ -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

View file

@ -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