usr/lib/byobu/ec2_cost, usr/lib/byobu/hostname,

usr/lib/byobu/include/shutil, usr/lib/byobu/ip_address,
usr/lib/byobu/updates_available:
This commit is contained in:
Dustin Kirkland 2013-07-09 09:02:25 -05:00
commit 74b55168e7
6 changed files with 19 additions and 17 deletions

4
debian/changelog vendored
View file

@ -2,7 +2,9 @@ byobu (5.44) unreleased; urgency=low
* usr/lib/byobu/wifi_quality: * usr/lib/byobu/wifi_quality:
- minor fix for wifi quality printing, sometimes = and sometimes : - minor fix for wifi quality printing, sometimes = and sometimes :
* usr/lib/byobu/include/shutil: * usr/lib/byobu/ec2_cost, usr/lib/byobu/hostname,
usr/lib/byobu/include/shutil, usr/lib/byobu/ip_address,
usr/lib/byobu/updates_available:
- ensure input/output/stderr are handled properly for background process - ensure input/output/stderr are handled properly for background process
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 02 Jun 2013 00:15:10 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Sun, 02 Jun 2013 00:15:10 -0500

View file

@ -37,11 +37,11 @@ __ec2_cost() {
read rate < "$cache.rate" read rate < "$cache.rate"
elif metadata_available; then elif metadata_available; then
# Try to use metadata service # Try to use metadata service
[ -s "$cache.zone" ] || wget -q -O "$cache.zone" http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null & [ -s "$cache.zone" ] || wget -q http://169.254.169.254/latest/meta-data/placement/availability-zone </dev/null >"$cache.zone" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache.zone" ] && read zone < "$cache.zone" [ -s "$cache.zone" ] && read zone < "$cache.zone"
zone=${zone%%[a-z]} zone=${zone%%[a-z]}
[ -s "$cache.type" ] || wget -q -O "$cache.type" http://169.254.169.254/latest/meta-data/instance-type 2>/dev/null & [ -s "$cache.type" ] || wget -q http://169.254.169.254/latest/meta-data/instance-type </dev/null >"$cache.type" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache.type" ] && read type < "$cache.type" [ -s "$cache.type" ] && read type < "$cache.type"
$BYOBU_PREFIX/lib/byobu/include/ec2instancespricing.py --type ondemand --filter-region $zone --filter-type $type --filter-os-type linux --format csv | tail -n1 > "$cache.rate" $BYOBU_PREFIX/lib/byobu/include/ec2instancespricing.py --type ondemand --filter-region $zone --filter-type $type --filter-os-type linux --format csv | tail -n1 > "$cache.rate"

View file

@ -28,7 +28,7 @@ __hostname() {
if metadata_available; then if metadata_available; then
local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/hostname" local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/hostname"
# Background a retrieval of our public hostname # Background a retrieval of our public hostname
wget -q -O "$cache" http://169.254.169.254/latest/meta-data/public-hostname 2>/dev/null & wget -q http://169.254.169.254/latest/meta-data/public-hostname </dev/null >"$cache" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache" ] && read h < "$cache" [ -s "$cache" ] && read h < "$cache"
else else

View file

@ -218,7 +218,7 @@ metadata_available() {
# Must seed the cache # Must seed the cache
if [ -e /etc/ec2_version ] || [ -e /usr/sbin/update-grub-legacy-ec2 ]; then if [ -e /etc/ec2_version ] || [ -e /usr/sbin/update-grub-legacy-ec2 ]; then
# This *looks* like a machine with metadata, so background a potentially slow check # This *looks* like a machine with metadata, so background a potentially slow check
wget -q -O "$cache" --timeout=10 --tries=1 http://169.254.169.254 2>/dev/null </dev/null >/dev/null & wget -q --timeout=10 --tries=1 http://169.254.169.254 </dev/null >"$cache" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache" ] && x=1 [ -s "$cache" ] && x=1
fi fi

View file

@ -42,12 +42,12 @@ __ip_address() {
1|true|yes) 1|true|yes)
if [ "$IP_EXTERNAL" = "1" ]; then if [ "$IP_EXTERNAL" = "1" ]; then
# Background an update # Background an update
wget -q -O "$cache" http://v6.ipv6-test.com/api/myip.php 2>/dev/null & wget -q http://v6.ipv6-test.com/api/myip.php </dev/null >"$cache" 2>/dev/null &
sleep 0.02 sleep 0.02
else else
# Background an update # Background an update
if [ -x /sbin/ip ]; then if [ -x /sbin/ip ]; then
LC_ALL=C /sbin/ip -6 addr list dev "$interface" scope global >"$cache" 2>/dev/null & LC_ALL=C /sbin/ip -6 addr list dev "$interface" scope global </dev/null >"$cache" 2>/dev/null &
elif $BYOBU_TEST ifconfig >/dev/null 2>&1; then elif $BYOBU_TEST ifconfig >/dev/null 2>&1; then
LC_ALL=c ifconfig "$interface" | grep "inet6 " | awk '{print $2}' | sed -e "s/%.*//" >"$cache" 2>/dev/null & LC_ALL=c ifconfig "$interface" | grep "inet6 " | awk '{print $2}' | sed -e "s/%.*//" >"$cache" 2>/dev/null &
@ -61,12 +61,12 @@ __ip_address() {
;; ;;
*) *)
if [ "$IP_EXTERNAL" = "1" ]; then if [ "$IP_EXTERNAL" = "1" ]; then
wget -q -O "$cache" http://v4.ipv6-test.com/api/myip.php 2>/dev/null & wget -q http://v4.ipv6-test.com/api/myip.php </dev/null >"$cache" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache" ] && read ipaddr < "$cache" [ -s "$cache" ] && read ipaddr < "$cache"
elif metadata_available; then elif metadata_available; then
# We're in EC2, so get our public IP address # We're in EC2, so get our public IP address
wget -q -O "$cache" http://169.254.169.254/latest/meta-data/public-ipv4 2>/dev/null & wget -q http://169.254.169.254/latest/meta-data/public-ipv4 </dev/null >"$cache" 2>/dev/null &
sleep 0.02 sleep 0.02
[ -s "$cache" ] && read ipaddr < "$cache" [ -s "$cache" ] && read ipaddr < "$cache"
else else

View file

@ -50,29 +50,29 @@ ___update_cache() {
# Ensure that no more than one of these run at a given time # Ensure that no more than one of these run at a given time
if [ -x /usr/lib/update-notifier/apt-check ]; then if [ -x /usr/lib/update-notifier/apt-check ]; then
# If apt-check binary exists, use it # If apt-check binary exists, use it
flock -xn "$flock" /usr/lib/update-notifier/apt-check 2>&1 | awk '-F;' 'END { print $1, $2 }' > "$mycache" & flock -xn "$flock" /usr/lib/update-notifier/apt-check 2>&1 | awk '-F;' 'END { print $1, $2 }' >"$mycache" 2>/dev/null &
elif $BYOBU_TEST apt-get >/dev/null; then elif $BYOBU_TEST apt-get >/dev/null; then
# If apt-get exists, use it # If apt-get exists, use it
flock -xn "$flock" apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst > $mycache & flock -xn "$flock" apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst >$mycache 2>/dev/null &
elif $BYOBU_TEST pkcon >/dev/null; then elif $BYOBU_TEST pkcon >/dev/null; then
# use packagekit to show list of packages # use packagekit to show list of packages
flock -xn "$flock" pkcon get-updates -p | grep -c '^Package' > "$mycache" & flock -xn "$flock" pkcon get-updates -p | grep -c '^Package' >"$mycache" 2>/dev/null &
elif $BYOBU_TEST zypper >/dev/null; then elif $BYOBU_TEST zypper >/dev/null; then
# If zypper exists, use it # If zypper exists, use it
flock -xn "$flock" zypper --no-refresh lu --best-effort | grep -c 'v |' > $mycache & flock -xn "$flock" zypper --no-refresh lu --best-effort | grep -c 'v |' >$mycache 2>/dev/null &
elif $BYOBU_TEST yum >/dev/null; then elif $BYOBU_TEST yum >/dev/null; then
# If yum exists, use it # If yum exists, use it
# TODO: We need a better way of counting updates available from a RH expert # TODO: We need a better way of counting updates available from a RH expert
flock -xn "$flock" yum list updates -q | grep -vc "Updated Packages" > $mycache & flock -xn "$flock" yum list updates -q | grep -vc "Updated Packages" >$mycache 2>/dev/null &
elif $BYOBU_TEST pacman >/dev/null; then elif $BYOBU_TEST pacman >/dev/null; then
# If pacman (Archlinux) exists, use it # If pacman (Archlinux) exists, use it
LC_ALL=C flock -xn "$flock" pacman -Sup | grep -vc "^\(::\| \)" > $mycache & LC_ALL=C flock -xn "$flock" pacman -Sup | grep -vc "^\(::\| \)" >$mycache 2>/dev/null &
elif $BYOBU_TEST brew >/dev/null; then elif $BYOBU_TEST brew >/dev/null; then
# If homebrew (Mac OSX) exists, use it, also background if flock exists # If homebrew (Mac OSX) exists, use it, also background if flock exists
if $BYOBU_TEST flock; then if $BYOBU_TEST flock; then
flock -xn "$flock" brew outdated | wc -l > $mycache & flock -xn "$flock" brew outdated | wc -l >$mycache 2>/dev/null &
else else
brew outdated | wc -l > $mycache & brew outdated | wc -l >$mycache &
fi fi
fi fi
} }