home · contact · privacy
Fix.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 15 Apr 2025 22:33:01 +0000 (00:33 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 15 Apr 2025 22:33:01 +0000 (00:33 +0200)
bookworm/scripts/lib/mkdir_p_print_top [new file with mode: 0644]
bookworm/scripts/lib/setup_users
bookworm/scripts/setup_catgirl.sh
testing/scripts/lib/mkdir_p_print_top [new symlink]
testing/scripts/setup_desktop.sh

diff --git a/bookworm/scripts/lib/mkdir_p_print_top b/bookworm/scripts/lib/mkdir_p_print_top
new file mode 100644 (file)
index 0000000..b88d63a
--- /dev/null
@@ -0,0 +1,10 @@
+mkdir_p_print_top() {
+    _TO_SHORTEN=$(mkdir -pv "$1" | sed "s/mkdir: created directory '//g" | head -1)
+    if [ -z "${_TO_SHORTEN}" ]; then
+        echo ''
+    else
+        _LENGTH=$(echo -n "${_TO_SHORTEN}" | wc -c)"
+        _TARGET_LENGTH=$(calc "${_LENGTH} - 1" | cut -f2)
+        echo "${_TO_SHORTEN}" | cut -c "-${_TARGET_LENGTH}"
+    fi
+}
index 236a829dc736c8d8133b041598d024142e66c54a..83488d6d43b1b5dddf1385f7148b4f61acee5e82 100644 (file)
@@ -2,6 +2,7 @@
 . lib/copy_dirtree
 . lib/constants_user  # PATH_USER_HOME, USERNAME
 . lib/ensure_homefiles_of_tags
+. lib/mkdir_p_print_top
 
 setup_users() {
     _MIN_TAGS="$1"
@@ -17,7 +18,7 @@ setup_users() {
     usermod -a -G sudo "${USERNAME}"
     ensure_homefiles_of_tags ${_MIN_TAGS} ${_TAGS_USER}
     copy_dirtree "${_PATH_CONF_HOME}" "${PATH_USER_HOME}" ${_MIN_TAGS} ${_TAGS_USER}
-    _TO_CHOWN=$(mkdir -pv "${_PATH_USER_BIN}" | sed 's/mkdir: created directory //g' | head -1)
+    _TO_CHOWN=$(mkdir_p_print_top "${_PATH_USER_BIN}")
     cd "${_PATH_USER_BIN}"
     ln -s ../../.plomlib lib
     chown_to_user "${_TO_CHOWN}"
index de96083220f7b1908f480790d654b2f35c9c2e8e..c70655b1aa220170a41257441e688b9ad5b1cb66 100755 (executable)
@@ -9,6 +9,7 @@ cd $(dirname "$0")
 . lib/ensure_homefiles_of_tags
 . lib/ensure_packages_of_tags
 . lib/expect_n_args
+. lib/mkdir_p_print_top
 
 check_finished_marker 'setup_server'
 expect_n_args 1 1 'IRC_PASSWORD' $@
@@ -22,7 +23,7 @@ ensure_etc_of_tags catgirl
 ensure_homefiles_of_tags catgirl
 
 echo "\nSetting up ${PATH_USER_SHARE_CATGIRL} so logs can go there."
-TO_CHOWN=$(mkdir -pv "${PATH_USER_SHARE_CATGIRL}" | sed 's/mkdir: created directory //g' | head -1)
+TO_CHOWN=$(mkdir_p_print_top "${PATH_USER_SHARE_CATGIRL}")
 chown_to_user "${TO_CHOWN}"
 
 echo "\nWriting provided password into ${PATH_USER_CONF_CATGIRL}."
diff --git a/testing/scripts/lib/mkdir_p_print_top b/testing/scripts/lib/mkdir_p_print_top
new file mode 120000 (symlink)
index 0000000..ab3ae3b
--- /dev/null
@@ -0,0 +1 @@
+../../../bookworm/scripts/lib/mkdir_p_print_top
\ No newline at end of file
index f5f184e8b5b6dc721446a2d3045e913023c66aae..ea3895d09788ddb5def4ee929fdc8b43c5a2c525 100755 (executable)
@@ -7,6 +7,7 @@ cd $(dirname "$0")
 . lib/constants_repopaths  # PATH_CONF
 . lib/constants_user  # USERNAME
 . lib/determine_ip
+. lib/ensure_etc_of_tags
 . lib/expect_min_n_args
 . lib/init_packages
 . lib/put_finished_marker