-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver
More file actions
executable file
·98 lines (86 loc) · 1.24 KB
/
server
File metadata and controls
executable file
·98 lines (86 loc) · 1.24 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
#!/bin/bash
RUNUSER=""
SERVERNAME=""
RUNCOMMAND=""
s_status ()
{
screen -ls | grep --quiet $SERVERNAME
return $?
}
s_start ()
{
if se_status
then
echo "Server is already running please stop this server before making another."
else
echo "Starting $SERVERNAME server."
screen -S $SERVERNAMEServer -dm bash -c "$RUNCOMMAND"
fi
}
s_stop ()
{
if se_status
then
echo "Stopping $SERVERNAME Server."
screen -S $SERVERNAMEServer -X stuff $'\003'
screen -S $SERVERNAMEServer -r
else
echo "Server isn't running."
fi
}
s_restart ()
{
if se_status
then
echo "Restarting $SERVERNAME Server."
s_stop
s_start
else
s_start
fi
}
s_update ()
{
}
s_help ()
{
cat .help
}
if [ "$(whoami)" != "$RUNUSER" ]
then
echo You are logged in as $(whoami) but the server can only be started as the $RUNUSER user. Please log in as this user and run this script again.
exit 1
fi
if [ ! -z "$2" ]
then
help
exit 3
fi
case $1 in
start)
s_start
;;
stop)
s_stop
;;
restart)
s_restart
;;
update)
s_update
;;
status)
if s_status;
then
echo "$SERVERNAMEServer is running."
else
echo "$SERVERNAMEServer is not running."
fi
;;
help)
s_help
;;
*)
s_help
;;
esac