checking for dir then moving on
i have now wrote this my first script for a mate who is setting up game servers and it works
but i would like to use the lndir command so what i would like to try and do is
when they try and install a game it checks to see if the base dir is there and if it is it moves on to set up the user dir with the crosslink dirs and other files needed for the server to run
but if it is not there then it unpaks that dir first then moves on to next step of setting up the users dir with linked files and there own files for running the server
any ideas ion how i coul do this
here the the existing script long i know but it works
#!/bin/bash
# Server INstall
clear
echo " Install One Of The Following"
echo " ------- --- -- --- ---------"
echo "Choose one of the following by inputing number then hit return"
echo
echo " 1: Medal of Honour Allied Assault"
echo " 2: Medal of Honour Spearhead"
echo " 3: Call of Duty"
echo " 4: Counterstrike"
echo " 5: Teamspeak"
echo " 6: Ventrillo"
echo
echo " Press enter to exit"
echo
read person
case "$person" in
"1" | "1" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvf mohaa.tar
mv server1 $folder
chmod 755 $folder/mohaa_loop.sh
cd $folder
clear
echo "Setting up mohaa_loop file"
echo "------- -- ---------- ----"
echo
echo "Please enter ip then press enter"
read first
sed s/address/$first/ mohaa_loop.sh > new.sh
echo
echo "Now enter port number followed by enter"
read richard
sed s/fifth/$richard/ new.sh > new4.sh
echo
echo "Nearly done just size of server now and enter"
read server
sed s/sixth/$server/ new4.sh > new5.sh
clear
cd /home/archive/$folder/main
echo "Setting up server.cfg"
echo "------- -- ----------"
echo
echo "Please give server name "
read name
sed "s/clan/$name/g" server.cfg > cfg.cfg
echo
rm server.cfg
echo "Please set an rcon password"
read rcon
sed s/leader/$rcon/g cfg.cfg > cfg1.cfg
echo
rm cfg.cfg
echo "And finally cfg player slots"
read slots
sed s/slots/$slots/g cfg1.cfg > server.cfg
rm cfg1.cfg
clear
echo "Ok now for the in game messages"
echo
echo "First message"
echo "if no message is need just hit enter"
read msg1
sed "s/msg1/$msg1/g" server.cfg > cfg.cfg
rm server.cfg
echo "Second message"
echo "if no message is need just hit enter"
read msg2
sed "s/msg2/$msg2/g" cfg.cfg > cfg1.cfg
rm cfg.cfg
echo "Third message"
echo "if no message is need just hit enter"
read msg3
sed "s/msg3/$msg3/g" cfg1.cfg > cfg2.cfg
rm cfg1.cfg
echo "Forth message"
echo "if no message is need just hit enter"
read msg4
sed "s/msg4/$msg4/g" cfg2.cfg > cfg3.cfg
rm cfg2.cfg
echo "Fifth message"
echo "if no message is need just hit enter"
read msg5
sed "s/msg5/$msg5/g" cfg3.cfg > cfg4.cfg
rm cfg3.cfg
echo "Sixth message"
echo "if no message is need just hit enter"
read msg6
sed "s/msg6/$msg6/g" cfg4.cfg > cfg5.cfg
rm cfg4.cfg
echo "Seventh message"
echo "if no message is need just hit enter"
read msg7
sed "s/msg7/$msg7/g" cfg5.cfg > cfg6.cfg
rm cfg5.cfg
echo "Eighth message"
echo "if no message is need just hit enter"
read msg8
sed "s/msg8/$msg8/g" cfg6.cfg > server.cfg
rm cfg6.cfg
sed s/folder/$folder/g start.sh > $folder
rm start.sh
mv $folder $folder.sh
chmod 755 $folder.sh
mv $folder.sh /home/
cd /home/archive/$folder
rm mohaa_loop.sh
rm new.sh
rm new4.sh
mv new5.sh mohaa_loop.sh
cd /home/archive
chmod 755 $folder/mohaa_loop.sh
mv $folder /home
cd /home/$folder
clear
echo "Game now installed to $folder"
echo
echo "Server IP =$first"
echo "Port =$richard"
echo "Startscript located here /home/$folder.sh"
echo
echo "All Thats left to do is setup ftp now"
echo
echo "This Script was brought to you by an old friend"
echo
echo
;;
* )
# Default option.
# Empty input (hitting RETURN) fits here, too.
echo
echo "Changed your mind then."
;;
esac
echo
exit 0
i have taken out 2 - 6 as not needed for this question as if i get an answer i can adopt it
i would also like to be able to set up ftp accounts via the useradd command but this does not work unless im logged in as root is there away of doing this. i know there is the su cmd and sudo but how would i implement this into the script
thanks might be asking to much here but i know you linux junkies just like me are getting the bug im hook on linux at mo
thanks in advance
Last edited by rharris72; 11-21-2005 at 06:06 AM.
|