-
-
Save PhilZ-cwm6/bdc85494725bd1c1443b4db0f7f306e4 to your computer and use it in GitHub Desktop.
vncserver rc.d script for FreeBSD
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 | |
# Download this file | |
# cd /usr/local/etc/rc.d && fetch --no-verify-peer https://gist.githubusercontent.com/PieterScheffers/1ecd70a1bfe640afb98f3cac9630814b/raw/326033ce1c243fd7ecd018684e748234668cf9ff/vncserver | |
# | |
# Make the file executable with: | |
# /usr/local/etc/rc.d/vncserver (chmod +x) | |
# | |
# add to /etc/rc.conf | |
# | |
# vncserver_enable="YES" | |
# vncserver_user="vncserver" | |
# vncserver_display="1" | |
# PROVIDE: vncserver | |
# REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv | |
# | |
. /etc/rc.subr | |
name=vncserver | |
rcvar=vncserver_enable | |
VNCSERVER=/usr/local/bin/vncserver | |
load_rc_config $name | |
start_cmd="vncserver_start" | |
stop_cmd="vncserver_stop" | |
restart_cmd="vncserver_restart" | |
: ${vncserver_user="vncserver"} | |
: ${vncserver_enable="NO"} | |
: ${vncserver_display="1"} | |
: ${vncserver_depth="24"} | |
: ${vncserver_geometry="1280x800"} | |
#: ${vncserver_localhost="no"} | |
: ${vncserver_localhost="yes"} | |
vncserver_start() | |
{ | |
CMD="$VNCSERVER :${vncserver_display} -depth ${vncserver_depth} -geometry ${vncserver_geometry} -localhost ${vncserver_localhost}" | |
su -l ${vncserver_user} -c "${CMD}" | |
} | |
vncserver_stop() | |
{ | |
CMD="$VNCSERVER -kill :${vncserver_display}" | |
su -l ${vncserver_user} -c "${CMD}" | |
} | |
vncserver_restart() | |
{ | |
host=$(hostname -s) | |
[ -f "/home/${vncserver_user}/.vnc/${host}:${vncserver_display}.pid" ] && run_rc_command stop | |
run_rc_command start | |
} | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment