-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnc.sh
executable file
·119 lines (106 loc) · 3.69 KB
/
dnc.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
if [ $(ps -ejH w | grep dnc.sh | grep -v grep | wc -l ) -eq 3 ]; then
sleep 1
echo "
___ ___ ___ ___ ___ ___ ___
_____ /\ \ /\ \ /\ \ /\__\ /\__\ /\ \ /\ \
/::\ \ /::\ \ \:\ \ /::\ \ ___ /:/ / /:/ _/_ /::\ \ \:\ \
/:/\:\ \ /:/\:\ \ \:\ \ /:/\:\ \ /\__\ /:/ / /:/ /\__\ /:/\:\ \ \:\ \
/:/ \:\__\ /:/ \:\ \ _____\:\ \ /:/ \:\ \ /:/ / /:/ / ___ ___ ___ /:/ /:/ _/_ /:/ /::\ \ _____\:\ \
/:/__/ \:|__| /:/__/ \:\__\ /::::::::\__\ /:/__/ \:\__\ /:/__/ /:/__/ /\__\ /\ \ /\__\ /:/_/:/ /\__\ /:/_/:/\:\__\ /::::::::\__\
\:\ \ /:/ / \:\ \ /:/ / \:\~~\~~\/__/ \:\ \ /:/ / /::\ \ \:\ \ /:/ / \:\ \ /:/ / \:\/:/ /:/ / \:\/:/ \/__/ \:\~~\~~\/__/
\:\ /:/ / \:\ /:/ / \:\ \ \:\ /:/ / /:/\:\ \ \:\ /:/ / \:\ /:/ / \::/_/:/ / \::/__/ \:\ \
\:\/:/ / \:\/:/ / \:\ \ \:\/:/ / \/__\:\ \ \:\/:/ / \:\/:/ / \:\/:/ / \:\ \ \:\ \
\::/ / \::/ / \:\__\ \::/ / \:\__\ \::/ / \::/ / \::/ / \:\__\ \:\__\
\/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/
"
else
echo "An instance is already running .. "$(ps -ejH w | grep dnc.sh | grep -v grep | wc -l ) > /tmp/dnc_l
echo "EXIT because already running"
exit 0
fi
running=1
DIRECT_INOUT=0
AUTO_START=1
## Save last log and clear them
mkdir /dnc/logs/old
rm -rf /dnc/logs/old/*
cp -a /dnc/logs/* /dnc/logs/old
rm /dnc/logs/*
##
# NAMED ARGUMENTS
while getopts "ou" opt; do
case "$opt" in
o) DIRECT_INOUT=1
;;
u) AUTO_START=0
;;
esac
done
# Wait for other process to start on boot
if ((AUTO_START)); then
echo "= DNC Loading"
sleep 5
fi
quit()
{
running=0
}
kill_zombies()
{
echo "= DNC Clear"
#/dnc/bash/kill.sh
#pkill python2 # NO ! It will break NetCtl Watchdog
#Free sockets
fuser -k 1783/udp
fuser -k 1782/udp
fuser -k 1781/udp
fuser -k 2782/udp
fuser -k 2781/udp
#Remove others
pkill vlc
pkill hplayer-vlc
pkill hardware6
pkill hardware7
}
trap quit SIGINT
while (( running )); do
kill_zombies
# Maintenance
echo ""
echo "= DNC Update"
/dnc/update.sh | sed -e 's/^/ /'
cd /dnc
# MAIN
echo ""
echo "= DNC Start"
if ((DIRECT_INOUT)); then
nice -n -20 ./player/Python/main.py
else
# MAIN PROGRAM
echo "."; sleep 1; echo "."; sleep 1; echo "."
mkdir -p /tmp/dnc
touch /tmp/dnc/main.log
nice -n -20 ./player/Python/main.py &> /tmp/dnc/main.log
fi
exitcode=$?
if [ $exitcode -eq 0 ]; then
quit
elif [ $exitcode -eq 2 ]; then
sleep 7 # Time for threads and others things to quit properly
quit
poweroff
elif [ $exitcode -eq 3 ]; then
sleep 7 # Time for threads and others things to quit properly
quit
reboot
fi
echo "ShowPlayer exited $exitcode"
if (( running )); then
echo "Respawning.."
echo ""
echo ""
sleep 1
fi
done
kill_zombies