File: restorecond.init

package info (click to toggle)
policycoreutils 2.0.49-8
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,024 kB
  • ctags: 677
  • sloc: ansic: 5,535; python: 2,125; sh: 452; makefile: 436
file content (79 lines) | stat: -rw-r--r-- 2,596 bytes parent folder | download
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
#!/bin/sh
### BEGIN INIT INFO
# Provides:          restorecond
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Default-Start:     S 2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the Daemon used to maintain path file context
# Description:       uses inotify to look for creation of new files
#                    listed in the /etc/selinux/restorecond.conf file, 
#                    and restores the correct security context.
### END INIT INFO

# Return values according to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# Check for daemon presence
test -x /usr/sbin/restorecond  || exit 0

# Test to see if SELinux is enabled
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 0

# Check that we are root ... so non-root users stop here
test $(id -u) = 0  || exit 1


# Get lsb functions
. /lib/lsb/init-functions
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Test to see if we are configured
if [ ! -f  /etc/selinux/restorecond.conf  ]; then
    log_failure_msg "There is no configuration file for restorecond."
    log_failure_msg "Please create /etc/selinux/restorecond.conf."
    exit 6
fi

RETVAL=0

# See how we were called.
case "$1" in
    start)
        log_daemon_msg "Starting file context maintaining daemon" "restorecond"
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
        start-stop-daemon --start --quiet  --oknodo --pidfile /var/run/restorecond.pid --exec /usr/sbin/restorecond 
        RETVAL=$?
        log_end_msg $RETVAL
        ;;
    stop)
        log_daemon_msg "Stopping  file context maintaining daemon" "restorecond"
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
        start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/restorecond.pid --retry 2 --exec /usr/sbin/restorecond 
	RETVAL=$?
        log_end_msg $RETVAL
        ;;
    force-reload|restart)
        log_action_begin_msg "Restarting restorecond"
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
        $0 stop  || RETVAL=1
        sleep 1
        $0 start || RETVAL=1
        log_action_end_msg $RETVAL
	;;
    *)
        log_success_msg "Usage: $0 {start|stop|restart|reload|condrestart}"
        RETVAL=1
esac

exit $RETVAL