summaryrefslogtreecommitdiffstats
path: root/instfiles
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2007-04-29 06:19:13 +0000
committerjsorg71 <jsorg71>2007-04-29 06:19:13 +0000
commitced52dc681f4ef2b9d558250898ba760c1803ae6 (patch)
tree66d5662d83d00678d8e290889a93fedab6fe39a2 /instfiles
parent99e7f9d8ca8b6f09e88efc4fc394d0fb3fa1754f (diff)
downloadxrdp-proprietary-ced52dc681f4ef2b9d558250898ba760c1803ae6.tar.gz
xrdp-proprietary-ced52dc681f4ef2b9d558250898ba760c1803ae6.zip
more portable start / stop script
Diffstat (limited to 'instfiles')
-rwxr-xr-xinstfiles/xrdp_control.sh92
1 files changed, 68 insertions, 24 deletions
diff --git a/instfiles/xrdp_control.sh b/instfiles/xrdp_control.sh
index 92ad3006..d5173150 100755
--- a/instfiles/xrdp_control.sh
+++ b/instfiles/xrdp_control.sh
@@ -1,5 +1,4 @@
-#!/bin/bash
-# this needs to be a bash script, the first line needs to be #!/bin/bash
+#!/bin/sh
# xrdp control script
# Written : 1-13-2006 - Mark Balliet - posicat@pobox.com
# maintaned by Jay Sorg
@@ -14,57 +13,97 @@ LOG=/dev/null
cd $XRDP_DIR
-test -x $XRDP || (echo "$XRDP is not executable" ; exit 0)
-test -x $SESMAN || (echo "$SESMAN is not executable" ; exit 0)
-test -x $STARTWM || (echo "$STARTWM is not executable" ; exit 0)
+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
-xrdp_start () {
- echo -n "Starting : xrdp and sesman . . "
+xrdp_start()
+{
+ echo -n "Starting: xrdp and sesman . . "
./$XRDP >> $LOG
./$SESMAN >> $LOG
echo "."
sleep 1
- return 0
+ return 0;
}
-xrdp_stop () {
- echo -n "Stopping : xrdp and sesman . . "
+xrdp_stop()
+{
+ echo -n "Stopping: xrdp and sesman . . "
./$SESMAN --kill >> $LOG
./$XRDP --kill >> $LOG
echo "."
+ return 0;
}
-check_up () {
- xrdpup=`ps u --noheading -C $XRDP`
- sesup=`ps u --noheading -C $SESMAN`
+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
+}
+check_up()
+{
# Cleanup : If sesman isn't running, but the pid exists, erase it.
- if [ "$sesup" == "" ]
+ is_sesman_running
+ if test $? -eq 0
then
- if [ -e /var/run/sesman.pid ]
+ if test -e /var/run/sesman.pid
then
rm /var/run/sesman.pid
fi
fi
# Cleanup : If xrdp isn't running, but the pid exists, erase it.
- if [ "$xrdpup" == "" ]
+ is_xrdp_running
+ if test $? -eq 0
then
- if [ -e /var/run/xrdp.pid ]
+ if test -e /var/run/xrdp.pid
then
rm /var/run/xrdp.pid
fi
fi
+ return 0;
}
case "$1" in
start)
check_up
- if [ "$xrdpup" != "" ]
+ is_xrdp_running
+ if ! test $? -eq 0
then
- echo "Xrdp is already loaded"
+ echo "xrdp is already loaded"
exit 1
fi
- if [ "$sesup" != "" ]
+ is_sesman_running
+ if ! test $? -eq 0
then
echo "sesman is already loaded"
exit 1
@@ -73,11 +112,13 @@ case "$1" in
;;
stop)
check_up
- if [ "$xrdpup" == "" ]
+ is_xrdp_running
+ if test $? -eq 0
then
echo "xrdp is not loaded."
fi
- if [ "$sesup" == "" ]
+ is_sesman_running
+ if test $? -eq 0
then
echo "sesman is not loaded."
fi
@@ -85,11 +126,14 @@ case "$1" in
;;
force-reload|restart)
check_up
- echo "Restarting Xrdp ..."
+ echo "Restarting xrdp ..."
xrdp_stop
- while [ "$xrdpup" != "" ]; do
+ is_xrdp_running
+ while ! test $? -eq 0
+ do
check_up
sleep 1
+ is_xrdp_running
done
xrdp_start
;;