3
# Provides: mcstransd mcstrans
4
# Required-Start: $remote_fs $syslog
5
# Required-Stop: $remote_fs $syslog
6
# Default-Start: 2 3 4 5
8
# Short-Description: The daemon to make sensitivity labels human readable form
9
# Description: This daemon maps machine readable sensitivity labels
10
# (numbered levels and categories) to a human readable form
11
# (arbitrary names assigned by the sysadmin).
14
# Author: Laurent Bigonville <bigon@debian.org>
18
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
DESC="SELinux Context Translation System"
21
DAEMON=/sbin/mcstransd
23
PIDFILE=/var/run/$NAME.pid
24
SCRIPTNAME=/etc/init.d/mcstrans
26
# Exit if the package is not installed
27
[ -x "$DAEMON" ] || exit 0
29
# Test to see if SELinux is enabled
30
[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 0
32
# Read configuration variable file if it is present
33
[ -r /etc/default/mcstrans ] && . /etc/default/mcstrans
35
# Define LSB log_* functions.
36
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
37
# and status_of_proc is working.
38
. /lib/lsb/init-functions
40
# Read SELinux configuration file if it is present
41
[ -r /etc/selinux/config ] && . /etc/selinux/config
42
if [ -z "$SELINUXTYPE" -o ! -r "/etc/selinux/$SELINUXTYPE/setrans.conf" ]; then
43
log_warning_msg "Daemon not started, configuration file not found."
48
# Function that starts the daemon/service
53
# 0 if daemon has been started
54
# 1 if daemon was already running
55
# 2 if daemon could not be started
56
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
59
if ! [ -d /var/run/setrans ]; then
60
mkdir -p /var/run/setrans
61
[ -x /sbin/restorecon ] && /sbin/restorecon /var/run/setrans
63
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
67
pidof $DAEMON > $PIDFILE
71
# Function that stops the daemon/service
76
# 0 if daemon has been stopped
77
# 1 if daemon was already stopped
78
# 2 if daemon could not be stopped
79
# other if a failure occurred
80
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
82
[ "$RETVAL" = 2 ] && return 2
89
# Function that sends a SIGHUP to the daemon/service
92
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
98
log_daemon_msg "Starting $DESC" "$NAME"
101
0|1) log_end_msg 0 ;;
106
log_daemon_msg "Stopping $DESC" "$NAME"
109
0|1) log_end_msg 0 ;;
114
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
117
log_daemon_msg "Reloading $DESC" "$NAME"
122
log_daemon_msg "Restarting $DESC" "$NAME"
129
1) log_end_msg 1 ;; # Old process is still running
130
*) log_end_msg 1 ;; # Failed to start
140
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2