-
Notifications
You must be signed in to change notification settings - Fork 22
/
xtreamcodes
83 lines (73 loc) · 2.53 KB
/
xtreamcodes
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
#!/bin/sh
SCRIPT=/home/xtreamcodes/iptv_xtream_codes
USER=$(whoami)
if [ $USER != "root" ]; then
echo "Please run as root!"
exit 0
fi
start() {
pids=$(pgrep -u xtreamcodes nginx | wc -l)
if [ $pids != 0 ]; then
echo 'XtreamCodes is already running'
return 1
fi
echo 'Starting XtreamCodes...'
sudo chown -R xtreamcodes:xtreamcodes /sys/class/net
sudo chown -R xtreamcodes:xtreamcodes $SCRIPT/streams
sudo chown -R xtreamcodes:xtreamcodes $SCRIPT/tmp
sudo -u xtreamcodes $SCRIPT/nginx/sbin/nginx >/dev/null 2>/dev/null
sudo -u xtreamcodes $SCRIPT/nginx_rtmp/sbin/nginx_rtmp >/dev/null 2>/dev/null
/sbin/start-stop-daemon --start --quiet --pidfile /home/xtreamcodes/iptv_xtream_codes/php/VaiIb8.pid --exec /home/xtreamcodes/iptv_xtream_codes/php/sbin/php-fpm -- --daemonize --fpm-config /home/xtreamcodes/iptv_xtream_codes/php/etc/VaiIb8.conf
/sbin/start-stop-daemon --start --quiet --pidfile /home/xtreamcodes/iptv_xtream_codes/php/JdlJXm.pid --exec /home/xtreamcodes/iptv_xtream_codes/php/sbin/php-fpm -- --daemonize --fpm-config /home/xtreamcodes/iptv_xtream_codes/php/etc/JdlJXm.conf
/sbin/start-stop-daemon --start --quiet --pidfile /home/xtreamcodes/iptv_xtream_codes/php/CWcfSP.pid --exec /home/xtreamcodes/iptv_xtream_codes/php/sbin/php-fpm -- --daemonize --fpm-config /home/xtreamcodes/iptv_xtream_codes/php/etc/CWcfSP.conf
rm -f $SCRIPT/php/*.pid
sudo -u xtreamcodes $SCRIPT/php/bin/php $SCRIPT/crons/setup_cache.php
sudo -u xtreamcodes $SCRIPT/php/bin/php $SCRIPT/tools/signal_receiver.php >/dev/null 2>/dev/null &
sudo -u xtreamcodes $SCRIPT/php/bin/php $SCRIPT/tools/pipe_reader.php >/dev/null 2>/dev/null &
echo 'Running in foreground...'
sleep infinity
}
stop() {
pids=$(pgrep -u xtreamcodes nginx | wc -l)
if [ $pids = 0 ]; then
echo 'XtreamCodes is not running'
return 1
fi
echo 'Stopping XtreamCodes...'
sudo killall -u xtreamcodes
sleep 1
sudo killall -u xtreamcodes
sleep 1
sudo killall -u xtreamcodes
}
restart() {
ps -U xtreamcodes | egrep -v "ffmpeg|PID" | awk '{print $1}' | xargs kill -9
start
}
reload() {
pids=$(pgrep -u xtreamcodes nginx | wc -l)
if [ $pids = 0 ]; then
echo 'XtreamCodes is not running'
return 1
fi
echo 'Reloading XtreamCodes...'
sudo -u xtreamcodes $SCRIPT/nginx/sbin/nginx -s reload
sudo -u xtreamcodes $SCRIPT/nginx_rtmp/sbin/nginx_rtmp -s reload
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
esac
exit 0