forked from valgilbert/pacCoinTipBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoxdCoinDiscordTipBot
executable file
·94 lines (78 loc) · 2.4 KB
/
foxdCoinDiscordTipBot
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
#! /bin/sh
### BEGIN INIT INFO
# Provides: foxdCoinDiscordTipBot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: foxdCoinDiscordTipBot server
### END INIT INFO
set -e
# /etc/init.d/foxdCoinDiscordTipBot: start and stop the foxdCoinDiscordTipBot daemon
test -x /opt/foxdCoinTipBot/foxdCoinDiscordTipBot.py || exit 0
umask 022
. /lib/lsb/init-functions
if [ -n "$2" ]; then
BOT_OPTS="$BOT_OPTS $2"
fi
# Are we running from init?
run_by_init() {
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}
check_for_upstart() {
if init_is_upstart; then
exit $1
fi
}
check_dev_null() {
if [ ! -c /dev/null ]; then
if [ "$1" = log_end_msg ]; then
log_end_msg 1 || true
fi
if ! run_by_init; then
log_action_msg "/dev/null is not a character device!" || true
fi
exit 1
fi
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
check_for_upstart 1
check_dev_null
log_daemon_msg "Starting foxdCoinDiscordTipBot server" "FoxdCoin" || true
if start-stop-daemon --start --background --quiet --oknodo -u root -p root -m --pidfile /var/run/foxdCoinDiscordTipBot.pid --exec /usr/bin/python3 /opt/foxdCoinTipBot/pacCoinDiscordTipBot.py -- $BOT_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
check_for_upstart 0
log_daemon_msg "Stopping foxdCoinDiscordTipBot server" "FoxdCoin" || true
if start-stop-daemon --stop --quiet --retry 30 --pidfile /var/run/foxdCoinDiscordTipBot.pid; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart)
check_for_upstart 1
log_daemon_msg "Restarting foxdCoinDiscordTipBot server" "FoxdCoin" || true
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/foxdCoinDiscordTipBot.pid
check_dev_null log_end_msg
if start-stop-daemon --start --background --quiet --oknodo -u root -p root -m --pidfile /var/run/foxdCoinDiscordTipBot.pid --exec /usr/bin/python3 /opt/foxdCoinTipBot/foxdCoinDiscordTipBot.py -- $BOT_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
check_for_upstart 1
status_of_proc -p /var/run/foxdCoinDiscordTipBot.pid /opt/foxdCoinTipBot/pacCoinDiscordTipBot.py foxdCoinDiscordTipBot && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/foxdCoinDiscordTipBot {start|stop|restart|status}" || true
exit 1
esac
exit 0