-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy.sh
More file actions
103 lines (93 loc) · 1.87 KB
/
proxy.sh
File metadata and controls
103 lines (93 loc) · 1.87 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Source function library
## CentOS/Fedora
if [ -f /etc/rc.d/init.d/functions ]
then
. /etc/rc.d/init.d/functions
fi
## Ubuntu
if [ -f /lib/lsb/init-functions ]
then
. /lib/lsb/init-functions
fi
#---------------------+
# Utilities |
#---------------------+
as_user() {
ME="$(whoami)"
if [ "$ME" == "$USER" ]; then
bash -c "$1"
else
su - "$USER" -c "$1"
fi
}
is_running() {
if ps ax | grep -v grep | grep -iv SCREEN | grep $SERVICE > /dev/null; then
PID=0
PID="$(ps ax | grep -v grep | grep -iv SCREEN | grep $SERVICE | awk '{print $1}')"
return 0
else
return 1
fi
}
mc_start() {
if is_running ; then
echo " * [ERROR] $SCRNNAME was already running [PID $PID]. Not starting..."
else
echo " * $SCRNNAME is not already running, starting up..."
as_user "cd \"$MCPATH\" && screen -c /dev/null -dmS $SCRNNAME $INVOCATION"
sleep 10
if is_running; then
echo " * [OK] $SCRNNAME has started up [PID $PID]"
else
echo " * [ERROR] Could not start $SCRNNAME"
fi
fi
}
mc_stop() {
if is_running; then
while is_running; do
as_user "kill -9 $PID"
sleep 10
done
echo " * $SCRNNAME has shut down"
else
echo " * [ERROR] $SCRNNAME was not running. Cannot stop!"
fi
}
mc_console() {
if is_running; then
as_user "screen -S $SCRNNAME -dr"
else
echo " * [ERROR] $SCRNNAME was not running!"
fi
}
#---------------------+
# Configuration |
#---------------------+
SCRNNAME="BungeeCord"
MCPATH="/home/minecraft/bungee"
SERVICE="$SCRNNAME.jar"
USER="root"
MINRAM="2G"
MAXRAM="4G"
INVOCATION="java -server -Xms$MINRAM -Xmx$MAXRAM -XX:PermSize=128m -jar $SERVICE nogui"
case $1 in
start)
mc_start
;;
stop)
mc_stop
;;
restart)
mc_stop
mc_start
;;
console)
mc_console
;;
*)
echo "Usage: {start|stop|restart|console}"
;;
esac
exit 1