xrdp/instfiles/xrdp.sh

154 lines
2.5 KiB
Bash
Raw Normal View History

2007-04-29 10:19:13 +04:00
#!/bin/sh
2006-02-04 22:19:34 +03:00
# xrdp control script
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
2007-02-04 02:09:08 +03:00
# maintaned by Jay Sorg
# chkconfig: 2345 11 89
# description: starts xrdp
2006-02-04 22:19:34 +03:00
2012-09-08 09:47:27 +04:00
### BEGIN INIT INFO
# Provides: xrdp
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop xrdp
# Description: starts xrdp
### END INIT INFO
2008-04-30 08:38:17 +04:00
SBINDIR=/usr/local/sbin
2006-02-04 22:19:34 +03:00
LOG=/dev/null
2008-05-06 10:30:59 +04:00
CFGDIR=/etc/xrdp
2006-02-04 22:19:34 +03:00
2008-04-30 08:38:17 +04:00
if ! test -x $SBINDIR/xrdp
2007-04-29 10:19:13 +04:00
then
2008-04-30 08:38:17 +04:00
echo "xrdp is not executable"
2007-04-29 10:19:13 +04:00
exit 0
fi
2008-04-30 08:38:17 +04:00
if ! test -x $SBINDIR/xrdp-sesman
2007-04-29 10:19:13 +04:00
then
2008-04-30 08:38:17 +04:00
echo "xrdp-sesman is not executable"
2007-04-29 10:19:13 +04:00
exit 0
fi
2008-04-30 08:38:17 +04:00
if ! test -x $CFGDIR/startwm.sh
2007-04-29 10:19:13 +04:00
then
2008-04-30 08:38:17 +04:00
echo "startwm.sh is not executable"
2007-04-29 10:19:13 +04:00
exit 0
fi
2006-02-04 22:19:34 +03:00
2007-04-29 10:19:13 +04:00
xrdp_start()
{
echo -n "Starting: xrdp and sesman . . "
2008-04-30 08:38:17 +04:00
$SBINDIR/xrdp >> $LOG
$SBINDIR/xrdp-sesman >> $LOG
2006-02-04 22:19:34 +03:00
echo "."
sleep 1
2007-04-29 10:19:13 +04:00
return 0;
2006-02-04 22:19:34 +03:00
}
2007-04-29 10:19:13 +04:00
xrdp_stop()
{
echo -n "Stopping: xrdp and sesman . . "
2008-04-30 08:38:17 +04:00
$SBINDIR/xrdp-sesman --kill >> $LOG
$SBINDIR/xrdp --kill >> $LOG
2006-02-04 22:19:34 +03:00
echo "."
2007-04-29 10:19:13 +04:00
return 0;
2006-02-04 22:19:34 +03:00
}
2007-04-29 10:19:13 +04:00
is_xrdp_running()
{
2008-04-30 08:38:17 +04:00
ps u --noheading -C xrdp | grep -q -i xrdp
2007-04-29 10:19:13 +04:00
if test $? -eq 0
then
return 1;
else
return 0;
fi
}
is_sesman_running()
{
2008-04-30 08:38:17 +04:00
ps u --noheading -C xrdp-sesman | grep -q -i xrdp-sesman
2007-04-29 10:19:13 +04:00
if test $? -eq 0
then
return 1;
else
return 0;
fi
}
2006-02-04 22:19:34 +03:00
2007-04-29 10:19:13 +04:00
check_up()
{
2006-02-04 22:19:34 +03:00
# Cleanup : If sesman isn't running, but the pid exists, erase it.
2007-04-29 10:19:13 +04:00
is_sesman_running
if test $? -eq 0
2006-02-04 22:19:34 +03:00
then
2008-04-30 08:38:17 +04:00
if test -e /var/run/xrdp-sesman.pid
2007-02-04 02:09:08 +03:00
then
2008-04-30 08:38:17 +04:00
rm /var/run/xrdp-sesman.pid
2007-02-04 02:09:08 +03:00
fi
2006-02-04 22:19:34 +03:00
fi
2006-02-12 22:29:16 +03:00
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
2007-04-29 10:19:13 +04:00
is_xrdp_running
if test $? -eq 0
2006-02-12 22:29:16 +03:00
then
2007-04-29 10:19:13 +04:00
if test -e /var/run/xrdp.pid
2007-02-04 02:09:08 +03:00
then
rm /var/run/xrdp.pid
fi
2006-02-12 22:29:16 +03:00
fi
2007-04-29 10:19:13 +04:00
return 0;
2006-02-04 22:19:34 +03:00
}
case "$1" in
start)
2007-02-04 02:09:08 +03:00
check_up
2007-04-29 10:19:13 +04:00
is_xrdp_running
if ! test $? -eq 0
2007-02-04 02:09:08 +03:00
then
2007-04-29 10:19:13 +04:00
echo "xrdp is already loaded"
2007-02-04 02:09:08 +03:00
exit 1
fi
2007-04-29 10:19:13 +04:00
is_sesman_running
if ! test $? -eq 0
2007-02-04 02:09:08 +03:00
then
echo "sesman is already loaded"
exit 1
fi
xrdp_start
;;
2006-02-04 22:19:34 +03:00
stop)
2007-02-04 02:09:08 +03:00
check_up
2007-04-29 10:19:13 +04:00
is_xrdp_running
if test $? -eq 0
2007-02-04 02:09:08 +03:00
then
echo "xrdp is not loaded."
fi
2007-04-29 10:19:13 +04:00
is_sesman_running
if test $? -eq 0
2007-02-04 02:09:08 +03:00
then
echo "sesman is not loaded."
fi
xrdp_stop
;;
2006-02-04 22:19:34 +03:00
force-reload|restart)
2007-02-04 02:09:08 +03:00
check_up
2007-04-29 10:19:13 +04:00
echo "Restarting xrdp ..."
2007-02-04 02:09:08 +03:00
xrdp_stop
2007-04-29 10:19:13 +04:00
is_xrdp_running
while ! test $? -eq 0
do
2007-02-04 02:09:08 +03:00
check_up
sleep 1
2007-04-29 10:19:13 +04:00
is_xrdp_running
2007-02-04 02:09:08 +03:00
done
xrdp_start
;;
2006-02-04 22:19:34 +03:00
*)
2008-08-17 11:23:56 +04:00
echo "Usage: xrdp.sh {start|stop|restart|force-reload}"
2007-02-04 02:09:08 +03:00
exit 1
2006-02-04 22:19:34 +03:00
esac
exit 0