My Perl Script
Posted: Tue Feb 24, 2004 1:04 am
I was bored and decided to try and make a User Friendly Script that would Emerge EBuilds then either Shutdown or Reboot after.
The Script works but is real nasty, Any one that can help.
The main problem is with the Checking, I could not get "or" statements to work.
btw, I named it SMERGE for Shutdown Emerge
The Script works but is real nasty, Any one that can help.
The main problem is with the Checking, I could not get "or" statements to work.
btw, I named it SMERGE for Shutdown Emerge
Code: Select all
#!/bin/bash
#Emerge Runner with Shutdown or Reboot After
#My first ever BASH Script for Linux ;-)
echo -e "Please Enter an E-Build to Emerge"
read EBuild
if [ $EBuild == "" ]; then
echo -e "Please Enter an E-Build"
sleep 4
exit 1
fi
OpClose(){
echo -e "Please Choose an Option"
sleep 4
exit 1
}
clear
echo -e "Please choose an Option to Execute after emerge"
echo -e "s or S = Shutdown"
echo -e "r or R = Reboot"
read Option
#Real Nasty here, Could not get "Or" to work ;-(
export Valid="FALSE"
if [ $Option == "r" ]; then
export Valid="TRUE"
fi
if [ $Option == "R" ]; then
export Valid="TRUE"
fi
if [ $Option == "s" ]; then
export Valid="TRUE"
fi
if [ $Option == "S" ]; then
export Valid="TRUE"
fi
if [ $Valid = "FALSE" ]; then
OpClose
fi
ConClose(){
echo -e "Please use Y for Yes and N for No"
sleep 4
exit 1
}
clear
echo -e "Confirm Emerge and Options"
echo -e "E-Build: $EBuild"
echo -e "Option: $Option"
echo -e "Continue Y or N"
read Confirm
export Valid="FALSE"
if [ $Confirm == "" ]; then
export Valid="TRUE"
fi
if [ $Confirm != "Y" ]; then
export Valid="TRUE"
fi
if [ $Confirm != "y" ]; then
export Valid="TRUE"
fi
if [ $Confirm != "N" ]; then
export Valid="TRUE"
fi
if [ $Confirm != "n" ]; then
export Valid="TRUE"
fi
if [ $Valid = "FALSE" ]; then
ConClose
fi
export Yes="FALSE"
if [ $Confirm == "Y" ]; then
export Yes="TRUE"
fi
if [ $Confirm == "y" ]; then
export Yes="TRUE"
fi
if [ $Yes == "TRUE" ]; then
echo -e "SMERGING, Please Stand By"
sleep 2
clear
emerge $EBuild
export Op="R"
if [ $Option == "r" ]; then
export Op="R"
fi
if [ $Option == "R" ]; then
export Op="R"
fi
if [ $Op == "R" ]; then
reboot
exit 1
else
halt
exit 1
fi
else
exit 1
fi