make the status scripts compatible with busybox shells

tested on the palm pre
mostly, this consists of making sure that utilities called
are available and failing over properly
in some cases, it's a matter of particular options not
being available
or perhaps directories not being available

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-09-14 23:52:28 -05:00
commit 67e86457b0
10 changed files with 37 additions and 20 deletions

View file

@ -21,5 +21,5 @@ if [ "$1" = "--detail" ]; then
grep -i "^model name" /proc/cpuinfo grep -i "^model name" /proc/cpuinfo
exit 0 exit 0
fi fi
count=`getconf _NPROCESSORS_ONLN` count=`getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo`
[ "$count" = "1" ] || printf "%sx" "$count" [ "$count" = "1" ] || printf "%sx" "$count"

View file

@ -31,4 +31,5 @@ case $MP in
/dev/*) MP=`grep "$MP" /proc/mounts | awk '{print $2}'` ;; /dev/*) MP=`grep "$MP" /proc/mounts | awk '{print $2}'` ;;
esac esac
df -h -P "$MP" | tail -n 1 | awk '{print $2 " " $5}' | sed "s/\([^0-9\. ]\)/ \1/g" | awk '{printf "\005{=b MW}%d\005{-}\005{= MW}%sB,\005{-}\005{=b MW}%d\005{-}\005{= MW}%%\005{-} ", $1, $2, $3}' disk=`df -h -P "$MP" 2>/dev/null || df -h "$MP"`
echo "$disk" | tail -n 1 | awk '{print $2 " " $5}' | sed "s/\([^0-9\. ]\)/ \1/g" | awk '{printf "\005{=b MW}%d\005{-}\005{= MW}%sB,\005{-}\005{=b MW}%d\005{-}\005{= MW}%%\005{-} ", $1, $2, $3}'

View file

@ -27,7 +27,7 @@ else
fi fi
print_logo() { print_logo() {
distro=`echo "$1" | tr '[:upper:]' '[:lower:]'` distro=`echo "$1" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' `
case "$distro" in case "$distro" in
*ubuntu*) *ubuntu*)
$MARKUP && printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/" || printf "\\o/" $MARKUP && printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/" || printf "\\o/"
@ -68,6 +68,10 @@ print_logo() {
logo=" RH " logo=" RH "
$MARKUP && printf "\005{= Rk}$logo" || printf "$logo" $MARKUP && printf "\005{= Rk}$logo" || printf "$logo"
;; ;;
*rockhopper*)
logo="palm"
$MARKUP && printf "\005{=b YW}$logo" || printf "$logo"
;;
*slackware*) *slackware*)
logo=",S " logo=",S "
$MARKUP && printf "\005{=u Bk}$logo" || printf "$logo" $MARKUP && printf "\005{=u Bk}$logo" || printf "$logo"

View file

@ -31,9 +31,10 @@ if [ "$1" = "--detail" ]; then
exit 0 exit 0
fi fi
[ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu"
t2=`date +%s` t2=`date +%s`
for i in up down; do for i in up down; do
cache="/var/run/screen/S-$USER/$PKG.network_$i" cache="$DIR/$PKG.network_$i"
t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0 t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0
unit="kB/s" unit="kB/s"
if [ $t2 -le $t1 ]; then if [ $t2 -le $t1 ]; then

View file

@ -19,7 +19,8 @@
PKG="byobu" PKG="byobu"
reboot="/var/run/reboot-required" reboot="/var/run/reboot-required"
reload="/var/run/screen/S-$USER/$PKG.reload-required" [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu"
reload="$DIR/$PKG.reload-required"
case "$1" in case "$1" in
--detail) --detail)
ls -alF "$reboot" "$reload" 2>&1 ls -alF "$reboot" "$reload" 2>&1

View file

@ -19,8 +19,14 @@
PKG="byobu" PKG="byobu"
if [ "$1" = "--detail" ]; then
cat /etc/issue
exit 0
fi
if [ -n "$DISTRO" ]; then if [ -n "$DISTRO" ]; then
printf "\005{+b }%s\005{-} " "$DISTRO" # skip down to the bottom
true
elif which lsb_release >/dev/null 2>&1; then elif which lsb_release >/dev/null 2>&1; then
if [ "$1" = "--detail" ]; then if [ "$1" = "--detail" ]; then
lsb_release -a 2>/dev/null lsb_release -a 2>/dev/null
@ -30,21 +36,22 @@ elif which lsb_release >/dev/null 2>&1; then
r=$(lsb_release -s -d) r=$(lsb_release -s -d)
if echo "$r" | grep -qs "^Ubuntu .*\..*\..*$"; then if echo "$r" | grep -qs "^Ubuntu .*\..*\..*$"; then
# Use the -d if an Ubuntu LTS # Use the -d if an Ubuntu LTS
printf "\005{+b }%s\005{-} " "$r" DISTRO="$r"
else else
# But for other distros the description # But for other distros the description
# is too long, so build from -i and -r # is too long, so build from -i and -r
i=$(lsb_release -s -i) i=$(lsb_release -s -i)
r=$(lsb_release -s -r) r=$(lsb_release -s -r)
printf "\005{+b }%s %s\005{-} " "$i" "$r" DISTRO="$i $r"
fi fi
elif [ -r "/etc/palm-build-info" ]; then
# Palm Pre hack
DISTRO=$(grep "^PRODUCT_VERSION_STRING=Palm " /etc/palm-build-info | sed "s/^.*=Palm //")
elif [ -r "/etc/issue" ]; then elif [ -r "/etc/issue" ]; then
if [ "$1" = "--detail" ]; then
cat /etc/issue
exit 0
fi
# Otherwise, grab part of /etc/issue, ideally the distro and version # Otherwise, grab part of /etc/issue, ideally the distro and version
printf "\005{+b }%s\005{-} " $(head -n1 /etc/issue | sed "s/ [^0-9]* / /" | awk '{print $1 " " $2}') DISTRO=$(head -n1 /etc/issue | sed "s/ [^0-9]* / /" | awk '{print $1 " " $2}')
else else
echo "Byobu" DISTRO="Byobu"
fi fi
printf "\005{+b }%s\005{-} " "$DISTRO"

View file

@ -20,14 +20,14 @@
DIR="/proc/acpi/thermal_zone" DIR="/proc/acpi/thermal_zone"
if [ "$1" = "--detail" ]; then if [ "$1" = "--detail" ]; then
for i in `ls $DIR`; do for i in `ls $DIR 2>/dev/null`; do
echo "$i:" echo "$i:"
cat "$DIR/$i"/* cat "$DIR/$i"/*
done done
exit 0 exit 0
fi fi
for i in $MONITORED_TEMP `ls $DIR/*/temperature`; do for i in $MONITORED_TEMP `ls $DIR/*/temperature 2>/dev/null`; do
t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i")
printf "\005{=b kY}%s\005{-}\005{= kY}\260C\005{-} " "$t" printf "\005{=b kY}%s\005{-}\005{= kY}\260C\005{-} " "$t"
break break

View file

@ -23,7 +23,7 @@ if [ "$1" = "--detail" ]; then
exit 0 exit 0
fi fi
for i in `ls $DIR/*/temperature`; do for i in `ls $DIR/*/temperature 2>/dev/null`; do
t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i" | awk '{printf "%.0f", $1 *9/5 + 32}') t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i" | awk '{printf "%.0f", $1 *9/5 + 32}')
printf "\005{=b kY}%s\005{-}\005{= kY}\260F\005{-} " "$t" printf "\005{=b kY}%s\005{-}\005{= kY}\260F\005{-} " "$t"
break break

View file

@ -80,7 +80,8 @@ PKG="byobu"
# I would welcome contributions from other distros to make this # I would welcome contributions from other distros to make this
# more distro-agnostic. # more distro-agnostic.
mycache="/var/run/screen/S-$USER/$PKG.updates-available" [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu"
mycache="$DIR/$PKG.updates-available"
if [ "/var/lib/apt" -nt "$mycache" ] || [ "/var/lib/apt/lists" -nt "$mycache" ]; then if [ "/var/lib/apt" -nt "$mycache" ] || [ "/var/lib/apt/lists" -nt "$mycache" ]; then
# If apt is newer than mycache, background an update now # If apt is newer than mycache, background an update now

6
debian/changelog vendored
View file

@ -1,8 +1,10 @@
byobu (2.33) unreleased; urgency=low byobu (2.33) unreleased; urgency=low
* UNRELEASED * cpu_count, disk, logo, network, reboot_required, release, temp_c,
temp_f, updates_available: make byobu status scripts friendlier
for busybox environments (tested on the Palm Pre)
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 11 Sep 2009 08:04:05 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Mon, 14 Sep 2009 23:47:29 -0500
byobu (2.32-0ubuntu1) karmic; urgency=low byobu (2.32-0ubuntu1) karmic; urgency=low