From efb8846ea8552f8e1f6e71b6e2fe00c2cff9c5bc Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Thu, 29 Jul 2021 21:24:01 +0100 Subject: [PATCH] Automatically start xvnc if it's installed This commit installs a etc/rc.d/xvnc as part of xvnc-server- and modifies the rc.conf template installed by disk-image to enable the service by default. --- pycheribuild/files/cheribsd/rc.conf.in | 1 + pycheribuild/projects/cross/x11.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pycheribuild/files/cheribsd/rc.conf.in b/pycheribuild/files/cheribsd/rc.conf.in index d8e2ca3dc..000c05e03 100644 --- a/pycheribuild/files/cheribsd/rc.conf.in +++ b/pycheribuild/files/cheribsd/rc.conf.in @@ -16,6 +16,7 @@ nfs_client_enable="YES" fsck_y_enable="YES" fsck_y_flags="-T ffs:-R -T ufs:-R" crashinfo_enable=NO # gdb runs for 5+ minutes on F1 if present... +xvnc_enable="YES" if [ -e /fett ]; then fett_bvrs_enable="YES" fett_nginx_enable="YES" diff --git a/pycheribuild/projects/cross/x11.py b/pycheribuild/projects/cross/x11.py index 1d03a5e80..783b7191b 100644 --- a/pycheribuild/projects/cross/x11.py +++ b/pycheribuild/projects/cross/x11.py @@ -443,6 +443,24 @@ def install(self, **kwargs): # TODO: should we install a service that we can start with `service xvnc start`? self.write_file(self.install_dir / "bin/startxvnc", overwrite=True, mode=0o755, contents="#!/bin/sh\nXvnc -geometry 1024x768 -SecurityTypes=None \"$@\"\n") + self.write_file(self.install_dir / "etc/rc.d/xvnc", overwrite=True, mode=0o755, contents=f"""#!/bin/sh +# PROVIDE: xvnc +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: nojail shutdown +. /etc/rc.subr + +name=xvnc +rcvar=xvnc_enable +: "${{xvnc_args="-geometry 1024x768 -SecurityTypes=None"}}" + +pidfile="/var/run/${{name}}.pid" +command=/usr/sbin/daemon +command_args="-p ${{pidfile}} -S -T ${{name}} {self.install_prefix / "bin/Xvnc"} ${{xvnc_args}}" + +load_rc_config $name +run_rc_command "$1" +""") def update(self): super().update()