
| Current Path : /etc/init.d/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //etc/init.d/xrdp |
#!/bin/sh
### BEGIN INIT INFO
# Provides: xrdp
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: xrdp (X Remote Desktop Protocol) full server
# Description: The xrdp daemon uses the Remote Desktop Protocol
# to present a graphical login to a remote client,
# allowing connections to an xorgxrdp or VNC server
# or another RDP server. The xrdp-sesman daemon
# authenticates the users against PAM and starts
# the session and, if necessary, X11 server.
### END INIT INFO
#-
# Copyright © 2015, 2019 mirabilos <thorsten.glaser@teckids.org>
# Published under The MirOS Licence.
# absolute basics
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin
export LC_ALL PATH
unset LANGUAGE
# exit cleanly if disabled or not installed
test -x /usr/sbin/xrdp || exit 0
# Debian/LSB init script foobar
DESC='Remote Desktop Protocol server'
NAME=xrdp
. /lib/init/vars.sh
test -t 0 && VERBOSE=yes
. /lib/lsb/init-functions
# read options
SESMAN_START=yes
SESMAN_OPTIONS=
XRDP_OPTIONS=
test -r /etc/default/xrdp && . /etc/default/xrdp
# prepare for actions
case $1 in
(status)
# nothing to do here
;;
(start|stop|force-reload|restart|try-restart)
# check for root; create run-time directories
. /usr/share/xrdp/socksetup
;;
(*)
# syntax error
echo >&2 "Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
exit 3
;;
esac
# take action
rv=0
case $1 in
(start)
test x"$VERBOSE" = x"no" || log_daemon_msg "Starting $DESC"
test x"$SESMAN_START" = x"yes" && \
if start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp-sesman.pid \
--startas /usr/sbin/xrdp-sesman --name xrdp-sesman \
--exec /usr/sbin/xrdp-sesman --test; then
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp-sesman"
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp-sesman.pid \
--startas /usr/sbin/xrdp-sesman --name xrdp-sesman \
--exec /usr/sbin/xrdp-sesman -- $SESMAN_OPTIONS
rc=$?
test $rc -gt 0 && rv=$rc
else
test x"$VERBOSE" = x"no" || \
log_progress_msg "sesman already running"
fi
if start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp.pid \
--chuid xrdp:xrdp \
--startas /usr/sbin/xrdp --name xrdp \
--exec /usr/sbin/xrdp --test; then
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp"
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp.pid \
--chuid xrdp:xrdp \
--startas /usr/sbin/xrdp --name xrdp \
--exec /usr/sbin/xrdp -- $XRDP_OPTIONS >/dev/null
rc=$?
test $rc -gt 0 && rv=$rc
else
test x"$VERBOSE" = x"no" || \
log_progress_msg "xrdp already running"
fi
test x"$VERBOSE" = x"no" || log_end_msg $rv
;;
(stop)
test x"$VERBOSE" = x"no" || log_daemon_msg "Stopping $DESC"
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp.pid \
--name xrdp --exec /usr/sbin/xrdp
rc=$?
if test $rc -gt 1; then
rv=$rc
else
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp
rc=$?
test $rc -gt 1 && test $rv -lt $rc && rv=$rc
fi
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp-sesman"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp-sesman.pid \
--name xrdp-sesman --exec /usr/sbin/xrdp-sesman
rc=$?
if test $rc -gt 1; then
rv=$rc
else
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp-sesman
rc=$?
test $rc -gt 1 && test $rv -lt $rc && rv=$rc
fi
rm -f /run/xrdp/xrdp-sesman.pid /run/xrdp/xrdp.pid
rm -rf /run/xrdp/sockdir
test x"$VERBOSE" = x"no" || log_end_msg $rv
;;
(status)
if test x"$SESMAN_START" = x"yes"; then
status_of_proc -p /run/xrdp/xrdp-sesman.pid \
/usr/sbin/xrdp-sesman xrdp-sesman
rc=$?
test $rc -gt $rv && rv=$rc
fi
status_of_proc -p /run/xrdp/xrdp.pid /usr/sbin/xrdp xrdp
rc=$?
test $rc -gt $rv && rv=$rc
exit $rv
;;
(force-reload|restart)
test x"$VERBOSE" = x"no" || log_daemon_msg "Restarting $DESC"
if test x"$SESMAN_START" = x"yes"; then
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp-sesman"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp-sesman.pid \
--name xrdp-sesman --exec /usr/sbin/xrdp-sesman
if test $? -lt 2; then
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp-sesman
fi
rm -f /run/xrdp/xrdp-sesman.pid
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp-sesman.pid \
--startas /usr/sbin/xrdp-sesman --name xrdp-sesman \
--exec /usr/sbin/xrdp-sesman -- $SESMAN_OPTIONS
rc=$?
test $rc -gt 0 && rv=$rc
fi
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp.pid \
--name xrdp --exec /usr/sbin/xrdp
if test $? -lt 2; then
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp
fi
rm -f /run/xrdp/xrdp.pid
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp.pid \
--chuid xrdp:xrdp \
--startas /usr/sbin/xrdp --name xrdp \
--exec /usr/sbin/xrdp -- $XRDP_OPTIONS >/dev/null
rc=$?
test $rc -gt 0 && rv=$rc
test x"$VERBOSE" = x"no" || log_end_msg $rv
;;
(try-restart)
test x"$VERBOSE" = x"no" || log_daemon_msg "Trying to restart $DESC"
if ! status_of_proc -p /run/xrdp/xrdp.pid \
/usr/sbin/xrdp xrdp >/dev/null 2>&1; then
test x"$VERBOSE" = x"no" || log_progress_msg "is not running."
test x"$VERBOSE" = x"no" || log_end_msg 1
exit 0
fi
if status_of_proc -p /run/xrdp/xrdp-sesman.pid \
/usr/sbin/xrdp-sesman xrdp-sesman >/dev/null 2>&1; then
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp-sesman"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp-sesman.pid \
--name xrdp-sesman --exec /usr/sbin/xrdp-sesman
if test $? -lt 2; then
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp-sesman
fi
rm -f /run/xrdp/xrdp-sesman.pid
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp-sesman.pid \
--startas /usr/sbin/xrdp-sesman --name xrdp-sesman \
--exec /usr/sbin/xrdp-sesman -- $SESMAN_OPTIONS
rc=$?
test $rc -gt 0 && rv=$rc
fi
test x"$VERBOSE" = x"no" || log_progress_msg "xrdp"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile /run/xrdp/xrdp.pid \
--name xrdp --exec /usr/sbin/xrdp
if test $? -lt 2; then
start-stop-daemon --stop --quiet --oknodo \
--retry=0/30/KILL/5 --exec /usr/sbin/xrdp
fi
rm -f /run/xrdp/xrdp.pid
start-stop-daemon --start --quiet \
--pidfile /run/xrdp/xrdp.pid \
--chuid xrdp:xrdp \
--startas /usr/sbin/xrdp --name xrdp \
--exec /usr/sbin/xrdp -- $XRDP_OPTIONS >/dev/null
rc=$?
test $rc -gt 0 && rv=$rc
test x"$VERBOSE" = x"no" || log_end_msg $rv
;;
esac
# make “/etc/init.d/xrdp status” work for nōn-root
(sleep 3; chmod a+r /run/xrdp/*.pid 2>/dev/null) &
exit $rv