#!/bin/sh
### BEGIN INIT INFO
# Provides :		restorecon
# Required-Start:	mountkernfs
# Required-Stop:	
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description: 	Restores contexts on tmpfs mounts.
### 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

# Source function library.
. /lib/lsb/init-functions

# Do nothing if selinux is not enabled.
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 0

# Check that we are root ... so non-root users stop here
test `/usr/bin/id -u` = 0  || exit 4

# Check that restorecon is installed.
test -x /sbin/restorecon || exit 5

RETVAL=0

start() 
{
        log_action_begin_msg "Starting restorecon"
	/sbin/restorecon -R /var/run /var/lock
	RETVAL=$?
	log_action_end_msg $RETVAL
	exit $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
        ;;
  stop)
        ;;
  *)
        log_failure_msg "Usage: $0 (start|stop)"
        RETVAL=3
esac

exit $RETVAL

