2006-07-18 19:49:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# setroubleshoot This starts and stops setroubleshoot daemon
|
|
|
|
#
|
2006-07-21 13:42:14 +00:00
|
|
|
# chkconfig: 345 13 87
|
2006-07-18 19:49:13 +00:00
|
|
|
# description: This starts the SELinux Troubleshooting Daemon
|
|
|
|
#
|
|
|
|
# processname: /usr/sbin/setroubleshootd
|
|
|
|
# config: /etc/setroubleshoot/setroubleshoot.cfg
|
|
|
|
# pidfile: /var/run/setroubleshoot.pid
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
2006-08-06 00:22:32 +00:00
|
|
|
|
|
|
|
# Silently exit is SELinux is not enabled
|
2006-08-21 15:18:36 +00:00
|
|
|
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 1
|
2006-08-06 00:22:32 +00:00
|
|
|
|
2006-07-18 19:49:13 +00:00
|
|
|
# Check that we are root ... so non-root users stop here
|
|
|
|
test `id -u` = 0 || exit 4
|
|
|
|
|
|
|
|
RETVAL=0
|
|
|
|
|
2006-08-21 15:18:36 +00:00
|
|
|
prog="setroubleshootd"
|
2006-07-18 19:49:13 +00:00
|
|
|
|
|
|
|
start(){
|
|
|
|
echo -n $"Starting $prog: "
|
|
|
|
unset HOME MAIL USER USERNAME
|
2006-08-21 15:18:36 +00:00
|
|
|
daemon $prog "$EXTRAOPTIONS"
|
2006-07-18 19:49:13 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
if test $RETVAL = 0 ; then
|
2006-09-15 20:52:45 +00:00
|
|
|
touch /var/lock/subsys/$prog
|
2006-07-18 19:49:13 +00:00
|
|
|
fi
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop(){
|
|
|
|
echo -n $"Stopping $prog: "
|
2006-08-21 15:18:36 +00:00
|
|
|
killproc $prog
|
2006-07-18 19:49:13 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2006-09-15 20:52:45 +00:00
|
|
|
rm -f /var/lock/subsys/$prog
|
2006-07-18 19:49:13 +00:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
reload(){
|
|
|
|
echo -n $"Reloading configuration: "
|
2006-08-21 15:18:36 +00:00
|
|
|
killproc $prog -HUP
|
2006-07-18 19:49:13 +00:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
restart(){
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
condrestart(){
|
2006-09-15 20:52:45 +00:00
|
|
|
[ -e /var/lock/subsys/$prog ] && restart
|
2006-07-18 19:49:13 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2006-08-21 19:44:14 +00:00
|
|
|
cleardb(){
|
|
|
|
running=0
|
2006-09-15 20:52:45 +00:00
|
|
|
[ -e /var/lock/subsys/$prog ] && running=1
|
2006-08-21 19:44:14 +00:00
|
|
|
[ $running == 1 ] && stop
|
|
|
|
echo $"Clearing database"
|
|
|
|
rm -f /var/lib/setroubleshoot/database.xml
|
|
|
|
[ $running == 1 ] && start
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2006-07-18 19:49:13 +00:00
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
status)
|
2006-08-21 15:18:36 +00:00
|
|
|
status $prog
|
2006-07-18 19:49:13 +00:00
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
reload
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
|
|
condrestart
|
|
|
|
;;
|
2006-08-21 19:44:14 +00:00
|
|
|
cleardb)
|
|
|
|
cleardb
|
|
|
|
;;
|
2006-07-18 19:49:13 +00:00
|
|
|
*)
|
2006-08-21 19:44:14 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|cleardb}"
|
2006-07-18 19:49:13 +00:00
|
|
|
RETVAL=3
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|