-
Notifications
You must be signed in to change notification settings - Fork 0
/
oddeye.sh
executable file
·75 lines (64 loc) · 1.65 KB
/
oddeye.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
#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides: oddeye.sh
# Required-Start: $local_fs $network
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop TSD Client
# Description: TSD Client
### END INIT INFO#
SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
PYTHON=`which python3`
cd $SCRIPT_DIR
function getValue {
VALUE=`grep $1 conf/config.ini| awk '{print $NF}'`
if [ `echo $VALUE | grep -o ':'` ] ; then VALUE=`echo $VALUE| cut -d ':' -f2` ; fi
if [ `echo $VALUE | grep -o '='` ] ; then VALUE=`echo $VALUE| cut -d '=' -f2` ; fi
echo $VALUE
}
RUNUSER=`getValue run_user`
TMPDIR=`getValue tmpdir`
PIDFILE=`getValue pid_file`
case "$1" in
start)
if [ ! -d $TMPDIR ];
then
mkdir $TMPDIR
chown $RUNUSER $TMPDIR
chmod 755 $TMPDIR
fi
su $RUNUSER -s /bin/bash -c "$PYTHON oddeye.py start"
;;
systemd)
if [ ! -d $TMPDIR ];
then
mkdir $TMPDIR
chown $RUNUSER $TMPDIR
chmod 755 $TMPDIR
fi
su $RUNUSER -s /bin/bash -c "$PYTHON oddeye.py systemd"
;;
stop)
su $RUNUSER -s /bin/bash -c "$PYTHON oddeye.py stop"
rm -f checks_enabled/*.pyc
;;
restart)
cd $SCRIPT_DIR && ./oddeye.sh stop
while [ -f $PIDFILE ];
do
echo -n '.'
sleep 1
done
echo
cd $SCRIPT_DIR && ./oddeye.sh start
;;
price)
cd lib
su $RUNUSER -s /bin/bash -c "$PYTHON getprice.py"
;;
*)
echo "Usage: `basename $0` start | stop | restart| systemd | price"
;;
esac