1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#!/bin/sh
#
# Start the X2Go Session Broker PAM Authentication Service
#
# Copyright © 2014-2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# Distributable under the terms of the GNU AGPL version 3+.
#
### BEGIN INIT INFO
# Provides: x2gobroker-authservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: X2Go Session Broker PAM Authentication Service
# Description: PAM authentication service for X2Go Session Broker
### END INIT INFO
#
set -eu
AUTHSERVICE=/usr/sbin/x2gobroker-authservice
test -d /run && RUNDIR=/run || RUNDIR=/var/run
PIDFILE_AUTHSERVICE=$RUNDIR/x2gobroker/x2gobroker-authservice.pid
DEBIANCONFIG_COMMON=/etc/default/python-x2gobroker
DEBIANCONFIG_AUTHSERVICE=/etc/default/x2gobroker-authservice
test -x "$AUTHSERVICE" || exit 0
START_AUTHSERVICE=false
X2GOBROKER_DEBUG=0
X2GOBROKER_DAEMON_USER='x2gobroker'
X2GOBROKER_DAEMON_GROUP='x2gobroker'
X2GOBROKER_AUTHSERVICE_SOCKET="$RUNDIR/x2gobroker/x2gobroker-authservice.socket"
test -f $DEBIANCONFIG_COMMON && . $DEBIANCONFIG_COMMON
test -f $DEBIANCONFIG_AUTHSERVICE && . $DEBIANCONFIG_AUTHSERVICE
if ! getent passwd $X2GOBROKER_DAEMON_USER 1>/dev/null 2>/dev/null; then
X2GOBROKER_DAEMON_USER=nobody
fi
if ! getent group $X2GOBROKER_DAEMON_GROUP 1>/dev/null 2>/dev/null; then
X2GOBROKER_DAEMON_GROUP=nogroup
fi
# create PID directory
mkdir -p $RUNDIR/x2gobroker
chown $X2GOBROKER_DAEMON_USER:$X2GOBROKER_DAEMON_GROUP $RUNDIR/x2gobroker
chmod 0770 $RUNDIR/x2gobroker
export X2GOBROKER_DEBUG
export X2GOBROKER_DAEMON_USER
export X2GOBROKER_DAEMON_GROUP
export X2GOBROKER_AUTHSERVICE_SOCKET
. /lib/lsb/init-functions
is_true()
{
case "${1:-}" in
[Yy]es|[Yy]|1|[Tt]|[Tt]rue) return 0;;
*) return 1;
esac
}
case "${1:-}" in
start)
if [ -f $PIDFILE_AUTHSERVICE ]; then
if ps a -u root | grep -v egrep | egrep ".*$(basename $AUTHSERVICE).*$X2GOBROKER_AUTHSERVICE_SOCKET.*" 1>/dev/null 2>/dev/null; then
log_warning_msg "X2Go Broker Authentication Service already running"
else
log_warning_msg "X2Go Broker Authentication Service: stale PID file ($PIDFILE_AUTHSERVICE). Delete it manually!"
fi
START_AUTHSERVICE=no
fi
if is_true $START_AUTHSERVICE; then
set +e
# once we are here, we have to make sure the authservice.socket does not exist
rm -f $X2GOBROKER_AUTHSERVICE_SOCKET
# and now we can start the auth service
log_daemon_msg "Starting X2Go Broker Authentication Service" "$(basename $AUTHSERVICE)"
start-stop-daemon -b -m -S -p $PIDFILE_AUTHSERVICE -x $AUTHSERVICE -- -s $X2GOBROKER_AUTHSERVICE_SOCKET -o root -g $X2GOBROKER_DAEMON_GROUP -p 0660
log_end_msg $?
set -e
fi
;;
stop)
if [ -f $PIDFILE_AUTHSERVICE ] ; then
log_daemon_msg "Stopping X2Go Broker Authentication Service" "$(basename $AUTHSERVICE)"
set +e
start-stop-daemon -K -p $PIDFILE_AUTHSERVICE && rm -f $PIDFILE_AUTHSERVICE
log_end_msg $?
set -e
fi
;;
status)
if ps -C x2gobroker-authservice 1>/dev/null 2>/dev/null; then
log_action_msg "X2Go Session Broker Authentication Service is up and running"
else
log_warning_msg "X2Go Session Broker Authentication Service daemon is down"
fi
;;
restart|reload|force-reload)
${0:-} stop
${0:-} start
;;
*)
echo "Usage: ${0:-} {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
|