Hallo.
Ich bin sehr neu bei Linux und dem ganzen Zeug.
Ich hab mir das startscript angeschaut und dachte sieht doch leicht aus oO, kann ich auch lol.
Naja es geht in meinem startscript etwa nicht mal eine Zeile :<
Ich habe 3 verschiedene Server. Am Anfang soll der Server ausgewählt werden und dann schauen ob er läuft, aber das mit dem auswählen funktioniert schonmal nicht.
Normalerweise poste ich nichts in Foren, doch ich komm echt nicht weiter x.x;
Hier ist mein Startscript
Spoiler anzeigen
Bash
#!/bin/sh
PHP=/usr/bin/php5
CFGDIR=config
LOGDIR=log
PARAMS=""
ServerSelect()
{
echo "========================"
echo "Enter Servernumber: (1,2,3)"
read SERVERNR
if [`$SERVERNR`] == 1]
then Server1
elif [`$SERVERNR` == 2]
then Server2
elif [`$SERVERNR` == 2]
then Server3
else echo "Invalid Server chosen"
ServerSelect
fi
}
Server1()
{
MAM=MAM_1
SERVERNAME=serverx1
SERVERSTARTPARAMS="blablabla"
PW="xxx"
DIRA=/root/Server/adminmod1
DIRB=/root/Server/1Cod4
serverstatus
}
Server2()
{
MAM=none
SERVERNAME=serverx2
SERVERSTARTPARAMS="blablabla"
PW="xxxx"
DIRA=none
DIRB=/root/Server/1Cod4
serverstatus
}
Server3()
{
MAM=MAM_2
SERVERNAME=serverx3
SERVERSTARTPARAMS="blablabla"
PW="xxx"
DIRA=/root/Server/adminmod2
DIRB=/root/Server/2Cod4
serverstatus
}
serverstatus()
{
if [ps ax | grep -v grep | grep $SERVERNAME >/dev/null]
then
echo $SERVERNAME is running.
RUNB=1
else
echo $SERVERNAME is not running.
RUNB=0
fi
echo "-"
if [$MAM == "none"]
then echo "MAM not installed for this Server"
RUNA=x
else if [[`screen -ls |grep $MAM`]]
then echo $MAM1 is running
RUNA=1
else echo $MAM1 is not running or screen bug. Yippie
RUNA=0
fi
fi
choices
}
choices()
{
echo "========================"
echo "What do you want to do:"
echo "serverstatus,startserver,stopserver,startmam,stopmam or exit?"
read ANSWER
if [$ANSWER == serverstatus]
then serverstatus
elif [$ANSWER == startserver]
then startserver
elif [$ANSWER == stopserver]
then stopserver
elif [$ANSWER == startmam]
then startmam
elif [$ANSWER == stopmam]
then stopmam
elif [$ANSWER == exit]
then exitchoices
else echo "wrong answer .________.;"
choices
fi
}
startserver()
{
if [$RUNB == 1]
then echo "Error:$SERVERNAME is already running"
echo "Want to stop $SERVERNAME? [y/n]"
read answ
if [[answ == y] || [answ == Y] || [answ == yes] || [answ == Yes]]
then stopserver
elif [[answ == n] || [answ == N] || [answ == no] || [answ == No]]
then choices
else echo "non correct answer"
choices
fi
elif [$RUNB == 0]
then cd $DIRB
./cod4_lnxded +$SERVERNAME +set log 0 +set rcon_password $PW +set log1 $SERVERSTARTPARAMS
echo "starting $SERVERNAME"
else echo "FK. I messed up :/"
fi
choices
}
stopserver()
{
if [$RUNB == 0]
then echo "Error:$SERVERNAME is not running"
echo "Want to start $SERVERNAME? [y/n]"
read answ
if [[answ == y] || [answ == Y] || [answ == yes] || [answ == Yes]]
then startserver
elif [[answ == n] || [answ == N] || [answ == no] || [answ == No]]
then choices
else echo "non correct answer"
choices
fi
elif [$RUNB == 1]
then kill `screen -ls |grep $SERVERNAME |awk -F . '{print $1}'|awk '{print $1}'`
echo "$SERVERNAME was stoped"
else echo "FK. I messed up :/"
fi
choices
}
startmam()
{
if [$RUNA == 1]
then echo "Error:$MAM is already running"
echo "Want to stop $MAM? [y/n]"
read answ
if [[answ == y] || [answ == Y] || [answ == yes] || [answ == Yes]]
then stopmam
elif [[answ == n] || [answ == N] || [answ == no] || [answ == No]]
then choices
else echo "non correct answer"
choices
fi
elif [$RUNA == 0]
then cd $DIRA
screen -dmS $MAM $PHP $PHPPARAMS daemon.php -- -configdir "$CFGDIR" -logdir "$LOGDIR" $PARAMS
echo "starting $MAM"
sleep 10
choices
elif [$RUNA == x]
then echo "MAM not installed for this Server"
else echo "FK. I messed up again :/"
fi
choices
}
stopmam()
{
if [$RUNA == 0]
then echo "Error:$MAM is not running"
echo "Want to start $MAM? [y/n]"
read answ
if [[answ == y] || [answ == Y] || [answ == yes] || [answ == Yes]]
then startmam
elif [[answ == n] || [answ == N] || [answ == no] || [answ == No]]
then choices
else echo "non correct answer"
choices
fi
elif [$RUNA == 1]
then kill `screen -ls |grep $MAM |awk -F . '{print $1}'|awk '{print $1}'`
echo "$MAM was stoped"
sleep 3
choices
elif [$RUNA == x]
thenecho "MAM not installed for this Server"
choices
else echo "FK. I messed up again :/"
fi
choices
}
exitchoices()
{ ServerSelect }
Alles anzeigen
Error is immer: Cod4starters.sh: 203: Syntax error: end of file unexpected (expecting "}")
Hoffentlich kann mir wer helfen :x