Fwd: Console only boot option
Anthony Jenkins
Scoobi_doo at yahoo.com
Sat Sep 3 12:41:42 UTC 2016
On 09/01/16 14:50, Allan Jude wrote:
> On 2016-09-01 14:46, Colin Percival wrote:
>>
>>
>> -------- Forwarded Message --------
>> Subject: Console only boot option
>> Date: Thu, 1 Sep 2016 11:22:23 -0400
>> From: Anthony Jenkins via freebsd-x11 <freebsd-x11 at freebsd.org>
>> Reply-To: Anthony Jenkins <Scoobi_doo at yahoo.com>
>> To: freebsd-x11 at freebsd.org <freebsd-x11 at freebsd.org>
>>
>> I have a patch against base that adds an option "Console" to the Boot
>> Options sub-menu to prevent a GUI desktop port from being started:
>>
>> 1. Back to Main Menu [Backspace]
>> 2. Load System Defaults
>>
>> Boot Options:
>> 3. Safe Mode... Off
>> 4. Single User. Off
>> 5. Verbose..... off
>> 6. Console..... off
>>
>>
>> When set to "On", a kernel environment variable "boot_console" is set to
>> "YES"; else "boot_console" is unset. A GUI desktop startup script in
>> ${LOCALBASE}/etc/rc.d/ should read this variable and, if set, should
>>
>> * Ignore a command to start the GUI
>> * Unset "boot_console" (this allows one to manually start the GUI
>> after initial boot).
>>
>> I'm open to suggestions about semantics to make this functionality
>> clearer (e.g. "Console..... On" is not intuitive).
>>
>> The problem I have is in the GUI startup scripts, which must be modified
>> to make this work. What I *want* is to make a *simple* modification to
>> all GUI startup scripts (e.g. ${LOCALBASE}/etc/rc.d/kdm4) such that
>> /etc/rc knows what scripts are "GUI startup scripts" and, if
>> $boot_console is set, performs the above 2 actions. Right now, for me
>> to make this patch work, I have to add code to my kdm4 startup script to
>> do this, which would be ugly to add to every GUI startup script in ports.
>>
>> Maybe one of the following would be simple/general enough to work:
>>
>> * Have each GUI startup script declare a variable, e.g. "gui_startup",
>> which /etc/rc reads to determine whether to disable its startup if
>> $boot_console is set.
>> * Have an rc.conf(5) variable "gui_startup_scripts" which holds a list
>> of startup scripts to not execute if $boot_console is set.
>> * Have each GUI startup script REQUIRE (i.e. rcorder(8))
>> "gui_start_check" which fails if $boot_console is set.
>>
>> GUI desktop port maintainers would have to modify their respective ports
>> to implement option 1 & 3; the user would have to add her desktop to
>> /etc/rc.conf for option 2. I'd implement the guts.
>>
>> Other suggestions welcome.
>>
>> https://github.com/ScoobiFreeBSD/freebsd/commit/2376fc13627db10a65bcab9d9091cbd8ff049e87
>> https://github.com/ScoobiFreeBSD/freebsd/commit/2376fc13627db10a65bcab9d9091cbd8ff049e87.patch
>>
> I think I prefer the 3rd option, having a dependant service that is
> controlled by the variable from the boot loader. This minimizes the
> changes to each port to just a single word added to the metadata.
>
> If the ports people want to decide which method they prefer, I would be
> happy to shepherd the changes to the boot loader / menu itself.
The 3rd option turned out to be ridiculously simple using rcorder(8)'s
KEYWORD tag and /etc/rc's skipping of certain scripts.
[ajenkins at ajenkins-hplaptop /usr/src]$ git diff 'HEAD^!'
diff --git a/etc/rc b/etc/rc
index 576ddf9..33ff6b2 100644
--- a/etc/rc
+++ b/etc/rc
@@ -84,6 +84,12 @@ if [ `/sbin/sysctl -n security.jail.jailed` -eq 1
]; then
fi
fi
+# If boot_console is enabled from loader(8), skip all rc.d scripts that
+# are marked with KEYWORD "gui".
+if [ "$(kenv boot_console 2>/dev/null)" = "YES" ]; then
+ skip="${skip} -s gui"
+fi
+
# If the firstboot sentinel doesn't exist, we want to skip
firstboot scripts.
if ! [ -e ${firstboot_sentinel} ]; then
skip_firstboot="-s firstboot"
Now all GUI port maintainers have to do is add "gui" to the KEYWORD tag
in their rc.d scripts.
[ajenkins at ajenkins-hplaptop /usr/ports]$ git diff
diff --git a/x11/kde4-workspace/files/kdm4.in
b/x11/kde4-workspace/files/kdm4.in
index 278ff62..6bd96cf 100644
--- a/x11/kde4-workspace/files/kdm4.in
+++ b/x11/kde4-workspace/files/kdm4.in
@@ -4,7 +4,7 @@
#
# PROVIDE: kdm4
# REQUIRE: LOGIN cleanvar moused syscons dbus hald
-# KEYWORD: shutdown
+# KEYWORD: shutdown gui
#
# Add the following to /etc/rc.conf to start KDM at boot time:
#
Now just need to sort out the wording of the option.
Anthony
More information about the freebsd-x11
mailing list