From 4d49c500658b2e9c06742f0930dd203448ecabb3 Mon Sep 17 00:00:00 2001 From: Bob Igo Date: Sat, 6 Jun 2009 12:48:58 -0400 Subject: General bash comparison syntax cleanup. --- .../LinHES-config-svn/install_functions.sh | 54 +++++++++++----------- .../LinHES-config/install_functions.sh | 46 +++++++++--------- abs/core-testing/LinHES-config/ir_config.sh | 42 ++++++----------- 3 files changed, 64 insertions(+), 78 deletions(-) diff --git a/abs/core-testing/LinHES-config-svn/install_functions.sh b/abs/core-testing/LinHES-config-svn/install_functions.sh index ddade6d..4f6f7ed 100755 --- a/abs/core-testing/LinHES-config-svn/install_functions.sh +++ b/abs/core-testing/LinHES-config-svn/install_functions.sh @@ -38,7 +38,7 @@ update_db_settings Theme "$pick" function splash_setup (){ echo $CMDLINE | grep -q splash=silent - if [ $? = 0 ] + if [ $? -eq 0 ] then update_db_settings Hostbootsplash 1 else @@ -61,7 +61,7 @@ function setupremote { update_db_settings HostRemoteType "$Remotetype" #special case for special remote echo "Starting with support for $Remotetype" - if [ x$Remotetype = "xdvico" ] + if [ "$Remotetype" == "dvico" ] then /usr/sbin/lircd -d /dev/usb/hiddev0 else @@ -79,7 +79,7 @@ echo "Scanning for Hauppauge receiver" for hpgid in `lspci -nm -d4444: |cut -d" " -f6- |tr -d '"'|tr " " :` do line=`grep $hpgid $TEMPLATES/remotes/i2c.id` - if [ $? = 0 ] + if [ $? -eq 0 ] then modprobe lirc_i2c FoundReceiverType=`echo "$line"|cut -d"|" -f2` @@ -102,7 +102,7 @@ while read line do USBID=`echo "$line"|cut -d"|" -f1` lsusb -d "$USBID" > /dev/null 2>/dev/null - if [ $? = 0 ] + if [ $? -eq 0 ] then Remotetype=`echo "$line"|cut -d"|" -f2` echo "Found $Remotetype" @@ -111,7 +111,7 @@ do break fi done <$BASE/$TEMPLATES/remotes/receiver_usb.id -if [ $found_remote = 1 ] +if [ $found_remote -eq 1 ] then scan_for_hpg_receiver fi @@ -125,7 +125,7 @@ fi function rest_of_network () { #netmask echo $CMDLINE | grep -q netmask - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netmask=} NETMASK=${TEMPVAR%% *} @@ -139,7 +139,7 @@ function rest_of_network () { fi #gateway echo $CMDLINE | grep -q gateway - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*gateway=} GATEWAY=${TEMPVAR%% *} @@ -152,7 +152,7 @@ function rest_of_network () { #dns echo $CMDLINE | grep -q dns - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*dns=} DNS=${TEMPVAR%% *} @@ -165,7 +165,7 @@ function rest_of_network () { function init_network { echo $CMDLINE |grep -q netdev - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netdev=} MYTHDEFAULT=${TEMPVAR%% *} @@ -176,7 +176,7 @@ function init_network { echo $CMDLINE | grep -q ip - if [ $? = 0 ] + if [ $? -eq 0 ] then update_db_settings HostDefaulteth0 0 update_db_settings HostDefault${MYTHDEFAULT} 1 @@ -187,7 +187,7 @@ function init_network { TEMPVAR=${CMDLINE#*ip=} IP=${TEMPVAR%% *} - if [ x$IP = xdhcp ] + if [ "$IP" == "dhcp" ] then /sbin/dhcpcd $MYTHDEFAULT update_db_settings HostUseDHCP${MYTHDEFAULT} 0 @@ -202,11 +202,11 @@ function init_network { function init_remote { echo $CMDLINE | grep -q remoteport - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remoteport=} REMOTEPORT=${TEMPVAR%% *} - if [ x"$ReceiverType" = "xSerial" ] + if [ "$ReceiverType" == "Serial" ] then if [ -e /dev/$REMOTEPORT ] then @@ -220,7 +220,7 @@ function init_remote { fi echo $CMDLINE | grep -q remote - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remote=} Remotetype=${TEMPVAR%% *} @@ -239,7 +239,7 @@ ROOT=$1 DATA=$2 SWAP=$3 -if [ ! x$SWAP = xNO ] +if [ "$SWAP" != "NO" ] then SWAPLINE=",$SWAP,S" MKSWAPCMD="mkswap /dev/${disk}2" @@ -248,7 +248,7 @@ if [ ! x$SWAP = xNO ] MKSWAPCMD="" fi -if [ x$DATA = xALL ] +if [ "$DATA" == "ALL" ] then DATALINE=",,," EXTRALINE="" @@ -315,7 +315,7 @@ unmount_it () { copy_it () { - if [ x$1 = xALL ] + if [ "$1" == "ALL" ] then echo "Transferring system" unsquashfs -f -d /$mountpoint /.livesys/medium/system.sqf @@ -403,7 +403,7 @@ function find_uuid() { get_grub_map() { - rm /tmp/dev.map + [ -e /tmp/dev.map ] && rm /tmp/dev.map /sbin/grub --no-floppy --device-map /tmp/dev.map < /dev/null 2>&1 echo "freezing xfs fs" /usr/sbin/xfs_freeze -f /$mountpoint - if [ $? = 0 ] + if [ $? -eq 0 ] then sleep 40 echo "unfreezing xfs" @@ -531,7 +531,7 @@ case $1 in create_fstab fi #was 5 - if [ x$3 = xUPGRADE ] + if [ "$3" == "UPGRADE" ] then if [ ! -f /tmp/etc/KnoppMyth-version ] then @@ -558,11 +558,11 @@ case $1 in SWAPUUID=$FOUNDUUID FOUNDUUID="" - if [ x$4 = x ] + if [ "$4" == "" ] then #upgrade find_uuid ${2}3 - elif [ x$5 = xFULL_INSTALL ] + elif [ "$5" == "FULL_INSTALL" ] then #install find_uuid ${2}3 @@ -585,7 +585,7 @@ case $1 in if [ -f /tmp/etc/fstab ] then grep -q /dev/vg /tmp/etc/fstab - if [ $? = 0 ] + if [ $? -eq 0 ] then grep /dev/vg /tmp/etc/fstab >> /$mountpoint/etc/fstab grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs mkdir diff --git a/abs/core-testing/LinHES-config/install_functions.sh b/abs/core-testing/LinHES-config/install_functions.sh index ce9a057..9f38384 100755 --- a/abs/core-testing/LinHES-config/install_functions.sh +++ b/abs/core-testing/LinHES-config/install_functions.sh @@ -38,7 +38,7 @@ update_db_settings Theme "$pick" function parse_cmdline_2_db(){ echo $CMDLINE | grep -q displayres - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*displayres=} update_db_settings HostXres $TEMPVAR @@ -49,7 +49,7 @@ function parse_cmdline_2_db(){ function bootsplash_setup (){ echo $CMDLINE | grep -q splash=silent - if [ $? = 0 ] + if [ $? -eq 0 ] then update_db_settings Hostbootsplash 1 else @@ -72,7 +72,7 @@ function setupremote { update_db_settings HostRemoteType "$Remotetype" #special case for special remote printhl "Starting with support for $Remotetype" - if [ x$Remotetype = "xdvico" ] + if [ "$Remotetype" == "dvico" ] then /usr/sbin/lircd -d /dev/usb/hiddev0 else @@ -90,7 +90,7 @@ printhl " Scanning for Hauppauge receiver" for hpgid in `lspci -nm -d4444: |cut -d" " -f6- |tr -d '"'|tr " " :` do line=`grep $hpgid $TEMPLATES/remotes/i2c.id` - if [ $? = 0 ] + if [ $? -eq 0 ] then modprobe lirc_i2c FoundReceiverType=`echo "$line"|cut -d"|" -f2` @@ -131,7 +131,7 @@ while read line do USBID=`echo "$line"|cut -d"|" -f1` lsusb -d "$USBID" > /dev/null 2>/dev/null - if [ $? = 0 ] + if [ $? -eq 0 ] then Remotetype=`echo "$line"|cut -d"|" -f2` printhl "Found $Remotetype" @@ -140,7 +140,7 @@ do break fi done <$BASE/$TEMPLATES/remotes/receiver_usb.id -if [ $found_remote = 1 ] +if [ $found_remote -eq 1 ] then scan_for_hpg_receiver fi @@ -154,7 +154,7 @@ fi function rest_of_network () { #netmask echo $CMDLINE | grep -q netmask - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netmask=} NETMASK=${TEMPVAR%% *} @@ -168,7 +168,7 @@ function rest_of_network () { fi #gateway echo $CMDLINE | grep -q gateway - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*gateway=} GATEWAY=${TEMPVAR%% *} @@ -180,7 +180,7 @@ function rest_of_network () { #dns echo $CMDLINE | grep -q dns - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*dns=} DNS=${TEMPVAR%% *} @@ -193,7 +193,7 @@ function rest_of_network () { function init_network { echo $CMDLINE |grep -q netdev - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netdev=} MYTHDEFAULT=${TEMPVAR%% *} @@ -204,7 +204,7 @@ function init_network { echo $CMDLINE | grep -q ip - if [ $? = 0 ] + if [ $? -eq 0 ] then update_db_settings HostDefaulteth0 0 update_db_settings HostDefault${MYTHDEFAULT} 1 @@ -215,7 +215,7 @@ function init_network { TEMPVAR=${CMDLINE#*ip=} IP=${TEMPVAR%% *} - if [ x$IP = xdhcp ] + if [ "$IP" == "dhcp" ] then /sbin/dhcpcd $MYTHDEFAULT update_db_settings HostUseDHCP${MYTHDEFAULT} 0 @@ -230,7 +230,7 @@ function init_network { function init_remote { echo $CMDLINE | grep -q remoteport - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remoteport=} REMOTEPORT=${TEMPVAR%% *} @@ -248,7 +248,7 @@ function init_remote { fi echo $CMDLINE | grep -q remote - if [ $? = 0 ] + if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remote=} Remotetype=${TEMPVAR%% *} @@ -267,7 +267,7 @@ ROOT=$1 DATA=$2 SWAP=$3 -if [ ! x$SWAP = xNO ] +if [ ! "$SWAP" == "NO" ] then SWAPLINE=",$SWAP,S" MKSWAPCMD="mkswap /dev/${disk}2" @@ -276,7 +276,7 @@ if [ ! x$SWAP = xNO ] MKSWAPCMD="" fi -if [ x$DATA = xALL ] +if [ "$DATA" == "ALL" ] then DATALINE=",,," EXTRALINE="" @@ -343,7 +343,7 @@ unmount_it () { copy_it () { - if [ x$1 = xALL ] + if [ "$1" == "ALL" ] then echo "Transferring system" unsquashfs -f -d /$mountpoint /.livesys/medium/system.sqf @@ -431,7 +431,7 @@ function find_uuid() { get_grub_map() { - rm /tmp/dev.map + [ -e /tmp/dev.map ] && rm /tmp/dev.map /sbin/grub --no-floppy --device-map /tmp/dev.map < /dev/null 2>&1 echo "freezing xfs fs" /usr/sbin/xfs_freeze -f /$mountpoint - if [ $? = 0 ] + if [ $? -eq 0 ] then sleep 40 echo "unfreezing xfs" @@ -559,7 +559,7 @@ case $1 in create_fstab fi #was 5 - if [ x$3 = xUPGRADE ] + if [ "$3" == "UPGRADE" ] then if [ ! -f /tmp/etc/KnoppMyth-version ] then @@ -586,11 +586,11 @@ case $1 in SWAPUUID=$FOUNDUUID FOUNDUUID="" - if [ x$4 = x ] + if [ "$4" == "" ] then #upgrade find_uuid ${2}3 - elif [ x$5 = xFULL_INSTALL ] + elif [ "$5" == "FULL_INSTALL" ] then #install find_uuid ${2}3 @@ -613,7 +613,7 @@ case $1 in if [ -f /tmp/etc/fstab ] then grep -q /dev/vg /tmp/etc/fstab - if [ $? = 0 ] + if [ $? -eq 0 ] then grep /dev/vg /tmp/etc/fstab >> /$mountpoint/etc/fstab grep /dev/vg /tmp/etc/fstab | awk -v mount=$mountpoint ' { print "/" mount $2 }' |xargs mkdir diff --git a/abs/core-testing/LinHES-config/ir_config.sh b/abs/core-testing/LinHES-config/ir_config.sh index 69d8406..28134e2 100644 --- a/abs/core-testing/LinHES-config/ir_config.sh +++ b/abs/core-testing/LinHES-config/ir_config.sh @@ -2,8 +2,7 @@ function include_lirc () { config_file=$1 include_file=$2 grep -q ${include_file} ${config_file} - if [ $? = 0 ] - then + if [ "$?" == "0" ]; then echo ${include_file} already present else echo "include \"${include_file}\"" >> $config_file @@ -39,8 +38,7 @@ function setup_ir_remote { #make backup copy mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` mv ${BASE}/etc/lircrc ${BASE}/etc/lircrc.`date +%Y-%m-%d-%H-%M` - if [ $HostBlasterType = pvr150 ] - then + if [ "$HostBlasterType" == "pvr150" ]; then Remotetype=hauppauge-blaster fi @@ -58,18 +56,15 @@ function setup_ir_remote { chmod 755 /etc/lircrc daemon_add="lircd $daemon_add" #standard location for mythtv lircrc - if [ ! -e /home/mythtv/.mythtv/lircrc ] - then - if [ ! -d /home/mythtv/.mythtv ] - then + if [ ! -e /home/mythtv/.mythtv/lircrc ]; then + if [ ! -d /home/mythtv/.mythtv ]; then mkdir /home/mythtv/.mythtv chown mythtv:mythtv /home/mythtv/.mythtv fi ln -s /etc/lircrc /home/mythtv/.mythtv/lircrc 2> /dev/null fi #standard location for lircrc - if [ ! -e /home/mythtv/.lircrc ] - then + if [ ! -e /home/mythtv/.lircrc ]; then ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null fi # echo "Sending hup to lircd" @@ -141,16 +136,14 @@ function setup_lcd () { x) echo "empty lcd" ;; *) echo "setup lcd" - if [ -f $TEMPLATES/LCD/$LCDtype/modules ] - then + if [ -f $TEMPLATES/LCD/$LCDtype/modules ]; then sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage #should also modprobe fi - if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ] - then + if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ]; then cp_and_log $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc # install="lcdproc $install" daemon_add="lcdd $daemon_add" @@ -160,10 +153,8 @@ function setup_lcd () { fi #check if lirc capable,if so then call setupremote #if not in tinker mode check for remote - if [ ! x$Remotetype = xtinker ] - then - if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ] - then + if [ "$Remotetype" != "tinker" ]; then + if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ]; then cd $TEMPLATES/LCD/$LCDtype for i in lircd* do @@ -182,18 +173,15 @@ function setup_lcd () { } function setup_blaster_proto () { - if [ x$HostBlasterType = x ] - then + if [ "$HostBlasterType" == "" ]; then HostBlasterType = "crap" fi - if [ ! $HostBlasterType = pvr150 -a ! $HostBlasterType = None ] - then + if [[ ("$HostBlasterType" != "pvr150") && ("$HostBlasterType" != "None") ]]; then for i in `seq $Hostnumblaster` do TEMP=HostTransmitproto_$i eval proto=\$${TEMP} - if [ -f $TEMPLATES/transmit/${proto}/lircd.conf ] - then + if [ -f $TEMPLATES/transmit/${proto}/lircd.conf ]; then include_lirc ${BASE}/etc/lircd.conf $TEMPLATES/transmit/${proto}/lircd.conf fi done @@ -207,8 +195,7 @@ function setup_blaster_proto () { function setup_blaster_transmiter () { echo "setup_blaster_transmiter" #if it's Reciever type, then these modules have already been loaded. - if [ ! x$HostBlasterType = xReceiver ] - then + if [ "$HostBlasterType" != "Receiver" ]; then case $HostBlasterType in None) echo "no blaster" sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage @@ -235,8 +222,7 @@ function setup_blaster_transmiter () { } function setupir () { - if [ ! x$Remotetype = xtinker ] - then + if [ "$Remotetype" != "tinker" ]; then setup_ir_remote setup_ir_receiver unload_all_lirc -- cgit v0.12