From ad676a1989f6399b1888656a58c7ab382355ad94 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 13:46:48 -0700
Subject: [PATCH 1/9] .

---
 README.md | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/README.md b/README.md
index 9dd4057..9e63ac4 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,7 @@ This project is to demonstrate a possibility to manage customization in a centra
 ## dependency
 
 coreutils bash grep sudo
+
+## TODO
+
+init order? what is one init depends on another?
-- 
GitLab


From 9790c79e01272aa706012059925520dea0a5347f Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 13:50:40 -0700
Subject: [PATCH 2/9] .

---
 examples/archlinux-gnome/conf.d/{basic.sh => 01_basic.sh}     | 0
 examples/archlinux-gnome/conf.d/{desktop.sh => 10_desktop.sh} | 0
 examples/archlinux-gnome/masterconf.sh                        | 2 +-
 examples/template/masterconf.sh                               | 1 +
 4 files changed, 2 insertions(+), 1 deletion(-)
 rename examples/archlinux-gnome/conf.d/{basic.sh => 01_basic.sh} (100%)
 rename examples/archlinux-gnome/conf.d/{desktop.sh => 10_desktop.sh} (100%)

diff --git a/examples/archlinux-gnome/conf.d/basic.sh b/examples/archlinux-gnome/conf.d/01_basic.sh
similarity index 100%
rename from examples/archlinux-gnome/conf.d/basic.sh
rename to examples/archlinux-gnome/conf.d/01_basic.sh
diff --git a/examples/archlinux-gnome/conf.d/desktop.sh b/examples/archlinux-gnome/conf.d/10_desktop.sh
similarity index 100%
rename from examples/archlinux-gnome/conf.d/desktop.sh
rename to examples/archlinux-gnome/conf.d/10_desktop.sh
diff --git a/examples/archlinux-gnome/masterconf.sh b/examples/archlinux-gnome/masterconf.sh
index 6486203..bf236a9 100644
--- a/examples/archlinux-gnome/masterconf.sh
+++ b/examples/archlinux-gnome/masterconf.sh
@@ -1,4 +1,4 @@
 # setup this linuxconf on fresh-installed archlinux
 
+# ordered by filename. Explicit order your files if u don't like.
 lc_include conf.d/*
-
diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index fe22038..b5e60c1 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -12,6 +12,7 @@
 #      > conf.d/basic.sh should install pkgs, (possibly) create new user, (possibly) run `linuxconf register .` again with new user.
 #
 
+# order by filename
 lc_include conf.d/*
 
 # If you have multiple user.. You might need this in your config file.
-- 
GitLab


From 55b1dbebc5a41fe4c25da6306551333fd0be0a1b Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 14:38:59 -0700
Subject: [PATCH 3/9] .

---
 examples/archlinux-gnome/conf.d/10_desktop.sh | 1 +
 examples/template/masterconf.sh               | 1 +
 2 files changed, 2 insertions(+)

diff --git a/examples/archlinux-gnome/conf.d/10_desktop.sh b/examples/archlinux-gnome/conf.d/10_desktop.sh
index ce27940..f589be1 100644
--- a/examples/archlinux-gnome/conf.d/10_desktop.sh
+++ b/examples/archlinux-gnome/conf.d/10_desktop.sh
@@ -1,5 +1,6 @@
 lc_assert_user_is_not root
 
+# okay to stay inside lc_init() or outside
 lc_fsmap files/config.fish $HOME/.config/fish/config.fish
 lc_fsmap files/ssh_config $HOME/.ssh/config
 lc_fsmap files/vimrc $HOME/.vimrc
diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index b5e60c1..ba69b68 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -55,6 +55,7 @@ function lc_cron () {
 }
 
 # Warning: watch out for unintended user
+# okay to stay inside lc_init() or outside
 lc_fsmap files/vimrc $LC_USER_HOME/.vimrc
 
 # TODO: what if lc_fsmap depends on lc_init() ?? This is not recommended usage. 
-- 
GitLab


From dab45800e9de336e64fe05851e1cbd1742c3b7c2 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 14:39:25 -0700
Subject: [PATCH 4/9] .

---
 examples/template/masterconf.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index ba69b68..bb5f6d2 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -54,9 +54,9 @@ function lc_cron () {
     
 }
 
-# Warning: watch out for unintended user
+# watch out! does your user have access?
 # okay to stay inside lc_init() or outside
-lc_fsmap files/vimrc $LC_USER_HOME/.vimrc
+lc_fsmap files/vimrc $HOME/.vimrc
 
 # TODO: what if lc_fsmap depends on lc_init() ?? This is not recommended usage. 
 # e.g: 'git clone xxx $HOME/sh' and lc_fsmap $HOME/sh/something /usr/bin/fancy
-- 
GitLab


From 29f9ce5595104054210424d2a3a721f1afa89f80 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 15:07:17 -0700
Subject: [PATCH 5/9] .example

---
 examples/template/masterconf.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index bb5f6d2..c8a6d16 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -37,7 +37,7 @@ function lc_startup () {
     
     # want some daemon in background?
     lcf_bgrun /tmp/server.log my_server --arg1 123 --arg2 "hello world !"
-    lcf_bgrun /tmp/server.log auto_restart important_service --gg "example"
+    lcf_bgrun /dev/null auto_restart important_service --gg "example"
 }
 
 function lc_login () {
-- 
GitLab


From 5b82ba8c687aedd091df4b3e3fca552e54885996 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 15:10:34 -0700
Subject: [PATCH 6/9] .example

---
 examples/template/masterconf.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index c8a6d16..9381719 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -20,7 +20,7 @@ lc_assert_user_is root
 lc_assert_user_is_not root
 
 # I strongly suggest u design lc_init() as an idempotent operation. Just in case u accidentally run `linuxconf register` elsewhere.
-function lc_init () {
+lc_init () {
     # as root / as user?
 
     # Some helpful functions.. To stop running current script:
@@ -31,7 +31,7 @@ function lc_init () {
     gsettings set var=123
 }
 
-function lc_startup () {
+lc_startup () {
     # as root / as user?
     # You want desktop env? Use lc_login()
     
@@ -40,17 +40,17 @@ function lc_startup () {
     lcf_bgrun /dev/null auto_restart important_service --gg "example"
 }
 
-function lc_login () {
+lc_login () {
     # Your desktop environment must implement "XDG autostart". Ref: https://wiki.archlinux.org/title/XDG_Autostart
     # Otherwise... Use lc_init to your task into wherever u'd like.
     #
     # Warning: Could be called multiple times if user logout/login again.
-    lc_login_is_x11?
 }
 
-function lc_cron () {
+lc_cron () {
     # hourly / daily / weekly / monthly?
     # as root / as user?
+    # TODO: not implemented yet!!!
     
 }
 
-- 
GitLab


From 482184028d197b8df7a23b4b2fc21596b01cb887 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 15:27:30 -0700
Subject: [PATCH 7/9] .example

---
 examples/template/files/test.conf | 1 +
 examples/template/masterconf.sh   | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 examples/template/files/test.conf

diff --git a/examples/template/files/test.conf b/examples/template/files/test.conf
new file mode 100644
index 0000000..be65677
--- /dev/null
+++ b/examples/template/files/test.conf
@@ -0,0 +1 @@
+example=conf
diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index 9381719..30014e7 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -37,7 +37,8 @@ lc_startup () {
     
     # want some daemon in background?
     lcf_bgrun /tmp/server.log my_server --arg1 123 --arg2 "hello world !"
-    lcf_bgrun /dev/null auto_restart important_service --gg "example"
+    # Guaranteed! linuxconf dir is your current workdir.
+    lcf_bgrun /dev/null auto_restart important_service --config files/test.conf
 }
 
 lc_login () {
-- 
GitLab


From 03c3b753d4ba5def9db9e7f38b91e47dbc63e3f9 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 15:28:37 -0700
Subject: [PATCH 8/9] .

---
 examples/template/files/vimrc   |  1 +
 examples/template/masterconf.sh | 15 ++-------------
 2 files changed, 3 insertions(+), 13 deletions(-)
 create mode 100644 examples/template/files/vimrc

diff --git a/examples/template/files/vimrc b/examples/template/files/vimrc
new file mode 100644
index 0000000..4c73139
--- /dev/null
+++ b/examples/template/files/vimrc
@@ -0,0 +1 @@
+example vimrc
diff --git a/examples/template/masterconf.sh b/examples/template/masterconf.sh
index 30014e7..c7bf86b 100644
--- a/examples/template/masterconf.sh
+++ b/examples/template/masterconf.sh
@@ -48,18 +48,7 @@ lc_login () {
     # Warning: Could be called multiple times if user logout/login again.
 }
 
-lc_cron () {
-    # hourly / daily / weekly / monthly?
-    # as root / as user?
-    # TODO: not implemented yet!!!
-    
-}
-
-# watch out! does your user have access?
-# okay to stay inside lc_init() or outside
+# watch out! does your user have access to target directory?
+# okay to stay inside lc_init() or outside, okay if files/vimrc doesn't exist yet.
 lc_fsmap files/vimrc $HOME/.vimrc
 
-# TODO: what if lc_fsmap depends on lc_init() ?? This is not recommended usage. 
-# e.g: 'git clone xxx $HOME/sh' and lc_fsmap $HOME/sh/something /usr/bin/fancy
-# lc_fsmap should success even if $HOME/sh/something doesn't exist yet. (what if dest also not exist? let it fail...)
-
-- 
GitLab


From 1db1deea31f73dcc1379376a5f14642c24ef1662 Mon Sep 17 00:00:00 2001
From: Recolic <git@me.recolic.net>
Date: Thu, 3 Apr 2025 16:08:07 -0700
Subject: [PATCH 9/9] .bugfix

---
 linuxconf | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/linuxconf b/linuxconf
index 49af2a0..8aba565 100755
--- a/linuxconf
+++ b/linuxconf
@@ -57,15 +57,21 @@ function lc_include () {
     return 0
 }
 
-function lci_fsmap () {
+function lc_fsmap () {
     # If existing symlink is correct, do nothing & return 0 (success).
     #   Otherwise, delete the existing symlink. 
     # If the existing item is file/folder, move to '$filename.linuxsync_backup'.
     # If target folder doesn't exist, create it.
     # Then create a symlink.
 
-    local content_path="$(realpath "$1")" || return $?
+    local content_path="$1"
     local symlink_path="$2"
+    
+    if [ ! -f "$content_path" ] && [[ "$content_path" == /* ]]; then
+        : # skip this specific failure case
+    else
+        content_path="$(realpath "$content_path")" || return $?
+    fi
 
     if [ -L "$symlink_path" ]; then
         if [ "$(readlink "$symlink_path")" = "$content_path" ]; then
@@ -82,13 +88,6 @@ function lci_fsmap () {
     ln -s "$content_path" "$symlink_path"
 }
 
-function lc_fsmap () {
-    lci_fsmap "$@"
-    local result=$?
-    [ $result = 0 ] || lcf_err "lc_fsmap returned error $result"
-    return $result
-}
-
 function lci_state_file_append () {
     local fname="$1"
     local prefix="$2"
-- 
GitLab