|
|
@ -1,5 +1,4 @@
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/sh
|
|
|
|
# this needs to be a bash script, the first line needs to be #!/bin/bash
|
|
|
|
|
|
|
|
# xrdp control script
|
|
|
|
# xrdp control script
|
|
|
|
# same as xrdp_control.sh except the XRDP_DIR is /usr/lib/xrdp
|
|
|
|
# same as xrdp_control.sh except the XRDP_DIR is /usr/lib/xrdp
|
|
|
|
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
|
|
|
|
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
|
|
|
@ -15,57 +14,97 @@ LOG=/dev/null
|
|
|
|
|
|
|
|
|
|
|
|
cd $XRDP_DIR
|
|
|
|
cd $XRDP_DIR
|
|
|
|
|
|
|
|
|
|
|
|
test -x $XRDP || (echo "$XRDP is not executable" ; exit 0)
|
|
|
|
if ! test -x $XRDP
|
|
|
|
test -x $SESMAN || (echo "$SESMAN is not executable" ; exit 0)
|
|
|
|
then
|
|
|
|
test -x $STARTWM || (echo "$STARTWM is not executable" ; exit 0)
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
xrdp_start () {
|
|
|
|
xrdp_start()
|
|
|
|
echo -n "Starting : xrdp and sesman . . "
|
|
|
|
{
|
|
|
|
|
|
|
|
echo -n "Starting: xrdp and sesman . . "
|
|
|
|
./$XRDP >> $LOG
|
|
|
|
./$XRDP >> $LOG
|
|
|
|
./$SESMAN >> $LOG
|
|
|
|
./$SESMAN >> $LOG
|
|
|
|
echo "."
|
|
|
|
echo "."
|
|
|
|
sleep 1
|
|
|
|
sleep 1
|
|
|
|
return 0
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xrdp_stop () {
|
|
|
|
xrdp_stop()
|
|
|
|
echo -n "Stopping : xrdp and sesman . . "
|
|
|
|
{
|
|
|
|
|
|
|
|
echo -n "Stopping: xrdp and sesman . . "
|
|
|
|
./$SESMAN --kill >> $LOG
|
|
|
|
./$SESMAN --kill >> $LOG
|
|
|
|
./$XRDP --kill >> $LOG
|
|
|
|
./$XRDP --kill >> $LOG
|
|
|
|
echo "."
|
|
|
|
echo "."
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
check_up () {
|
|
|
|
is_xrdp_running()
|
|
|
|
xrdpup=`ps u --noheading -C $XRDP`
|
|
|
|
{
|
|
|
|
sesup=`ps u --noheading -C $SESMAN`
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_up()
|
|
|
|
|
|
|
|
{
|
|
|
|
# Cleanup : If sesman isn't running, but the pid exists, erase it.
|
|
|
|
# Cleanup : If sesman isn't running, but the pid exists, erase it.
|
|
|
|
if [ "$sesup" == "" ]
|
|
|
|
is_sesman_running
|
|
|
|
|
|
|
|
if test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
if [ -e /var/run/sesman.pid ]
|
|
|
|
if test -e /var/run/sesman.pid
|
|
|
|
then
|
|
|
|
then
|
|
|
|
rm /var/run/sesman.pid
|
|
|
|
rm /var/run/sesman.pid
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
|
|
|
|
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
|
|
|
|
if [ "$xrdpup" == "" ]
|
|
|
|
is_xrdp_running
|
|
|
|
|
|
|
|
if test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
if [ -e /var/run/xrdp.pid ]
|
|
|
|
if test -e /var/run/xrdp.pid
|
|
|
|
then
|
|
|
|
then
|
|
|
|
rm /var/run/xrdp.pid
|
|
|
|
rm /var/run/xrdp.pid
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start)
|
|
|
|
check_up
|
|
|
|
check_up
|
|
|
|
if [ "$xrdpup" != "" ]
|
|
|
|
is_xrdp_running
|
|
|
|
|
|
|
|
if ! test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
echo "Xrdp is already loaded"
|
|
|
|
echo "xrdp is already loaded"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$sesup" != "" ]
|
|
|
|
is_sesman_running
|
|
|
|
|
|
|
|
if ! test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
echo "sesman is already loaded"
|
|
|
|
echo "sesman is already loaded"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
@ -74,11 +113,13 @@ case "$1" in
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop)
|
|
|
|
check_up
|
|
|
|
check_up
|
|
|
|
if [ "$xrdpup" == "" ]
|
|
|
|
is_xrdp_running
|
|
|
|
|
|
|
|
if test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
echo "xrdp is not loaded."
|
|
|
|
echo "xrdp is not loaded."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$sesup" == "" ]
|
|
|
|
is_sesman_running
|
|
|
|
|
|
|
|
if test $? -eq 0
|
|
|
|
then
|
|
|
|
then
|
|
|
|
echo "sesman is not loaded."
|
|
|
|
echo "sesman is not loaded."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -86,11 +127,14 @@ case "$1" in
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
force-reload|restart)
|
|
|
|
force-reload|restart)
|
|
|
|
check_up
|
|
|
|
check_up
|
|
|
|
echo "Restarting Xrdp ..."
|
|
|
|
echo "Restarting xrdp ..."
|
|
|
|
xrdp_stop
|
|
|
|
xrdp_stop
|
|
|
|
while [ "$xrdpup" != "" ]; do
|
|
|
|
is_xrdp_running
|
|
|
|
|
|
|
|
while ! test $? -eq 0
|
|
|
|
|
|
|
|
do
|
|
|
|
check_up
|
|
|
|
check_up
|
|
|
|
sleep 1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
is_xrdp_running
|
|
|
|
done
|
|
|
|
done
|
|
|
|
xrdp_start
|
|
|
|
xrdp_start
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|