-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.sh
More file actions
73 lines (66 loc) · 975 Bytes
/
app.sh
File metadata and controls
73 lines (66 loc) · 975 Bytes
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
#!/bin/bash
app_check() {
if $(screen -ls | grep -q "$APP_NAME"); then
return 1
else
return 0
fi
}
app_open() {
app_check
if [ $? -eq 1 ]; then
screen -r "$APP_NAME"
else
printf "$APP_NAME is not running\n"
fi
}
app_stop() {
app_check
if [ $? -eq 1 ]; then
printf "stopping $APP_NAME\n"
screen -S "$APP_NAME" -X quit
else
printf "$APP_NAME is not running\n"
fi
}
app_start() {
app_check
if [ $? -eq 1 ]; then
printf "$APP_NAME is already running\n"
else
printf "starting $APP_NAME\n"
screen -d -m -S "$APP_NAME" $CMD
fi
}
app_status() {
app_check
if [ $? -eq 1 ]; then
printf "started\n"
else
printf "stopped\n"
fi
}
main() {
local param=$1
case $param in
start)
app_start
;;
status)
app_status
;;
open)
app_open
;;
stop)
app_stop
;;
restart)
app_stop
sleep 1
app_start
;;
*)
;;
esac
}