File mcstrans-0.3.3-initscript.patch of Package mcstrans
Index: src/mcstrans.init
===================================================================
--- src/mcstrans.init.orig
+++ src/mcstrans.init
@@ -1,12 +1,7 @@
-#!/bin/bash
-#
-# mcstransd This starts and stops mcstransd
-#
-# chkconfig: - 08 87
-# description: This starts the SELinux Context Translation System Daemon
+#!/bin/sh
#
# processname: /sbin/mcstransd
-# pidfile: /var/run/mcstransd.pid
+# pidfile: /var/run/mcstransd.pid
#
# Return values according to LSB for all commands but status:
# 0 - success
@@ -17,56 +12,68 @@
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
+#
+### BEGIN INIT INFO
+# Provides: mcstrans
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Should-Start:
+# Should-Stop:
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: This starts and stops mcstransd
+# Description: This starts the SELinux Context Translation System Daemon
+### END INIT INFO
+#
PATH=/sbin:/bin:/usr/bin:/usr/sbin
prog="mcstransd"
-lockfile=/var/lock/subsys/$prog
+lockfile=/var/lock/$prog
+SETRANS_DIR=/var/run/setrans
+
# Source function library.
-. /etc/init.d/functions
+. /etc/rc.status
# Allow anyone to run status
if [ "$1" = "status" ] ; then
- status $prog
- RETVAL=$?
- exit $RETVAL
+ echo -n $"Checking for $prog: "
+ checkproc -p $LOCK_FILE $prog
+ rc_status -v
+ rc_exit
fi
# Check that we are root ... so non-root users stop here
-test $EUID = 0 || exit 4
+if [ $EUID -ne 0 ] ; then
+ echo $"Access denied. Only root can run this daemon"
+ rc_failed 4
+ rc_status -v
+ rc_exit
+fi
+
+# Check whether SELinux is enabled
+if [ ! -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled ; then
+ echo $"SELinux should be enabled to run this daemon"
+ rc_failed 1
+ rc_status -v
+ rc_exit
+fi
-# If selinux is not enabled, return success
-test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled || exit 0
RETVAL=0
start(){
test -x /sbin/mcstransd || exit 5
echo -n $"Starting $prog: "
- if status $prog > /dev/null; then
- echo -n $"$prog: already running"
- failure
- echo
- return 1
- fi
-
- unset HOME MAIL USER USERNAME
- daemon $prog "$EXTRAOPTIONS"
- RETVAL=$?
- echo
- if test $RETVAL = 0 ; then
- touch $lockfile
- fi
- return $RETVAL
+ startproc -p $lockfile $prog "$EXTRAOPTIONS"
+ rc_status -v
+
}
stop(){
echo -n $"Stopping $prog: "
- killproc $prog
- RETVAL=$?
- echo
- rm -f $lockfile
- return $RETVAL
+ killproc -p $lockfile -TERM $prog
+ rc_status -v
}
restart(){
@@ -75,7 +82,7 @@ restart(){
}
condrestart(){
- [ -e $lockfile ] && restart
+ [ -e $lockfile ] && restart || :
return 0
}
@@ -95,8 +102,9 @@ case "$1" in
condrestart
;;
*)
- echo $"Usage: $0 {start|stop|status|restart|force-reload|condrestart}"
- RETVAL=3
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+ rc_failed 3
+ rc_status -v
esac
-exit $RETVAL
+rc_exit