remove 'bashisms' or explicit use bash

This commit is contained in:
HW42 2015-02-05 03:14:41 +01:00 committed by Marek Marczykowski-Górecki
parent 77392fd3a9
commit dad5bfbd18
25 changed files with 45 additions and 47 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# postrm script for core-agent-linux # postrm script for core-agent-linux
# #
# see: dh_installdeb(1) # see: dh_installdeb(1)
@ -37,7 +37,7 @@ set -e
# the debian-policy package # the debian-policy package
if [ "${1}" = "remove" ] ; then if [ "${1}" = "remove" ] ; then
/usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/null || : /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas > /dev/null 2>&1 || :
if [ -L /lib/firmware/updates ]; then if [ -L /lib/firmware/updates ]; then
rm /lib/firmware/updates rm /lib/firmware/updates

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# preinst script for core-agent-linux # preinst script for core-agent-linux
# #
# see: dh_installdeb(1) # see: dh_installdeb(1)

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# prerm script for core-agent-linux # prerm script for core-agent-linux
# #
# see: dh_installdeb(1) # see: dh_installdeb(1)

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
apps="evince /usr/libexec/evinced soffice firefox" apps="evince /usr/libexec/evinced soffice firefox"
@ -18,7 +18,7 @@ echo "Sleeping..."
PREV_IO=0 PREV_IO=0
while true; do while true; do
IO=`vmstat -D | awk '/read|write/ {IOs+=$1} END {print IOs}'` IO=`vmstat -D | awk '/read|write/ {IOs+=$1} END {print IOs}'`
if [ $IO -lt $[ $PREV_IO + 50 ] ]; then if [ $IO -lt $(( $PREV_IO + 50 )) ]; then
break; break;
fi fi
PREV_IO=$IO PREV_IO=$IO

View File

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
if [ x$2 == xup ]; then if [ x$2 = xup ]; then
INET=$(/sbin/ip addr show dev $1 | /bin/grep inet) INET=$(/sbin/ip addr show dev $1 | /bin/grep inet)
qubesdb-write /qubes-netvm-external-ip "$INET" qubesdb-write /qubes-netvm-external-ip "$INET"
fi fi
if [ x$2 == xdown ]; then if [ x$2 = xdown ]; then
qubesdb-write /qubes-netvm-external-ip "" qubesdb-write /qubes-netvm-external-ip ""
fi fi

View File

@ -3,7 +3,7 @@
RULE_FILTER="INPUT -i vif+ -p tcp --dport 8082 -j ACCEPT" RULE_FILTER="INPUT -i vif+ -p tcp --dport 8082 -j ACCEPT"
RULE_NAT="PR-QBS-SERVICES -i vif+ -d 10.137.255.254 -p tcp --dport 8082 -j REDIRECT" RULE_NAT="PR-QBS-SERVICES -i vif+ -d 10.137.255.254 -p tcp --dport 8082 -j REDIRECT"
if [ "$1" == "start" ]; then if [ "$1" = "start" ]; then
cat <<__EOF__ | iptables-restore -n cat <<__EOF__ | iptables-restore -n
*filter *filter
-I $RULE_FILTER -I $RULE_FILTER

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
PIDFILE=/var/run/qubes/qubes-firewall.pid PIDFILE=/var/run/qubes/qubes-firewall.pid
@ -7,10 +7,10 @@ XENSTORE_IPTABLES_HEADER=/qubes-iptables-header
XENSTORE_ERROR=/qubes-iptables-error XENSTORE_ERROR=/qubes-iptables-error
OLD_RULES="" OLD_RULES=""
# PIDfile handling # PIDfile handling
[[ -e $PIDFILE ]] && kill -s 0 $(<$PIDFILE) 2>/dev/null && exit 0 [ -e "$PIDFILE" ] && kill -s 0 $(cat "$PIDFILE") 2>/dev/null && exit 0
echo $$ >$PIDFILE echo $$ >$PIDFILE
trap 'exit 0' SIGTERM trap 'exit 0' TERM
FIRST_TIME=yes FIRST_TIME=yes
@ -36,11 +36,11 @@ while true; do
RULES=$(qubesdb-read $XENSTORE_IPTABLES_HEADER) RULES=$(qubesdb-read $XENSTORE_IPTABLES_HEADER)
IPTABLES_SAVE=$(iptables-save | sed '/^\*filter/,/^COMMIT/d') IPTABLES_SAVE=$(iptables-save | sed '/^\*filter/,/^COMMIT/d')
OUT=`echo -e "$RULES\n$IPTABLES_SAVE" | iptables-restore 2>&1 || true` OUT=$(printf '%s\n%s\n' "$RULES" "$IPTABLES_SAVE" | sed 's/\\n/\n/g' | iptables-restore 2>&1 || true)
for i in $(qubesdb-list -f /qubes-iptables-domainrules) ; do for i in $(qubesdb-list -f /qubes-iptables-domainrules) ; do
RULES=$(qubesdb-read "$i") RULES=$(qubesdb-read "$i")
ERRS=`echo -e "$RULES" | /sbin/iptables-restore -n 2>&1 || true` ERRS=$(printf '%s\n' "$RULES" | sed 's/\\n/\n/g' | /sbin/iptables-restore -n 2>&1 || true)
if [ -n "$ERRS" ]; then if [ -n "$ERRS" ]; then
echo "Failed applying rules for $i: $ERRS" >&2 echo "Failed applying rules for $i: $ERRS" >&2
OUT="$OUT$ERRS" OUT="$OUT$ERRS"
@ -48,7 +48,7 @@ while true; do
done done
qubesdb-write $XENSTORE_ERROR "$OUT" qubesdb-write $XENSTORE_ERROR "$OUT"
if [ -n "$OUT" ]; then if [ -n "$OUT" ]; then
DISPLAY=:0 /usr/bin/notify-send -t 3000 "Firewall loading error ($HOSTNAME)" "$OUT" || : DISPLAY=:0 /usr/bin/notify-send -t 3000 "Firewall loading error ($(hostname))" "$OUT" || :
fi fi
# Check if user didn't define some custom rules to be applied as well... # Check if user didn't define some custom rules to be applied as well...

View File

@ -1,23 +1,23 @@
#!/bin/bash #!/bin/sh
set -e set -e
PIDFILE=/var/run/qubes/qubes-netwatcher.pid PIDFILE=/var/run/qubes/qubes-netwatcher.pid
CURR_NETCFG="" CURR_NETCFG=""
# PIDfile handling # PIDfile handling
[[ -e $PIDFILE ]] && kill -s 0 $(<$PIDFILE) 2>/dev/null && exit 0 [ -e "$PIDFILE" ] && kill -s 0 $(cat "$PIDFILE") 2>/dev/null && exit 0
echo $$ >$PIDFILE echo $$ >$PIDFILE
trap 'exit 0' SIGTERM trap 'exit 0' TERM
while true; do while true; do
NET_DOMID=$(xenstore-read qubes-netvm-domid || :) NET_DOMID=$(xenstore-read qubes-netvm-domid || :)
if [[ -n "$NET_DOMID" ]] && [[ $NET_DOMID -gt 0 ]]; then if [ -n "$NET_DOMID" ] && [ $NET_DOMID -gt 0 ]; then
UNTRUSTED_NETCFG=$(xenstore-read /local/domain/$NET_DOMID/qubes-netvm-external-ip || :) UNTRUSTED_NETCFG=$(xenstore-read /local/domain/$NET_DOMID/qubes-netvm-external-ip || :)
# UNTRUSTED_NETCFG is not parsed in any way # UNTRUSTED_NETCFG is not parsed in any way
# thus, no sanitization ready # thus, no sanitization ready
# but be careful when passing it to other shell scripts # but be careful when passing it to other shell scripts
if [[ "$UNTRUSTED_NETCFG" != "$CURR_NETCFG" ]]; then if [ "$UNTRUSTED_NETCFG" != "$CURR_NETCFG" ]; then
/sbin/service qubes-firewall stop /sbin/service qubes-firewall stop
/sbin/service qubes-firewall start /sbin/service qubes-firewall start
CURR_NETCFG="$UNTRUSTED_NETCFG" CURR_NETCFG="$UNTRUSTED_NETCFG"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
type nm-applet > /dev/null 2>&1 || exit 0 which nm-applet > /dev/null 2>&1 || exit 0
# Hide nm-applet when network-manager is disabled # Hide nm-applet when network-manager is disabled
nm_enabled=false nm_enabled=false

View File

@ -11,7 +11,7 @@ if [ -r /rw/config/suspend-module-blacklist ]; then
MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /rw/config/suspend-module-blacklist`" MODULES_BLACKLIST="$MODULES_BLACKLIST `cat /rw/config/suspend-module-blacklist`"
fi fi
if [ x"$action" == x"suspend" ]; then if [ x"$action" = x"suspend" ]; then
dbus-send --system --print-reply \ dbus-send --system --print-reply \
--dest=org.freedesktop.NetworkManager \ --dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \ /org/freedesktop/NetworkManager \
@ -19,7 +19,7 @@ if [ x"$action" == x"suspend" ]; then
service NetworkManager stop service NetworkManager stop
# Force interfaces down, just in case when NM didn't done it # Force interfaces down, just in case when NM didn't done it
for if in `ls /sys/class/net|grep -v "lo\|vif"`; do for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
if [ "`cat /sys/class/net/$if/device/devtype 2>/dev/null`" == "vif" ]; then if [ "`cat /sys/class/net/$if/device/devtype 2>/dev/null`" = "vif" ]; then
continue continue
fi fi
ip l s $if down ip l s $if down

View File

@ -9,8 +9,7 @@ if [ -d "$args" ] ; then
else else
echo "Checking if arguments is matching a command" echo "Checking if arguments is matching a command"
COMMAND=`echo $args | cut -d ' ' -f 1` COMMAND=`echo $args | cut -d ' ' -f 1`
TYPE=`type -t $COMMAND` if which "$COMMAND"; then
if [ "$TYPE" == "file" ] ; then
echo "Redirecting STDIN to $args" echo "Redirecting STDIN to $args"
# Parsing args to handle quotes correctly # Parsing args to handle quotes correctly
# Dangerous method if args are uncontrolled # Dangerous method if args are uncontrolled

View File

@ -1,31 +1,31 @@
set -e set -e
read filename read filename
if [[ "${filename}" = xdgicon:* ]]; then if [ "${filename%%:*}" = xdgicon ]; then
# get biggest icon from hicolor theme # get biggest icon from hicolor theme
filename="${filename#*:}.png" filename="${filename#*:}.png"
candidate= candidate=
for dir in /usr/share/icons/{hicolor/,}; do for dir in /usr/share/icons/hicolor/ /usr/share/icons/; do
candidate=$(find -L "${dir}" -type f -name "${filename}") candidate=$(find -L "${dir}" -type f -name "${filename}")
if [[ -n "${candidate}" ]]; then if [ -n "${candidate}" ]; then
candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1) candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1)
break break
fi fi
done done
[[ -n "${candidate}" ]] [ -n "${candidate}" ]
filename="${candidate}" filename="${candidate}"
elif [[ "${filename}" = "-" ]] || [[ "${filename}" = *":-" ]]; then elif [ "${filename}" = "-" ] || [ "${filename##*:}" = "-" ]; then
tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)" tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)"
cat > "${tmpfile}" cat > "${tmpfile}"
if [[ "$filename" = *":-" ]]; then if [ "${filename##*:}" = "-" ]; then
tmpfile="${filename%:*}:${tmpfile}" tmpfile="${filename%:*}:${tmpfile}"
fi fi
filename="${tmpfile}" filename="${tmpfile}"
elif ! [[ -r "${filename}" ]]; then elif ! [ -r "${filename}" ]; then
exit 1 exit 1
fi fi
@ -34,6 +34,6 @@ fi
identify -format '%w %h\n' "$filename" | sed -e '/^$/d' identify -format '%w %h\n' "$filename" | sed -e '/^$/d'
convert -depth 8 "$filename" rgba:- convert -depth 8 "$filename" rgba:-
[[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true [ -n "${tmpfile}" ] && rm -f ${tmpfile} || true
# vim: ft=sh ts=4 sw=4 et # vim: ft=sh ts=4 sw=4 et

View File

@ -11,8 +11,7 @@ if [ -f "$args" ] ; then
else else
echo "Checking if arguments is matching a command" >&2 echo "Checking if arguments is matching a command" >&2
COMMAND=`echo $args | cut -d ' ' -f 1` COMMAND=`echo $args | cut -d ' ' -f 1`
TYPE=`type -t $COMMAND` if which "$COMMAND"; then
if [ "$TYPE" == "file" ] ; then
tmpdir=`mktemp -d` tmpdir=`mktemp -d`
mkfifo $tmpdir/backup-data mkfifo $tmpdir/backup-data
echo "Redirecting $args to STDOUT" >&2 echo "Redirecting $args to STDOUT" >&2

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# The Qubes OS Project, http://www.qubes-os.org # The Qubes OS Project, http://www.qubes-os.org
# #

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# The Qubes OS Project, http://www.qubes-os.org # The Qubes OS Project, http://www.qubes-os.org
# #

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# The Qubes OS Project, http://www.qubes-os.org # The Qubes OS Project, http://www.qubes-os.org
# #

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 90 90 # chkconfig: 345 90 90
# description: Executes Qubes core scripts at VM boot # description: Executes Qubes core scripts at VM boot

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 85 85 # chkconfig: 345 85 85
# description: Executes Qubes core scripts at AppVM boot # description: Executes Qubes core scripts at AppVM boot

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 90 90 # chkconfig: 345 90 90
# description: Executes Qubes core scripts at NetVM boot # description: Executes Qubes core scripts at NetVM boot

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 91 91 # chkconfig: 345 91 91
# description: Starts Qubes Firewall monitor # description: Starts Qubes Firewall monitor

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 92 92 # chkconfig: 345 92 92
# description: Starts Qubes Network monitor # description: Starts Qubes Network monitor

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# chkconfig: 345 90 90 # chkconfig: 345 90 90
# description: Executes Qubes core scripts at VM boot # description: Executes Qubes core scripts at VM boot

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# tinyproxy Startup script for the tinyproxy server as Qubes updates proxy # tinyproxy Startup script for the tinyproxy server as Qubes updates proxy
# #

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# List of services enabled by default (in case of absence of qubesdb entry) # List of services enabled by default (in case of absence of qubesdb entry)
DEFAULT_ENABLED_NETVM="network-manager qubes-network qubes-update-check qubes-updates-proxy" DEFAULT_ENABLED_NETVM="network-manager qubes-network qubes-update-check qubes-updates-proxy"

View File

@ -4,4 +4,4 @@ ConditionPathExists=/var/run/qubes-service/qubes-update-check
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'if [ -e /usr/bin/yum ]; then yum -q check-update >/dev/null; [ $? -eq 100 ] && echo 1 || echo 0; else apt-get -q update > /dev/null; apt-get -s upgrade | awk "/^Inst/{ print $2 }" | [[ $(wc -L) -eq 0 ]] && echo 0 || echo 1; fi' ExecStart=/usr/lib/qubes/qrexec-client-vm dom0 qubes.NotifyUpdates /bin/sh -c 'if [ -e /usr/bin/yum ]; then yum -q check-update >/dev/null; [ $? -eq 100 ] && echo 1 || echo 0; else apt-get -q update > /dev/null; apt-get -s upgrade | awk "/^Inst/{ print $2 }" | [ $(wc -L) -eq 0 ] && echo 0 || echo 1; fi'