xref: /OK3568_Linux_fs/buildroot/package/restorecond/S02restorecond (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3DAEMON=restorecond
4PIDFILE=/var/run/$DAEMON.pid
5
6RESTORECOND_ARGS=""
7
8# shellcheck source=/dev/null
9[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
10
11start()
12{
13	printf 'Starting %s: ' "$DAEMON"
14	start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
15		-- $RESTORECOND_ARGS
16	status=$?
17	if [ "$status" -eq 0 ]; then
18		echo "OK"
19	else
20		echo "FAIL"
21	fi
22	return "$status"
23}
24
25stop()
26{
27	printf 'Stopping %s: ' "$DAEMON"
28	start-stop-daemon -K -q -p $PIDFILE -R TERM/30/KILL/5 -n $DAEMON
29	status=$?
30	if [ "$status" -eq 0 ]; then
31		rm -f "$PIDFILE"
32		echo "OK"
33	else
34		echo "FAIL"
35	fi
36	return "$status"
37}
38
39restart()
40{
41	stop
42	sleep 1
43	start
44}
45
46case "$1" in
47	start|stop|restart)
48		"$1";;
49	reload)
50		restart;;
51	*)
52		echo $"Usage: $0 {start|stop|restart|reload}"
53		exit 1
54esac
55