File: motion.init-RH.in

package info (click to toggle)
motion 3.2.3-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,612 kB
  • ctags: 1,330
  • sloc: ansic: 11,669; sh: 2,906; makefile: 198
file content (84 lines) | stat: -rw-r--r-- 1,424 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
#
# Startup script for the Motion Detection System 
#
# chkconfig: - 85 15
# description: Motion Detection System.  It is used to detect \
#              movement based on compare images.
# processname: motion 
# pidfile: /var/run/motion.pid
# config: /etc/motion.conf

# Source function library.
. /etc/rc.d/init.d/functions



motion=${MOTION-@BIN_PATH@/motion}
prog=motion
PIDFILE=/var/run/motion.pid
RETVAL=0


start() {
	echo -n $"Starting $prog: "
	daemon $motion 
	RETVAL=$?
	echo `ps axf | grep -v grep | grep  $motion | head -n1 | awk '{print $1}'` > $PIDFILE
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/motion
	return $RETVAL
}
stop() {
	echo -n $"Stopping $prog: "
	killproc $motion
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/motion /var/run/motion.pid
}
stopsafe() {
	echo -n $"Stopping $prog: ( for restarting ) "
	killproc $motion
	RETVAL=$?
	sleep 10s
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/motion /var/run/motion.pid
}
reload() {
	echo -n $"Reloading $prog: "
	killproc $motion -HUP
	RETVAL=$?
	echo
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status $motion
		RETVAL=$?
		;;
	restart)
		stopsafe
		start
		;;
	condrestart)
		if [ -f /var/run/motion.pid ] ; then
			stop
			start
		fi
		;;
	reload)
		reload
		;;
	*)
		echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}"
		exit 1
esac

exit $RETVAL