xrdp/instfiles/xrdp_control1.sh

147 lines
2.3 KiB
Bash
Raw Normal View History

2007-04-29 14:38:30 +08:00
#!/bin/sh
# xrdp control script
# same as xrdp_control.sh except the XRDP_DIR is /usr/lib/xrdp
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
2007-02-04 07:09:08 +08:00
# maintaned by Jay Sorg
# chkconfig: 2345 11 89
# description: starts xrdp
XRDP=xrdp
SESMAN=sesman
STARTWM=startwm.sh
XRDP_DIR=/usr/lib/xrdp/
LOG=/dev/null
cd $XRDP_DIR
2007-04-29 14:38:30 +08:00
if ! test -x $XRDP
then
echo "$XRDP is not executable"
exit 0
fi
if ! test -x $SESMAN
then
echo "$SESMAN is not executable"
exit 0
fi
if ! test -x $STARTWM
then
echo "$STARTWM is not executable"
exit 0
fi
2007-04-29 14:38:30 +08:00
xrdp_start()
{
echo -n "Starting: xrdp and sesman . . "
./$XRDP >> $LOG
./$SESMAN >> $LOG
echo "."
sleep 1
2007-04-29 14:38:30 +08:00
return 0;
}
2007-04-29 14:38:30 +08:00
xrdp_stop()
{
echo -n "Stopping: xrdp and sesman . . "
./$SESMAN --kill >> $LOG
./$XRDP --kill >> $LOG
echo "."
2007-04-29 14:38:30 +08:00
return 0;
}
2007-04-29 14:38:30 +08:00
is_xrdp_running()
{
ps u --noheading -C $XRDP | grep -q -i $XRDP
if test $? -eq 0
then
return 1;
else
return 0;
fi
}
is_sesman_running()
{
ps u --noheading -C $SESMAN | grep -q -i $SESMAN
if test $? -eq 0
then
return 1;
else
return 0;
fi
}
2007-04-29 14:38:30 +08:00
check_up()
{
# Cleanup : If sesman isn't running, but the pid exists, erase it.
2007-04-29 14:38:30 +08:00
is_sesman_running
if test $? -eq 0
then
2007-04-29 14:38:30 +08:00
if test -e /var/run/sesman.pid
2007-02-04 07:09:08 +08:00
then
rm /var/run/sesman.pid
fi
fi
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
2007-04-29 14:38:30 +08:00
is_xrdp_running
if test $? -eq 0
then
2007-04-29 14:38:30 +08:00
if test -e /var/run/xrdp.pid
2007-02-04 07:09:08 +08:00
then
rm /var/run/xrdp.pid
fi
fi
2007-04-29 14:38:30 +08:00
return 0;
}
case "$1" in
start)
2007-02-04 07:09:08 +08:00
check_up
2007-04-29 14:38:30 +08:00
is_xrdp_running
if ! test $? -eq 0
2007-02-04 07:09:08 +08:00
then
2007-04-29 14:38:30 +08:00
echo "xrdp is already loaded"
2007-02-04 07:09:08 +08:00
exit 1
fi
2007-04-29 14:38:30 +08:00
is_sesman_running
if ! test $? -eq 0
2007-02-04 07:09:08 +08:00
then
echo "sesman is already loaded"
exit 1
fi
xrdp_start
;;
stop)
2007-02-04 07:09:08 +08:00
check_up
2007-04-29 14:38:30 +08:00
is_xrdp_running
if test $? -eq 0
2007-02-04 07:09:08 +08:00
then
echo "xrdp is not loaded."
fi
2007-04-29 14:38:30 +08:00
is_sesman_running
if test $? -eq 0
2007-02-04 07:09:08 +08:00
then
echo "sesman is not loaded."
fi
xrdp_stop
;;
force-reload|restart)
2007-02-04 07:09:08 +08:00
check_up
2007-04-29 14:38:30 +08:00
echo "Restarting xrdp ..."
2007-02-04 07:09:08 +08:00
xrdp_stop
2007-04-29 14:38:30 +08:00
is_xrdp_running
while ! test $? -eq 0
do
2007-02-04 07:09:08 +08:00
check_up
sleep 1
2007-04-29 14:38:30 +08:00
is_xrdp_running
2007-02-04 07:09:08 +08:00
done
xrdp_start
;;
*)
2007-02-04 07:09:08 +08:00
echo "Usage: xrdp_control.sh {start|stop|restart|force-reload}"
exit 1
esac
exit 0