From 74b55168e744e7e8f64db02338dbd1e9ec550275 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 9 Jul 2013 09:02:25 -0500 Subject: [PATCH] usr/lib/byobu/ec2_cost, usr/lib/byobu/hostname, usr/lib/byobu/include/shutil, usr/lib/byobu/ip_address, usr/lib/byobu/updates_available: --- debian/changelog | 4 +++- usr/lib/byobu/ec2_cost | 4 ++-- usr/lib/byobu/hostname | 2 +- usr/lib/byobu/include/shutil | 2 +- usr/lib/byobu/ip_address | 8 ++++---- usr/lib/byobu/updates_available | 16 ++++++++-------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/debian/changelog b/debian/changelog index 240351dd..defb57bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,9 @@ byobu (5.44) unreleased; urgency=low * usr/lib/byobu/wifi_quality: - 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 -- Dustin Kirkland Sun, 02 Jun 2013 00:15:10 -0500 diff --git a/usr/lib/byobu/ec2_cost b/usr/lib/byobu/ec2_cost index a39006bb..a16f99fc 100755 --- a/usr/lib/byobu/ec2_cost +++ b/usr/lib/byobu/ec2_cost @@ -37,11 +37,11 @@ __ec2_cost() { read rate < "$cache.rate" elif metadata_available; then # 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 "$cache.zone" 2>/dev/null & sleep 0.02 [ -s "$cache.zone" ] && read zone < "$cache.zone" 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 "$cache.type" 2>/dev/null & sleep 0.02 [ -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" diff --git a/usr/lib/byobu/hostname b/usr/lib/byobu/hostname index d044e5bb..c534393e 100755 --- a/usr/lib/byobu/hostname +++ b/usr/lib/byobu/hostname @@ -28,7 +28,7 @@ __hostname() { if metadata_available; then local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/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 "$cache" 2>/dev/null & sleep 0.02 [ -s "$cache" ] && read h < "$cache" else diff --git a/usr/lib/byobu/include/shutil b/usr/lib/byobu/include/shutil index 2a53b9b7..e5b5f838 100755 --- a/usr/lib/byobu/include/shutil +++ b/usr/lib/byobu/include/shutil @@ -218,7 +218,7 @@ metadata_available() { # Must seed the cache 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 - wget -q -O "$cache" --timeout=10 --tries=1 http://169.254.169.254 2>/dev/null /dev/null & + wget -q --timeout=10 --tries=1 http://169.254.169.254 "$cache" 2>/dev/null & sleep 0.02 [ -s "$cache" ] && x=1 fi diff --git a/usr/lib/byobu/ip_address b/usr/lib/byobu/ip_address index 7e8278ac..3964aede 100755 --- a/usr/lib/byobu/ip_address +++ b/usr/lib/byobu/ip_address @@ -42,12 +42,12 @@ __ip_address() { 1|true|yes) if [ "$IP_EXTERNAL" = "1" ]; then # 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 "$cache" 2>/dev/null & sleep 0.02 else # Background an update 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 "$cache" 2>/dev/null & 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 & @@ -61,12 +61,12 @@ __ip_address() { ;; *) 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 "$cache" 2>/dev/null & sleep 0.02 [ -s "$cache" ] && read ipaddr < "$cache" elif metadata_available; then # 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 "$cache" 2>/dev/null & sleep 0.02 [ -s "$cache" ] && read ipaddr < "$cache" else diff --git a/usr/lib/byobu/updates_available b/usr/lib/byobu/updates_available index 0cd19807..5e641c94 100755 --- a/usr/lib/byobu/updates_available +++ b/usr/lib/byobu/updates_available @@ -50,29 +50,29 @@ ___update_cache() { # Ensure that no more than one of these run at a given time if [ -x /usr/lib/update-notifier/apt-check ]; then # 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 # 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 # 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 # 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 # If yum exists, use it # 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 # 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 # If homebrew (Mac OSX) exists, use it, also background if flock exists 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 - brew outdated | wc -l > $mycache & + brew outdated | wc -l >$mycache & fi fi }