From owner-freebsd-x11@freebsd.org  Sat Sep  3 12:41:42 2016
Return-Path: <owner-freebsd-x11@freebsd.org>
Delivered-To: freebsd-x11@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90926BCEE55
 for <freebsd-x11@mailman.ysv.freebsd.org>;
 Sat,  3 Sep 2016 12:41:42 +0000 (UTC)
 (envelope-from Scoobi_doo@yahoo.com)
Received: from nm9-vm0.bullet.mail.bf1.yahoo.com
 (nm9-vm0.bullet.mail.bf1.yahoo.com [98.139.213.154])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 57F58D6D
 for <freebsd-x11@freebsd.org>; Sat,  3 Sep 2016 12:41:42 +0000 (UTC)
 (envelope-from Scoobi_doo@yahoo.com)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1472906495; bh=xSP1tY4j6h8Oe5G7lxyxWQhO/OLAJcvgONM51oibZJA=;
 h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject;
 b=DWjaptNhbGa62e1HlgSezGT1Ou/aiCKsRFoFbCEPdLa6R/g1SpkiuOxJtlVetEXeT5kRNOpKlRb+uQx56PvGoIHXmByp0wljEFWFNz+T6esXk1Hgwh/u8u0PX/nA/GL/5x3VHfX19JwXB5+3rhenKFBpX1JxoJa07lRWBsa3p3YrkjfnKqTV8lu1mgVbrG+l92GL8MasZ0F/rXS8L922412CG39a/ejTQKdKRW0+rZb6G7FI/pWM5CjdsQ/PxCjyRQAUmz1XOGGXIf21dqKfrofhY3558SPijRWpMBD2ZxY5ze6bISwEEilrbwlpDIPNio0XdvP8881TsfAsoEt3zA==
Received: from [98.139.170.180] by nm9.bullet.mail.bf1.yahoo.com with NNFMP;
 03 Sep 2016 12:41:35 -0000
Received: from [98.139.211.205] by tm23.bullet.mail.bf1.yahoo.com with NNFMP;
 03 Sep 2016 12:41:35 -0000
Received: from [127.0.0.1] by smtp214.mail.bf1.yahoo.com with NNFMP;
 03 Sep 2016 12:41:35 -0000
X-Yahoo-Newman-Id: 751117.64675.bm@smtp214.mail.bf1.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: Ve8NvJoVM1mFq377q_To0vse82RBCSinNP91dXVpuWnsI0_
 ED9tBGlIjoYVwvdtfG.aoC8aszLPgImPseN.tggwcCV7NKZdN3Zd5KshK_X9
 MG1cwdxrNGdevORRN_k_qXC3ZmFA5qnk6CAy64n06XN0en7xXrslae4Fxt4C
 RP.JINf0SLE98hHG3xDi3udTpK9F1iBk8KnuxnIZD0Zk428xs9JuC2AMrJHc
 S3CZEOlUtsJkh4fqUrYycuy.PsFwi.FfIF876jQy8a8oGo4uiNQzjvyvdH0x
 EbfRI2ZjecDJSvjd1M3xxjtEpE5aIQFGIVwIoX7th45qCny_aL7AxGOmpyXP
 PA81ewBk1afgm1WgCG31CVFsg2JKdT6zKzhwATiftRqNfMxs.gAu6AgjyWko
 tVjvKxrFUVak40Hc.2JwN0FmfgMe3gzN7wLf3W8J8FXiQy3Q_zO8MEGFjfwn
 HsXJEeUD78ZwFqdzQ_lDlqRZNL1x.H7OmY6nn3sJ4sMAB35AKw9XuaSl9nes
 FWoNWehdGkR7AJsHzNpepmisZU9OQ7g0SgPML3qHfkCYW5CU-
X-Yahoo-SMTP: 9sPoSQ2swBBlERuQ.0vs8XLc_MeClW0-
Subject: Re: Fwd: Console only boot option
To: Allan Jude <allanjude@freebsd.org>, freebsd-x11@freebsd.org
References: <e48d3b7a-f2ac-3d12-56a4-b907a36ac099@yahoo.com>
 <01000156e712dd33-54873391-f056-4e0a-bf9e-b23a2053a412-000000@email.amazonses.com>
 <52049264-cc66-b244-c6eb-fa99f2a236fd@freebsd.org>
Cc: Colin Percival <cperciva@tarsnap.com>
From: Anthony Jenkins <Scoobi_doo@yahoo.com>
Message-ID: <1df8b031-db27-5a72-02e1-a7b913772e66@yahoo.com>
Date: Sat, 3 Sep 2016 08:41:33 -0400
User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.1
MIME-Version: 1.0
In-Reply-To: <52049264-cc66-b244-c6eb-fa99f2a236fd@freebsd.org>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-BeenThere: freebsd-x11@freebsd.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: X11 on FreeBSD -- maintaining and support <freebsd-x11.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-x11>,
 <mailto:freebsd-x11-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-x11/>
List-Post: <mailto:freebsd-x11@freebsd.org>
List-Help: <mailto:freebsd-x11-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-x11>,
 <mailto:freebsd-x11-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 03 Sep 2016 12:41:42 -0000

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@freebsd.org>
>> Reply-To: Anthony Jenkins <Scoobi_doo@yahoo.com>
>> To: freebsd-x11@freebsd.org <freebsd-x11@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@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@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