-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiNotify_
More file actions
114 lines (106 loc) · 2.12 KB
/
iNotify_
File metadata and controls
114 lines (106 loc) · 2.12 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
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
#!/bin/sh
#
# iNotiy Startup script for the Linux iNotify Agent
#
# chkconfig: 5 99 01
# description: Linux iNotify Agent is a event monitor for file/directory.
#
# processname: iNotify
# config: SUSTITUIRconfig
# pidfile: SUSTITUIRpid
# logfile: SUSTITUIRlogfile
#
iNotify=SUSTITUCIONinstallpath
prog="iNotifyd"
config=SUSTITUIRconfig
user=SUSTITUIRuser
SUDO=/usr/bin/sudo
path=SUSTITUCIONpath
pidFile=`grep pidpath ${config} | awk -F= '{ printf $2 }' 2>/dev/null`
# Source function library.
. /etc/init.d/functions
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
start() {
echo -n $"Starting $prog: "
if [ ! -f $pidFile ]; then
if [ -f /sbin/runuser ]
then
runuser -l $user -c "${SUDO} ${iNotify} -c ${config} &"
RETVAL=$?
else
su - $user -c "${SUDO} ${iNotify} -c ${config} &"
RETVAL=$?
fi
chown -R $user $path
if [ $RETVAL -eq 0 ] ; then
success
else
failure
fi
echo
else
pid=`cat ${pidFile} 2>/dev/null`
ps -p $pid > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "${prog} is running."
else
rm $pidFile > /dev/null 2>&1
start
fi
fi
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
if [ -f $pidFile ]; then
if [ -f /sbin/runuser ]; then
runuser -l $user -c "${SUDO} ${iNotify} -k ${config}"
RETVAL=$?
else
su - $user -c "${SUDO} ${iNotify} -k ${config}"
RETVAL=$?
fi
if [ $RETVAL -eq 0 ] ; then
success
rm $pidFile > /dev/null 2>&1
else
rm $pidFile > /dev/null 2>&1
failure
fi
else
failure
fi
echo
return $RETVAL
}
status() {
ps -p $pidFile > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "${prog} is running."
else
echo "${prog} is not running."
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart}"
RETVAL=2
esac
exit $RETVAL