diff mbox series

[bug#43769,v2,2/2] guix-install.sh: Check the service 'nscd' and suggest it.

Message ID 20201003184447.9542-2-zimon.toutoune@gmail.com
State Accepted
Headers show
Series [bug#43769,v2,1/2] guix-install.sh: Add symbolic links for supported shell completions. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/applying patch fail View Laminar job

Commit Message

Simon Tournier Oct. 3, 2020, 6:44 p.m. UTC
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (chk_sys_nscd): New function to check if the service
'nscd is running, otherwise suggest to install distribution-wide.
---
 etc/guix-install.sh | 66 ++++++++++++++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 25 deletions(-)

Comments

ashish.is--- via Guix-patches" via Oct. 3, 2020, 7:14 p.m. UTC | #1
Zimoun,

zimoun 写道:
> * etc/guix-install.sh (chk_sys_nscd): New function to check if 
> the service
> 'nscd is running, otherwise suggest to install 
> distribution-wide.

If we must have a new interactive prompt in this series, this 
seems like the better place: we know enough about the host (init) 
system to auto-enable nscd on most of them, if the user so wishes.

>  main()
>  {
> -    local tmp_path
> -    welcome
> +    # local tmp_path
> +    # welcome
> +
> +    # _msg "Starting installation ($(date))"
>  
> -    _msg "Starting installation ($(date))"
> +    # chk_term
> +    # chk_require "${REQUIRE[@]}"
> +    # chk_gpg_keyring
> +    # chk_init_sys
> +    # chk_sys_arch
>  
> -    chk_term
> -    chk_require "${REQUIRE[@]}"
> -    chk_gpg_keyring
> -    chk_init_sys
> -    chk_sys_arch
> +    # _msg "${INF}system is ${ARCH_OS}"
>  
> -    _msg "${INF}system is ${ARCH_OS}"
> +    # umask 0022
> +    # tmp_path="$(mktemp -t -d guix.XXX)"
>  
> -    umask 0022
> -    tmp_path="$(mktemp -t -d guix.XXX)"
> +    # guix_get_bin_list "${GNU_URL}"
> +    # guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
>  
> -    guix_get_bin_list "${GNU_URL}"
> -    guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
> +    # sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
> +    # sys_create_build_user
> +    # sys_enable_guix_daemon
> +    # sys_authorize_build_farms
> +    # sys_create_init_profile
> +    # sys_create_shell_completion
>  
> -    sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
> -    sys_create_build_user
> -    sys_enable_guix_daemon
> -    sys_authorize_build_farms
> -    sys_create_init_profile
> -    sys_create_shell_completion
> +    # _msg "${INF}cleaning up ${tmp_path}"
> +    # rm -r "${tmp_path}"
>  
> -    _msg "${INF}cleaning up ${tmp_path}"
> -    rm -r "${tmp_path}"
> +    chk_sys_nscd
>  
> -    _msg "${PAS}Guix has successfully been installed!"
> -    _msg "${INF}Run 'info guix' to read the manual."
> +    # _msg "${PAS}Guix has successfully been installed!"
> +    # _msg "${INF}Run 'info guix' to read the manual."
>  
> -    # Required to source /etc/profile in desktop environments.
> -    _msg "${INF}Please log out and back in to complete the 
> installation."
> +    # # Required to source /etc/profile in desktop 
> environments.
> +    # _msg "${INF}Please log out and back in to complete the 
> installation."
>   }

?

Debugging left-overs?

Kind regards,

T G-R
Ludovic Courtès Oct. 5, 2020, 8:08 a.m. UTC | #2
Hi Tobias,

Tobias Geerinckx-Rice <me@tobias.gr> skribis:

> zimoun 写道:
>> * etc/guix-install.sh (chk_sys_nscd): New function to check if the
>> service
>> 'nscd is running, otherwise suggest to install distribution-wide.
>
> If we must have a new interactive prompt in this series, this seems
> like the better place: we know enough about the host (init) system to
> auto-enable nscd on most of them, if the user so wishes.

In practice, you enable nscd by running ‘apt install nscd’ or similar,
and I think we cannot guess what the right command is.  WDYT?

Thanks,
Ludo’.
Simon Tournier Oct. 5, 2020, 9:19 a.m. UTC | #3
On Mon, 5 Oct 2020 at 10:08, Ludovic Courtès <ludo@gnu.org> wrote:
> Tobias Geerinckx-Rice <me@tobias.gr> skribis:
>
> > zimoun 写道:
> >> * etc/guix-install.sh (chk_sys_nscd): New function to check if the
> >> service
> >> 'nscd is running, otherwise suggest to install distribution-wide.
> >
> > If we must have a new interactive prompt in this series, this seems
> > like the better place: we know enough about the host (init) system to
> > auto-enable nscd on most of them, if the user so wishes.
>
> In practice, you enable nscd by running ‘apt install nscd’ or similar,
> and I think we cannot guess what the right command is.  WDYT?

Yeah, I have tried in an unsent yet v3 to ask and then try to start
the service depending on the init system if nscd is not running.  And
if it fails, ask to install it.  That's the best we can do, IMHO.
Maybe it is over engineering and a simple INFO/WARN is enough.  WDYT?

All the best,
simon
ashish.is--- via Guix-patches" via Oct. 5, 2020, 12:28 p.m. UTC | #4
Ludo', Zimoun,

Ludovic Courtès 写道:
>> If we must have a new interactive prompt in this series, this 
>> seems
>> like the better place: we know enough about the host (init) 
>> system to
>> auto-enable nscd on most of them, if the user so wishes.
>
> In practice, you enable nscd by running ‘apt install nscd’ or 
> similar,
> and I think we cannot guess what the right command is.  WDYT?

I agree: I was under the assumption that nscd is commonly 
installed as part of the base OS, but disabled by default at the 
init system level.  If that's not likely to be true, don't let's 
bother.

Zimoun 写道:
> ask and then try to start the service depending on the init 
> system if nscd is not running

If the distro equivalent of ‘service start nscd’ works in the 
*common* case, I like it.  Otherwise a warning/suggestion to 
manually install & enable it is fine.

My general point was that guix-install.sh should do as much as it 
can with the information it already has ($INIT_SYS) and be 
consistent in using it, not that we start sniffing 
$LEGACY_PKG_MANAGER too :-)

Thanks for your work so far, Simon,

T G-R
Simon Tournier Oct. 13, 2020, 4:45 p.m. UTC | #5
>> In practice, you enable nscd by running ‘apt install nscd’ or similar,
>> and I think we cannot guess what the right command is.  WDYT?
>
> I agree: I was under the assumption that nscd is commonly installed as part of
> the base OS, but disabled by default at the init system level.  If that's not
> likely to be true, don't let's bother.

>> ask and then try to start the service depending on the init system if nscd
>> is not running
>
> If the distro equivalent of ‘service start nscd’ works in the *common* case, I
> like it.  Otherwise a warning/suggestion to manually install & enable it is
> fine.
>
> My general point was that guix-install.sh should do as much as it can with the
> information it already has ($INIT_SYS) and be consistent in using it, not that
> we start sniffing $LEGACY_PKG_MANAGER too :-)

As said, I have tried somehting like this uglyness… but it’s wrong!  It
is overcomplicated and if the package is installed, then it is highly
probable that is running.  I mean 2 kind of users:

 - the noob as me: “Please install nscd” and the I do “aptitude install
   nscd” and my distro takes care of everything (start it etc.)
   
 - the control-freak: they knows what to do with the message “Please
   install nscd”.

And we can try to guess the distro… but again it is overcomplicated.


So it’s not useful.  A message is enough.  Please give a look at v3.

Thanks,
simon

--8<---------------cut here---------------start------------->8---
sys_enable_nscd()
{ # Check if nscd is up and suggest to start it or install it
    flag=""
    if [ "$(type -P pidof)" ]; then
        if [ ! "$(pidof nscd)" ]; then
            _msg "${INF}We recommend installing and/or starting your distribution 'nscd' service"
            while true; do
                read -p "Permit to try starting your 'nscd' service? (yes/no) " yn
                case $yn in
                    [Yy]*) case "$INIT_SYS" in
                               upstart)
                                   { initctl reload-configuration;
                                     /etc/init/ &&
                                         start nscd; } &&
                                       _msg "${PAS}enabled 'nscd' service via upstart"
                                   ;;
                               systemd)
                                   if [ ( systemctl daemon-reload &&
                                              systemctl enable nscd &&
                                              systemctl start nscd; ) ]; then
                                       _msg "${PAS}enabled 'nscd' service via systemd";
                                   else
                                       flag=failure
                                   fi

                                   ;;
                               sysv-init)
                                   { update-rc.d nscd defaults &&
                                         update-rc.d nscd enable &&
                                         service nscd start; } &&
                                       _msg "${PAS}enabled 'nscd' service via sysv"
                                   ;;
                               openrc)
                                   { rc-update add nscd default &&
                                        rc-service nscd start; } &&
                                       _msg "${PAS}enabled 'nscd' service via OpenRC"
                                   ;;
                               NA|*)
                                   _msg "${ERR}unsupported init system; run the 'ncsd' service manually"
                                   ;;
                           esac;
                           break;;
                    [Nn]*) _msg "${INF}Skipped 'nscd' service"
                           flag=failure
                           break;;
                    *) _msg "Please answer yes or no.";
                esac
            done
        fi
    else
        _msg "${WAR}We cannot determine1 if your distribution 'nscd' service is running"
        failure=failure
    fi
    if [[ $flag == failure ]]; then
        _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
    fi
}
--8<---------------cut here---------------end--------------->8---
diff mbox series

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index a5da198eb0..5bda31de2e 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -55,6 +55,7 @@  REQUIRE=(
 
 PAS=$'[ \033[32;1mPASS\033[0m ] '
 ERR=$'[ \033[31;1mFAIL\033[0m ] '
+WAR=$'[ \033[33;1mWARN\033[0m ] '
 INF="[ INFO ] "
 
 DEBUG=0
@@ -200,6 +201,19 @@  chk_sys_arch()
     ARCH_OS="${arch}-${os}"
 }
 
+chk_sys_nscd()
+{ # Check if nscd is up and suggest to start it or install it
+    if [ "$(type -P pidof)" ]; then
+        if [ ! "$(pidof nscd)" ]; then
+            _msg "${WAR}We recommend installing and/or starting your distribution 'nscd' service"
+            _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+        fi
+    else
+        _msg "${INF}We cannot determine if your distribution 'nscd' service is running"
+        _msg "${INF}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+    fi
+}
+
 # ------------------------------------------------------------------------------
 #+MAIN
 
@@ -523,40 +537,42 @@  EOF
 
 main()
 {
-    local tmp_path
-    welcome
+    # local tmp_path
+    # welcome
+
+    # _msg "Starting installation ($(date))"
 
-    _msg "Starting installation ($(date))"
+    # chk_term
+    # chk_require "${REQUIRE[@]}"
+    # chk_gpg_keyring
+    # chk_init_sys
+    # chk_sys_arch
 
-    chk_term
-    chk_require "${REQUIRE[@]}"
-    chk_gpg_keyring
-    chk_init_sys
-    chk_sys_arch
+    # _msg "${INF}system is ${ARCH_OS}"
 
-    _msg "${INF}system is ${ARCH_OS}"
+    # umask 0022
+    # tmp_path="$(mktemp -t -d guix.XXX)"
 
-    umask 0022
-    tmp_path="$(mktemp -t -d guix.XXX)"
+    # guix_get_bin_list "${GNU_URL}"
+    # guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
 
-    guix_get_bin_list "${GNU_URL}"
-    guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
+    # sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
+    # sys_create_build_user
+    # sys_enable_guix_daemon
+    # sys_authorize_build_farms
+    # sys_create_init_profile
+    # sys_create_shell_completion
 
-    sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
-    sys_create_build_user
-    sys_enable_guix_daemon
-    sys_authorize_build_farms
-    sys_create_init_profile
-    sys_create_shell_completion
+    # _msg "${INF}cleaning up ${tmp_path}"
+    # rm -r "${tmp_path}"
 
-    _msg "${INF}cleaning up ${tmp_path}"
-    rm -r "${tmp_path}"
+    chk_sys_nscd
 
-    _msg "${PAS}Guix has successfully been installed!"
-    _msg "${INF}Run 'info guix' to read the manual."
+    # _msg "${PAS}Guix has successfully been installed!"
+    # _msg "${INF}Run 'info guix' to read the manual."
 
-    # Required to source /etc/profile in desktop environments.
-    _msg "${INF}Please log out and back in to complete the installation."
+    # # Required to source /etc/profile in desktop environments.
+    # _msg "${INF}Please log out and back in to complete the installation."
  }
 
 main "$@"