bash: Make this script allow execution of php parser
Currently I start an Armagetron Server with the following开发者_开发百科 script
#!/bin/sh
tron="/home/duke/aa/bin/armagetronad-dedicated"
var="/home/duke/aa/servers/demo/var/"
log="${var}console_log.txt"
userconfigdir="/home/duke/aa/servers/demo/var/customize/config/"
parser="/home/duke/aa/scripts/parser.php"
ladderlog="${var}ladderlog.txt"
cmds="${var}cmd.txt"
tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log
This runs the server and applys the php script in $parser
However, I want to start my server like this:
#!/bin/bash
screen -S $1 -X quit # avoiding to run the same server twice
screen -dmS $1 /home/duke/aa/scripts/srv $1
srv:
screen -S $1 -X logtstamp on
screen -S $1 -X logfile /home/duke/aa/servers/$1/logs
screen -S $1 -X log on
while true; do # start a loop to allow server restart if it crashes
/home/duke/aa/bin/armagetronad-dedicated --vardir /home/duke/aa/servers/$1/var --userdatadir /home/duke/aa/servers/$1/var/customize #run the server
echo "###Server has crashed. Ctrl-C to cancel reboot...###"
sleep 5
done # end the loop
the only problem here is I don't know how to specify a php parser to run on the server (im a noob). How would i modify the second scripts to allow this?
put all the code in your first block inside the while loop in the srv script, i.e.
srv:
#!/bin/bash
tron="/home/duke/aa/bin/armagetronad-dedicated"
var="/home/duke/aa/servers/demo/var/"
log="${var}console_log.txt"
userconfigdir="/home/duke/aa/servers/demo/var/customize/config/"
parser="/home/duke/aa/scripts/parser.php"
ladderlog="${var}ladderlog.txt"
cmds="${var}cmd.txt"
screen -S $1 -X logtstamp on
screen -S $1 -X logfile /home/duke/aa/servers/$1/logs
screen -S $1 -X log on
while true; do # start a loop to allow server restart if it crashes
tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log
# /home/duke/aa/bin/armagetronad-dedicated --vardir /home/duke/aa/servers/$1/var --userdatadir /home/duke/aa/servers/$1/var/customize #run the server
echo "###Server has crashed. Ctrl-C to cancel reboot...###"
sleep 5
done # end the loop
(Does this look right?)
I hope this helps.
精彩评论