forked from pchtrakt/pchtrakt
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdaemon.sh
More file actions
executable file
·87 lines (77 loc) · 1.72 KB
/
Copy pathdaemon.sh
File metadata and controls
executable file
·87 lines (77 loc) · 1.72 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
#!/bin/sh
#Set Paths
PATH=$PATH:/bin:/usr/local/bin:/share/Apps/local/bin:/share/Apps/local/libexec/git-core:/nmt/apps/bin;export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:opt/syb/app/lib:/nmt/app/lib:/opt/syb/sigma/lib:/usr/local/bin:/share/Apps/local/lib;export LD_LIBRARY_PATH
MANPATH=$MANPATH:/usr/local/share/man:/share/Apps/local/share/man;export MANPATH
force_pchtrakt()
{
# install coreutils
if [ -f /share/Apps/local/bin/tr ] ; then
echo "Required dependency, coreutils is installed."
else
opkg install coreutils -force-depends -force-overwrite
fi
chmod 777 /share/Apps/pchtrakt
cd /share/Apps/pchtrakt
git reset --hard
git pull
sleep 5
git reset
}
force_all()
{
opkg update
opkg install python2.7 -force-depends -force-overwrite
opkg install git -force-depends -force-overwrite
cd /share/Apps/pchtrakt/
}
start_pchtrakt()
{
# start pchtrakt
ps | grep "[p]chtrakt.py --daemon" > /dev/null
if [ $? -ne 0 ];
then
echo "pchtrakt.py is not running, Starting processes"
cd /share/Apps/pchtrakt
python2.7 pchtrakt.py --daemon
cd
fi
}
stop_pchtrakt()
{
# Stop pchtrakt
if [ -n "`ps | grep "pchtrakt" | grep -v "grep"`" ]; then
kill -9 `ps |grep pchtrakt.py | grep -v grep |head -n 1 | awk '{print $1}'` >/dev/null 2>/dev/null
sleep 2
fi
}
#Main
case "$1" in
start)
start_pchtrakt;
;;
stop)
stop_pchtrakt;
exit
;;
restart)
stop_pchtrakt;
sleep 2
start_pchtrakt;
;;
update)
stop_pchtrakt;
sleep 2
force_pchtrakt;
sleep 2
start_pchtrakt;
;;
forceall)
stop_pchtrakt;
sleep 2
force_all;
force_pchtrakt;
sleep 2
start_pchtrakt;
;;
esac