-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·64 lines (61 loc) · 1.25 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
ask_restart()
{
echo -n "metBot has stopped. Retry? (y/n): "
read REPLY || exit
while [[ $REPLY != "y" && $REPLY != "n" ]]
do
echo -n "Unknown option \"$REPLY\". Retry? (y/n): "
read REPLY
done
if [ $REPLY == "y" ]
then
if [ -n "$NEWARGS" ]
then
php run.php "${NEWARGS[@]}"
else
php run.php "${@:1}"
fi
else
echo "Bye!"
exit
fi
}
echo "metBot Beta 7"
# PHP for Windows Mingw users
if [ -z "$(which php)" -a -f "/c/php/php" ]
then
PATH=$PATH:/c/php
fi
php run.php "${@:1}"
while :
do
if [ -f ./core/status/restart.bot ]
then
# see if there are new args in the restart
if [ -s ./core/status/restart.bot ]
then
RESTART=`cat ./core/status/restart.bot`
echo Using new arguments \`$RESTART\`
eval "NEWARGS=($RESTART)"
php run.php "${NEWARGS[@]}"
else
echo Restart file empty, using old arguments...
if [ -n "$NEWARGS" ]
then
php run.php "${NEWARGS[@]}"
else
php run.php "${@:1}"
fi
fi
else
if [ -f ./core/status/close.bot ]
then
echo "Bye!"
exit
else # in case PHP crashes, we need to fix the STDIN handle
php -r 'stream_set_blocking(STDIN, true);'
ask_restart
fi
fi
done