Last active
August 29, 2015 14:10
-
-
Save morenocarullo/77da3ca5782c8b057a81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides:x11vnc | |
# Required-Start:$remote_fs $syslog | |
# Required-Stop:$remote_fs $syslog | |
# Default-Start:2 3 4 5 | |
# Default-Stop:0 1 6 | |
# Short-Description:Start X11VNC | |
# Description:Start VNC server X11VNC at boot | |
### END INIT INFO | |
case "$1" in | |
start) | |
sleep 6 | |
XAUTH=$(find /var/run/gdm3 | grep database | grep 'auth-for-Debian') | |
logger -f /var/log/x11vnc "Starting with $XAUTH" | |
start-stop-daemon --start --oknodo --pidfile /var/run/x11vnc.pid --background --nicelevel 15 --make-pidfile --exec /usr/bin/x11vnc -- -display :0 -loop -passwdfile /root/.vnc/passwd -nossl -logfile /var/log/x11vnc -auth $XAUTH | |
;; | |
stop) | |
logger -f /var/log/x11vnc "Stopping" | |
start-stop-daemon --stop --oknodo --pidfile /var/run/x11vnc.pid | |
;; | |
restart) | |
logger -f /var/log/x11vnc "Restarting" | |
$0 stop | |
$0 start | |
;; | |
condrestart) | |
PID=`cat /var/run/x11vnc.pid` | |
RUNNING=`ps h --ppid $PID` | |
if [ "$RUNNING" == "" ]; then | |
logger -f /var/log/x11vnc "No process matching /var/run/x11vnc.pid" | |
echo "No process matching /var/run/x11vnc.pid" | |
$0 restart | |
else | |
logger -f /var/log/x11vnc "Process matching /var/run/x11vnc.pid exists" | |
echo "Process matching /var/run/x11vnc.pid exists - no action taken" | |
fi | |
;; | |
*) | |
echo "Usage: $0 start|stop|restart|condrestart" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment