#!/bin/bash # # Init file for xrdp # # runlevel 5 priority 20 start 80 stop # chkconfig: 5 20 80 # description: xrdp allows rdesktop and windows \ # terminal clients to connect via rdp # RETVAL=0 check_stat() { xrdp_stat=`ps h -C xrdp|grep -v $0` } start() { if [ "$xrdp_stat" != "" ];then echo xrdp is already running else echo starting xrdp /usr/local/xrdp/xrdpstart.sh > /var/log/xrdp.out #2 > #/var/log/xrdp.err fi } stop() { pid=`echo $xrdp_stat|cut -d" " -f 1` if [ "$xrdp_stat" != "" ];then echo stopping xrdp kill $pid else echo xrdp is not running fi } status() { if [ "$xrdp_stat" != "" ];then echo xrdp is running else echo xrdp is not running fi } restart() { stop sleep 5 check_stat start } check_stat case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo "Usage: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL