From 329f2a2c4c73db7625fdbd27f629639d15b852ae Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 01:02:44 +0000
Subject: [PATCH] test and bugfix

---
 examples/archlinux-gnome/conf.d/basic.sh   | 11 ++++++-----
 examples/archlinux-gnome/conf.d/desktop.sh |  2 +-
 examples/archlinux-gnome/linuxconf.wrapper |  3 ++-
 linuxconf                                  |  8 ++++----
 test.sh                                    | 16 ++++++++++++++++
 5 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100644 test.sh

diff --git a/examples/archlinux-gnome/conf.d/basic.sh b/examples/archlinux-gnome/conf.d/basic.sh
index 1c8e83f..3201482 100644
--- a/examples/archlinux-gnome/conf.d/basic.sh
+++ b/examples/archlinux-gnome/conf.d/basic.sh
@@ -21,21 +21,22 @@ XMODIFIERS=@im=fcitx5' > /etc/environment
 
 lc_init () {
     # my favorite pkgs
-    pacman -Sy --noconfirm fish dhcpcd vim sudo openssh
-    pacman -Sy --noconfirm --asdeps openssl
+    pacman -Syu --noconfirm
+    pacman -S --noconfirm fish dhcpcd vim sudo openssh
+    pacman -S --noconfirm --asdeps openssl
 
-    # add primary user
+    # add primary user. If you want to do this, at least give read access to linuxconf dir.
     useradd --create-home --shell /usr/bin/fish rtest
     echo 'rtest ALL=(ALL) NOPASSWD: ALL' | EDITOR='tee -a' visudo
     usermod --password $(echo testpass | openssl passwd -1 -stdin) rtest
 
     if ! sudo -u rtest realpath masterconf.sh; then
-        echo "ERROR: rtest do not have access to current dir... fix permission and manually register with 'sudo -u rtest'."
+        echo "ERROR: rtest do not have read access to current dir... fix permission and manually register with 'sudo -u rtest'."
     else
         sudo -u rtest linuxconf register masterconf.sh
     fi
 
-    # more customization...
+    # more one-time customization
     grep kernel.sysrq=1 /etc/sysctl.d/99-sysctl.conf || echo 'kernel.sysrq=1' >> /etc/sysctl.d/99-sysctl.conf
 
     grep recolic-aur /etc/pacman.conf || echo '[recolic-aur]
diff --git a/examples/archlinux-gnome/conf.d/desktop.sh b/examples/archlinux-gnome/conf.d/desktop.sh
index 3bbeff0..c1a6be6 100644
--- a/examples/archlinux-gnome/conf.d/desktop.sh
+++ b/examples/archlinux-gnome/conf.d/desktop.sh
@@ -45,7 +45,7 @@ user_pref("browser.tabs.hoverPreview.enabled", false);'
         [[ -d "$dir" ]] && echo "$firefox_config" > "$dir/user.js"
     done
 
-    [[ -f /usr/bin/az ]] && az config set core.login_experience_v2=off
+    [[ -f /usr/bin/az ]] && az config set core.login_experience_v2=off || true
 }
 
 lc_login () {
diff --git a/examples/archlinux-gnome/linuxconf.wrapper b/examples/archlinux-gnome/linuxconf.wrapper
index e1cadf4..fd4dee5 100755
--- a/examples/archlinux-gnome/linuxconf.wrapper
+++ b/examples/archlinux-gnome/linuxconf.wrapper
@@ -1,7 +1,8 @@
 #!/bin/bash
 
 if [ ! -f /usr/bin/linuxconf ]; then
-    curl "https://git.recolic.net/root/linuxconf/-/raw/master/linuxconf?ref_type=heads" -o /usr/bin/linuxconf ||
+    # curl "https://git.recolic.net/root/linuxconf/-/raw/master/linuxconf?ref_type=heads" -o /usr/bin/linuxconf ||
+    curl "https://recolic.cc/tmp/linuxconf" -o /usr/bin/linuxconf ||
         ! echo "Unable to download linuxconf executable." || exit 1
     chmod +x /usr/bin/linuxconf
 fi
diff --git a/linuxconf b/linuxconf
index d9e805a..3998794 100755
--- a/linuxconf
+++ b/linuxconf
@@ -13,10 +13,10 @@ function die () {
 }
 
 function lc_assert_user_is () {
-    [[ "$(whoami)" = "$1" ]] || exit 2
+    [[ "$(whoami)" = "$1" ]] || exit 0
 }
 function lc_assert_user_is_not () {
-    [[ "$(whoami)" != "$1" ]] || exit 2
+    [[ "$(whoami)" != "$1" ]] || exit 0
 }
 
 function lc_include () {
@@ -32,7 +32,7 @@ function lc_include () {
             eval "$LCI_SUBSHELL_OP"
         )
         echo2 "$script -- $LCI_SUBSHELL_OP completed with status $?"
-        # TODO: should I abort on failure? But for nested lc_include, I cannot know if it failed.
+        # TODO: should I abort on failure? It will stop running other include files. Don't do it now.
     done
 
     return 0
@@ -223,7 +223,7 @@ function lci_install_login_hook () {
     fi
 }
 
-lci_version=0.1.1
+lci_version=0.2.0
 subcommand="$1"
 if [[ "$subcommand" != register ]] && [[ "$subcommand" != "" ]]; then
     [[ ! -f /etc/linuxconf.conf ]] && die "Please run '$0 register <path/to/masterconf.sh>' at least once"
diff --git a/test.sh b/test.sh
new file mode 100644
index 0000000..f69a6d7
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,16 @@
+set -e
+tar -cvzf /tmp/test.tgz examples
+netpush /tmp/test.tgz
+
+echo "
+TODO:
+rm /mnt/fsdisk/svm/vm/archtest/ -r
+pgkill archtest
+
+ssh -p 30476  r@hms.r
+
+sudo su
+
+cd /
+curl https://recolic.cc/tmp/test.tgz | tar xvzf -
+"
-- 
GitLab