just curious if this will actually run, I modelled it after an example from someone elses script. My big worries are
- Is the variable included when the script is run?
- In the case statements, will the echo / mv / & close work correctly?
Code Updated
#! /bin/sh
#save as ads.sh
#run command: chmod +x ads.sh
#usage ./ads.sh {on|off}
#stop framework
#/etc/init.d/framework stop
#create backup dir if needed
mkdir -p /var/local/adunits.bkp
#if ads.sh on
case "$1" in
on)
#move, touch, exit
echo "Turning Ad support on..."
mv /var/local/adunits/* /var/local/adunits.bkp
;;
#if ads.sh off
off)
#remove tmp
echo "Ads turned off..."
mv /var/local/adunits.bkp/* /var/local/adunits
;;
#else
*)
echo "Usage: ./ads.sh {on|off}"
exit 1
;;
esac
#restart framwork
#/etc/init.d/framework start
#bye
exit 0
Thanks ahead!
The
mvcommands look possibly dodgy. From a mv man page:Note that the last argument should be a target file or directory.
So things like:
Are likely to overwrite the ‘last’ file in
/target_dir– which is probably not what you want.is probably what you mean.