Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-21-2005, 03:56 AM   #1
Registered: Nov 2005
Posts: 32

Rep: Reputation: 15
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


# Server INstall


echo " Install One Of The Following"
echo " ------- --- -- --- ---------"
echo "Choose one of the following by inputing number then hit return"
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 " Press enter to exit"

read person

case "$person" in

"1" | "1" )
echo "please type a folder to install to and hit return"
read folder
tar -xvvf mohaa.tar
mv server1 $folder
chmod 755 $folder/
cd $folder
echo "Setting up mohaa_loop file"
echo "------- -- ---------- ----"
echo "Please enter ip then press enter"
read first
sed s/address/$first/ >
echo "Now enter port number followed by enter"
read richard
sed s/fifth/$richard/ >
echo "Nearly done just size of server now and enter"
read server
sed s/sixth/$server/ >


cd /home/archive/$folder/main

echo "Setting up server.cfg"
echo "------- -- ----------"
echo "Please give server name "
read name
sed "s/clan/$name/g" server.cfg > cfg.cfg
rm server.cfg
echo "Please set an rcon password"
read rcon
sed s/leader/$rcon/g cfg.cfg > cfg1.cfg
rm cfg.cfg
echo "And finally cfg player slots"
read slots
sed s/slots/$slots/g cfg1.cfg > server.cfg
rm cfg1.cfg


echo "Ok now for the in game messages"
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 > $folder
mv $folder $
chmod 755 $
mv $ /home/
cd /home/archive/$folder

cd /home/archive
chmod 755 $folder/
mv $folder /home
cd /home/$folder

echo "Game now installed to $folder"
echo "Server IP =$first"
echo "Port =$richard"
echo "Startscript located here /home/$"
echo "All Thats left to do is setup ftp now"
echo "This Script was brought to you by an old friend"

* )
# Default option.
# Empty input (hitting RETURN) fits here, too.
echo "Changed your mind then."



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.
Old 11-22-2005, 02:05 PM   #2
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Checking for a directory:

if [[ -d $dir ]]; then
        ... do whatever ....
Old 11-22-2005, 02:31 PM   #3
Registered: Nov 2005
Posts: 32

Original Poster
Rep: Reputation: 15
ok thanks


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
moving a file from a cd-rom to root dir stupidloser Linux - Newbie 4 08-06-2004 08:04 AM
copying/moving stalls when moving a lot of data to a usb stick =X= Linux - Hardware 10 07-30-2004 05:29 AM
howto make a dir shared that is not in my home dir Schmurff Linux - Newbie 2 06-19-2004 07:54 PM
krecipes and ./configure -with-qt-dir=DIR disco rugby Linux - Software 4 06-13-2004 09:06 PM
checking for X... no cmd Linux - Newbie 3 02-22-2004 04:18 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration