-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogicmooServerLoop.sh
executable file
·70 lines (56 loc) · 1.49 KB
/
LogicmooServerLoop.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
65
66
67
68
69
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo ""
echo -e "\e[1;31mERROR This script must be run as root. \e[0m"
echo ""
return 1 2>/dev/null
exit 1
fi
GREEN='\033[0;32m'
NC='\033[0m' # No Color
function green {
printf "${GREEN}$@${NC}\n"
}
function red {
printf "${RED}$@${NC}\n"
}
DIR0="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# $DIR0/StartLogicmoo.sh
COUNTER=0
while [ 0 -lt 4 ]
do
let COUNTER+=1
export SCREEN_CMD="sudo -u prologmud_server -- screen"
if pgrep -x "screen" > /dev/nulli="0"
then
if [ "$needs_message_update" != "0" ]; then
echo "Screen Already Running"
needs_message_update="0"
fi
else
echo "Screen not running"
$SCREEN_CMD -mdS "LogicmooServer"
sleep 2
$SCREEN_CMD -S LogicmooServer -p0 -X stuff "$DIR0/StartLogicmoo.sh\r"
sleep 2
echo "Screen Started"
if pgrep -f "StartLogicmoo" > /dev/nulli="0"
then
if [ "$needs_message_update" != "0" ]; then
echo "Looks like StartLogicmoo is running!"
needs_message_update="0"
fi
else
echo "Starting StartLogicmoo"
needs_message_update="1"
$SCREEN_CMD -S LogicmooServer -p0 -X stuff "$DIR0/StartLogicmoo.sh\r"
sleep 2
fi
fi
if [ $COUNTER -gt 30 ]; then
echo "MAYBE (IN OTHER TERMINAL): " $(green "docker exec -it logicmoo $SCREEN_CMD -rx LogicmooServer")
echo "OR (Bash IN OTHER TERMINAL): " $(green "docker exec -it logicmoo bash ")
COUNTER=0
fi
sleep 1
done