You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
2.3 KiB
142 lines
2.3 KiB
18 years ago
|
#!/bin/sh
|
||
19 years ago
|
# xrdp control script
|
||
|
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
|
||
18 years ago
|
# maintaned by Jay Sorg
|
||
18 years ago
|
# chkconfig: 2345 11 89
|
||
|
# description: starts xrdp
|
||
19 years ago
|
|
||
17 years ago
|
SBINDIR=/usr/local/sbin
|
||
19 years ago
|
LOG=/dev/null
|
||
17 years ago
|
CFGDIR=/etc/xrdp
|
||
19 years ago
|
|
||
17 years ago
|
if ! test -x $SBINDIR/xrdp
|
||
18 years ago
|
then
|
||
17 years ago
|
echo "xrdp is not executable"
|
||
18 years ago
|
exit 0
|
||
|
fi
|
||
17 years ago
|
if ! test -x $SBINDIR/xrdp-sesman
|
||
18 years ago
|
then
|
||
17 years ago
|
echo "xrdp-sesman is not executable"
|
||
18 years ago
|
exit 0
|
||
|
fi
|
||
17 years ago
|
if ! test -x $CFGDIR/startwm.sh
|
||
18 years ago
|
then
|
||
17 years ago
|
echo "startwm.sh is not executable"
|
||
18 years ago
|
exit 0
|
||
|
fi
|
||
19 years ago
|
|
||
18 years ago
|
xrdp_start()
|
||
|
{
|
||
|
echo -n "Starting: xrdp and sesman . . "
|
||
17 years ago
|
$SBINDIR/xrdp >> $LOG
|
||
|
$SBINDIR/xrdp-sesman >> $LOG
|
||
19 years ago
|
echo "."
|
||
|
sleep 1
|
||
18 years ago
|
return 0;
|
||
19 years ago
|
}
|
||
|
|
||
18 years ago
|
xrdp_stop()
|
||
|
{
|
||
|
echo -n "Stopping: xrdp and sesman . . "
|
||
17 years ago
|
$SBINDIR/xrdp-sesman --kill >> $LOG
|
||
|
$SBINDIR/xrdp --kill >> $LOG
|
||
19 years ago
|
echo "."
|
||
18 years ago
|
return 0;
|
||
19 years ago
|
}
|
||
|
|
||
18 years ago
|
is_xrdp_running()
|
||
|
{
|
||
17 years ago
|
ps u --noheading -C xrdp | grep -q -i xrdp
|
||
18 years ago
|
if test $? -eq 0
|
||
|
then
|
||
|
return 1;
|
||
|
else
|
||
|
return 0;
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
is_sesman_running()
|
||
|
{
|
||
17 years ago
|
ps u --noheading -C xrdp-sesman | grep -q -i xrdp-sesman
|
||
18 years ago
|
if test $? -eq 0
|
||
|
then
|
||
|
return 1;
|
||
|
else
|
||
|
return 0;
|
||
|
fi
|
||
|
}
|
||
19 years ago
|
|
||
18 years ago
|
check_up()
|
||
|
{
|
||
19 years ago
|
# Cleanup : If sesman isn't running, but the pid exists, erase it.
|
||
18 years ago
|
is_sesman_running
|
||
|
if test $? -eq 0
|
||
19 years ago
|
then
|
||
17 years ago
|
if test -e /var/run/xrdp-sesman.pid
|
||
18 years ago
|
then
|
||
17 years ago
|
rm /var/run/xrdp-sesman.pid
|
||
18 years ago
|
fi
|
||
19 years ago
|
fi
|
||
19 years ago
|
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
|
||
18 years ago
|
is_xrdp_running
|
||
|
if test $? -eq 0
|
||
19 years ago
|
then
|
||
18 years ago
|
if test -e /var/run/xrdp.pid
|
||
18 years ago
|
then
|
||
|
rm /var/run/xrdp.pid
|
||
|
fi
|
||
19 years ago
|
fi
|
||
18 years ago
|
return 0;
|
||
19 years ago
|
}
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
18 years ago
|
check_up
|
||
18 years ago
|
is_xrdp_running
|
||
|
if ! test $? -eq 0
|
||
18 years ago
|
then
|
||
18 years ago
|
echo "xrdp is already loaded"
|
||
18 years ago
|
exit 1
|
||
|
fi
|
||
18 years ago
|
is_sesman_running
|
||
|
if ! test $? -eq 0
|
||
18 years ago
|
then
|
||
|
echo "sesman is already loaded"
|
||
|
exit 1
|
||
|
fi
|
||
|
xrdp_start
|
||
|
;;
|
||
19 years ago
|
stop)
|
||
18 years ago
|
check_up
|
||
18 years ago
|
is_xrdp_running
|
||
|
if test $? -eq 0
|
||
18 years ago
|
then
|
||
|
echo "xrdp is not loaded."
|
||
|
fi
|
||
18 years ago
|
is_sesman_running
|
||
|
if test $? -eq 0
|
||
18 years ago
|
then
|
||
|
echo "sesman is not loaded."
|
||
|
fi
|
||
|
xrdp_stop
|
||
|
;;
|
||
19 years ago
|
force-reload|restart)
|
||
18 years ago
|
check_up
|
||
18 years ago
|
echo "Restarting xrdp ..."
|
||
18 years ago
|
xrdp_stop
|
||
18 years ago
|
is_xrdp_running
|
||
|
while ! test $? -eq 0
|
||
|
do
|
||
18 years ago
|
check_up
|
||
|
sleep 1
|
||
18 years ago
|
is_xrdp_running
|
||
18 years ago
|
done
|
||
|
xrdp_start
|
||
|
;;
|
||
19 years ago
|
*)
|
||
18 years ago
|
echo "Usage: xrdp_control.sh {start|stop|restart|force-reload}"
|
||
|
exit 1
|
||
19 years ago
|
esac
|
||
|
|
||
|
exit 0
|