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

From: zimoun <[email-masked]>
Date: Sat, 3 Oct 2020 20:44:47 +0200

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(-)

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 "$@"
-- 
2.28.0