diff sbin/fjail @ 223:dce9ba905c32

Propose settings for host.hostuuid and host.hostid when configuring jails
author Franz Glasner <f.glasner@feldmann-mg.com>
date Wed, 31 Aug 2022 12:55:51 +0200
parents 16238e9032a9
children 6713d97b4180
line wrap: on
line diff
--- a/sbin/fjail	Wed Aug 31 12:41:18 2022 +0200
+++ b/sbin/fjail	Wed Aug 31 12:55:51 2022 +0200
@@ -331,6 +331,7 @@
 command_configure() {
     # mountpoint
     local _mp
+    local _new_hostuuid _new_hostid
 
     _mp="$1"
 
@@ -356,11 +357,29 @@
     if [ ! -f "${_mp}/etc/localtime" ]; then
         echo "Setting timezone to Europe/Berlin"
         ln -s ../usr/share/zoneinfo/Europe/Berlin "${_mp}/etc/localtime"
+        echo "Europe/Berlin" > "${_mp}/var/db/zoneinfo"
     else
         echo "WARNING: \"${_mp}/etc/localtime\" exists already -- not changed"
     fi
 
-    # XXX FIXME What about hostid in vnet jails (see /etc/rc.d/hostid and /etc/rc.d/hostid_save)
+    #
+    # hostid and hostuuid should be set (at least for consistency ressons)
+    # in vnet jails (see /etc/rc.d/hostid and /etc/rc.d/hostid_save).
+    # They can be set in the jail.conf.
+    # Print one here that can be pasted into the jail.conf if needed.
+    #
+    # hostid and hostuuid for non-vnet jails are inherited from the parent/host.
+    #
+    # See also /etc/rc.d/hostid and /etc/rc.d/hostid_save.
+    #
+    _new_hostuuid="$(uuidgen)"
+    _new_hostid="$(echo -n ${_new_hostuuid} | /sbin/md5)"
+    _new_hostid="0x${_new_hostid%%????????????????????????}"
+
+    echo "Proposed hostuuid/hostid:"
+    echo "  host.hostuuid = \"${_new_hostuuid}\";"
+    echo "  host.hostid = $((_new_hostid));"
+    #echo "  host.hostid = ${_new_hostid};"
 }