#!/bin/bash # # Start the X2Go Session Broker standalone daemon # # Copyright © 2012 Mike Gabriel # Distributable under the terms of the GNU AGPL version 2. # ### BEGIN INIT INFO # Provides: x2gobroker-daemon # Required-Start: $network $remote_fs $syslog sshd # Required-Stop: $network $remote_fs $syslog sshd # Default-Start: 3 5 # Default-Stop: 0 1 6 # Short-Description: X2Go Session Broker standalone daemon # Description: X2Go Session Broker daemon comes with its own HTTP daemon ### END INIT INFO . /etc/rc.status # First reset status of this service rc_reset DAEMON=/usr/sbin/x2gobroker test -d /run && RUNDIR=/run || RUNDIR=/var/run PIDFILE_BROKER=$RUNDIR/x2gobroker/x2gobroker-daemon.pid DEBIANCONFIG_COMMON=/etc/default/python-x2gobroker DEBIANCONFIG_DAEMON=/etc/default/x2gobroker-daemon test -x "$DAEMON" || exit 0 START_BROKER=false DAEMON_BIND_ADDRESS=0.0.0.0:8080 X2GOBROKER_DEBUG=0 X2GOBROKER_DAEMON_USER='x2gobroker' X2GOBROKER_DAEMON_GROUP='x2gobroker' X2GOBROKER_DEFAULT_BACKEND="zeroconf" X2GOBROKER_CONFIG="/etc/x2go/x2gobroker.conf" X2GOBROKER_SESSIONPROFILES="/etc/x2go/broker/x2gobroker-sessionprofiles.conf" X2GOBROKER_AGENT_CMD="/usr/lib64/x2go/x2gobroker-agent" X2GOBROKER_SSL_CERTFILE= X2GOBROKER_SSL_KEYFILE= test -f $DEBIANCONFIG_COMMON && . $DEBIANCONFIG_COMMON test -f $DEBIANCONFIG_DAEMON && . $DEBIANCONFIG_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_SSL_CERTFILE export X2GOBROKER_SSL_KEYFILE su_command="su - ${X2GOBROKER_DAEMON_USER} -m -c " case "$1" in start) echo -n "Starting X2go Session broker standalone daemon ... " export HOME=/var/lib/x2gobroker startproc -f -u $X2GOBROKER_DAEMON_USER -g $X2GOBROKER_DAEMON_GROUP -p $PIDFILE_BROKER $DAEMON -b $DAEMON_BIND_ADDRESS -C $X2GOBROKER_CONFIG pidof x2gobroker > $PIDFILE_BROKER rc_status -v ;; stop) echo -n "Stopping X2go Session broker standalone daemon ... " killproc -TERM -p $PIDFILE_BROKER x2gobroker rm -f $PIDFILE_BROKER # Remember status and be verbose rc_status -v ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start # Remember status and be quiet rc_status ;; status) echo -n "Checking for X2go Session broker ... " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. # Status has a slightly different for the status command: # 0 - service running # 1 - service dead, but /var/run/ pid file exists # 2 - service dead, but /var/lock/ lock file exists # 3 - service not running # NOTE: checkproc returns LSB compliant status values. checkproc -p $PIDFILE_BROKER x2gobroker rc_status -v ;; *) echo "Usage: $0 {start|stop|status|restart}" exit 1 ;; esac rc_exit