Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Last active January 1, 2024 12:01
Show Gist options
  • Save PieterScheffers/1ecd70a1bfe640afb98f3cac9630814b to your computer and use it in GitHub Desktop.
Save PieterScheffers/1ecd70a1bfe640afb98f3cac9630814b to your computer and use it in GitHub Desktop.
vncserver rc.d script for FreeBSD
#!/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_start()
{
CMD="$VNCSERVER -depth ${vncserver_depth} -geometry ${vncserver_geometry} -nolisten tcp :${vncserver_display}"
su -l ${vncserver_user} -c "${CMD}"
}
vncserver_stop()
{
CMD="$VNCSERVER -kill :${vncserver_display}"
su -l ${vncserver_user} -c "${CMD}"
}
run_rc_command "$1"
@joe81tx
Copy link

joe81tx commented Jan 1, 2024

I wasn't using port forwarding. My issue is that upon boot the vnc service would start before dbus and thus fail. So after every reboot I would have to manually restart the vnc service. But when I added dbus to the require line the service would wait for dbus to be active, then start so everything worked automatically if I reboot my system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment