I wrote a couple scripts a few months ago. pfdown - Which asked how many minutes, and then executed a line to do just that bringing the firewall back up when the minutes had run out. And pfup - which was used to locate the pid of the sleeping pfdown process and kill -HUP the pid and allow the rest of the pfdown script to bring the firewall back up.
Both work great!
However, I would really like to cut my teeth on some better bash scripts. But, I have to relay on you nice people as the particular knowlege I need is not mentioned on any reference that I found online.
I cannot seem to figure out how to have the script test if:
#1 [ -z $ARG1 ] or
#2 [ $ARG2 != "-u" ] or
#3 [ $ARG2 != "-d" ] then
run the printf.
Basically, the script will test wether the first argument passed is empty, or not one of the intended switches. Then, will run the printf:usage if any of those tests come back true.
I know this is terribly newbie of me. But, any help would be greatly appreciated.
Both work great!
However, I would really like to cut my teeth on some better bash scripts. But, I have to relay on you nice people as the particular knowlege I need is not mentioned on any reference that I found online.
Code:
ARG1=$1
ARG2=$2
echo $ARG1
echo $ARG2
if [ -z $ARG1 ] || [ $ARG1 != "-u" ] || [ $ARG1 != "-d" ]; then
printf "%s\n" "Usage: firewall -u|-d [mins]"
exit 0
#1 [ -z $ARG1 ] or
#2 [ $ARG2 != "-u" ] or
#3 [ $ARG2 != "-d" ] then
run the printf.
Basically, the script will test wether the first argument passed is empty, or not one of the intended switches. Then, will run the printf:usage if any of those tests come back true.
I know this is terribly newbie of me. But, any help would be greatly appreciated.