bash:使该脚本允许执行 php 解析器

发布于 2024-11-08 15:30:24 字数 1204 浏览 0 评论 0原文

目前我使用以下脚本启动 Armagetron 服务器

#!/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

这将运行服务器并在 $parser 中应用 php 脚本

但是,我想像这样启动我的服务器:

#!/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

这里唯一的问题是我不知道如何指定 php解析器在服务器上运行(我是一个菜鸟)。我将如何修改第二个脚本以允许这样做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒与心事 2024-11-15 15:30:24

将第一个块中的所有代码放入 srv 脚本中的 while 循环内,即

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

(这看起来正确吗?)

我希望这会有所帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文