diff sbin/fjail @ 250:c4d835ccb4ae

Implement configure for symlinked skeletons. Automatically decide if "etc" is a symlink to "skeleton/etc".
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 11 Sep 2022 13:58:08 +0200
parents 243dba574ad3
children 7f21d242f79f
line wrap: on
line diff
--- a/sbin/fjail	Sun Sep 11 13:02:39 2022 +0200
+++ b/sbin/fjail	Sun Sep 11 13:58:08 2022 +0200
@@ -69,6 +69,9 @@
     Configure some basic parts of the system at MOUNTPOINT:
     disable root password, syslog and other basic configuration settings
 
+    Also handle thin jails by checking whether "etc" is a symlink to
+    "skeleton/etc".
+
    hostid
 
      Print proposals for a hostuuid and hostid
@@ -395,7 +398,12 @@
         # Timezone to CET
         if [ ! -f "${_mp}/etc/localtime" ]; then
             echo "Setting timezone to Europe/Berlin"
-            ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            # Handle thin jails automatically (but check expectations very strictly)
+            if [ \( -L "${_mp}/etc" \) -a \( "$(readlink "${_mp}/etc")" = "skeleton/etc" \) ]; then
+                ln -s ../../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            else
+                ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+            fi
             echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo"
         else
             echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed"