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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#!/bin/sh
#
# Start the X2Go Session Broker standalone daemon
#
# Copyright © 2012-2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
# Distributable under the terms of the GNU AGPL version 3+.
#
### BEGIN INIT INFO
# Provides: x2gobroker-daemon
# Required-Start: $remote_fs $syslog x2gobroker-authservice
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: X2Go Session Broker standalone daemon
# Description: X2Go Session Broker comes with its own HTTP daemon
### END INIT INFO
#
set -eu
DAEMON=/usr/bin/x2gobroker-daemon
test -d /run && RUNDIR=/run || RUNDIR=/var/run
PIDFILE_BROKER=$RUNDIR/x2gobroker/x2gobroker-daemon.pid
DEFAULTCONFIG_COMMON=/etc/default/python-x2gobroker
DEFAULTCONFIG_DAEMON=/etc/default/x2gobroker-daemon
test -x "$DAEMON" || exit 0
START_BROKER=false
DAEMON_BIND_ADDRESS=127.0.0.1:8080
X2GOBROKER_DEBUG=0
X2GOBROKER_DAEMON_USER='x2gobroker'
X2GOBROKER_DAEMON_GROUP='x2gobroker'
X2GOBROKER_DEFAULT_BACKEND="inifile"
X2GOBROKER_CONFIG="/etc/x2go/x2gobroker.conf"
X2GOBROKER_SESSIONPROFILES="/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
X2GOBROKER_AGENT_CMD="/usr/lib/x2go/x2gobroker-agent"
X2GOBROKER_AUTHSERVICE_SOCKET="$RUNDIR/x2gobroker/x2gobroker-authservice.socket"
X2GOBROKER_SSL_CERTFILE=
X2GOBROKER_SSL_KEYFILE=
test -f $DEFAULTCONFIG_COMMON && . $DEFAULTCONFIG_COMMON
test -f $DEFAULTCONFIG_DAEMON && . $DEFAULTCONFIG_DAEMON
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
# mend user ID variables when --chuid $X2GOBROKER_DAEMON_USER is used with start-stop-daemon
export LOGNAME=$X2GOBROKER_DAEMON_USER
export USER=$X2GOBROKER_DAEMON_USER
export USERNAME=$X2GOBROKER_DAEMON_USER
export X2GOBROKER_DEBUG
export X2GOBROKER_DAEMON_USER
export X2GOBROKER_DAEMON_GROUP
export X2GOBROKER_CONFIG
export X2GOBROKER_DEFAULT_BACKEND
export X2GOBROKER_SESSIONPROFILES
export X2GOBROKER_AGENT_CMD
export X2GOBROKER_AUTHSERVICE_SOCKET
export X2GOBROKER_SSL_CERTFILE
export X2GOBROKER_SSL_KEYFILE
. /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_BROKER ]; then
if ps a -u $X2GOBROKER_DAEMON_USER | egrep -v "(grep|ps)" | awk '{ print $5 }' | grep "$(basename $DAEMON)" 1>/dev/null 2>/dev/null; then
log_warning_msg "X2Go Session Broker already running"
else
log_warning_msg "X2Go Session Broker: stale PID file ($PIDFILE_BROKER). Delete it manually!"
fi
START_BROKER=no
fi
if is_true $START_BROKER; then
log_daemon_msg "Starting X2Go Session Broker standalone daemon" "$(basename $DAEMON)"
set +e
start-stop-daemon --chuid $X2GOBROKER_DAEMON_USER -b -m -S -p $PIDFILE_BROKER -x $DAEMON -- -b $DAEMON_BIND_ADDRESS
log_end_msg $?
set -e
fi
;;
stop)
if [ -f $PIDFILE_BROKER ] ; then
log_daemon_msg "Stopping X2Go Session Broker standalone daemon" "$(basename $DAEMON)"
set +e
start-stop-daemon -K --signal TERM --quiet -p $PIDFILE_BROKER && rm -f $PIDFILE_BROKER
log_end_msg $?
set -e
fi
;;
status)
if ps -C x2gobroker-daemon 1>/dev/null 2>/dev/null; then
log_action_msg "X2Go Session Broker HTTP standalone daemon is up and running"
else
log_warning_msg "X2Go Session Broker HTTP standalone 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
|