1#!/bin/bash
2#
3# mcstransd        This starts and stops mcstransd
4#
5# chkconfig: - 08 87
6# description: This starts the SELinux Context Translation System Daemon
7#
8# processname: /sbin/mcstransd
9# pidfile: /var/run/mcstransd.pid
10#
11# Return values according to LSB for all commands but status:
12# 0 - success
13# 1 - generic or unspecified error
14# 2 - invalid or excess argument(s)
15# 3 - unimplemented feature (e.g. "reload")
16# 4 - insufficient privilege
17# 5 - program is not installed
18# 6 - program is not configured
19# 7 - program is not running
20
21PATH=/sbin:/bin:/usr/bin:/usr/sbin
22prog="mcstransd"
23lockfile=/var/lock/subsys/$prog
24
25# Source function library.
26. /etc/init.d/functions
27
28# Allow anyone to run status
29if [ "$1" = "status" ] ; then
30	status $prog
31	RETVAL=$?
32	exit $RETVAL
33fi
34
35# Check that we are root ... so non-root users stop here
36test $EUID = 0  || exit 4
37
38# If selinux is not enabled, return success
39test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled || exit 0
40
41RETVAL=0
42
43start(){
44	test -x /sbin/mcstransd  || exit 5
45	echo -n $"Starting $prog: "
46	if status $prog > /dev/null; then
47		echo -n $"$prog: already running"
48		failure
49		echo
50		return 1
51	fi
52
53	unset HOME MAIL USER USERNAME
54	daemon $prog "$EXTRAOPTIONS"
55	RETVAL=$?
56	echo
57	if test $RETVAL = 0 ; then
58        	touch $lockfile
59	fi
60	return $RETVAL
61}
62
63stop(){
64	echo -n $"Stopping $prog: "
65	killproc $prog
66	RETVAL=$?
67	echo
68	rm -f $lockfile
69	return $RETVAL
70}
71
72restart(){
73	stop
74	start
75}
76
77condrestart(){
78	[ -e $lockfile ] && restart
79	return 0
80}
81
82
83# See how we were called.
84case "$1" in
85    start)
86	start
87	;;
88    stop)
89	stop
90	;;
91    restart|force-reload)
92	restart
93	;;
94    condrestart)
95	condrestart
96	;;
97    *)
98	echo $"Usage: $0 {start|stop|status|restart|force-reload|condrestart}"
99	RETVAL=3
100esac
101
102exit $RETVAL
103