# HG changeset patch # User Franz Glasner # Date 1662017523 -7200 # Node ID 73f2436fdf869fcef41e1c78c7aa68afd1968385 # Parent ffd24013d3466877a11bc5df99b2baaeafacdb97 Make "hostid" a separate command for printint hostid proposals diff -r ffd24013d346 -r 73f2436fdf86 sbin/fjail --- a/sbin/fjail Wed Aug 31 13:04:25 2022 +0200 +++ b/sbin/fjail Thu Sep 01 09:32:03 2022 +0200 @@ -69,6 +69,10 @@ Configure some basic parts of the system at MOUNTPOINT: disable root password, syslog and other basic configuration settings + hostid + + Print proposals for a hostuuid and hostid + copy [OPTIONS] SOURCE-DATASET DEST-DATASET Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". @@ -324,6 +328,34 @@ # +# "hostid" -- print a proposal for hostid/hostuuid settings in a jail +# +# command_hostid +# +command_hostid() { + # + # 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. + # + local _new_hostuuid _new_hostid + _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};" +} + + +# # "configure" -- configure the mountpoint # # command_configure mountpoint @@ -331,7 +363,6 @@ command_configure() { # mountpoint local _mp - local _new_hostuuid _new_hostid _mp="$1" @@ -373,24 +404,7 @@ # Call newaliases within the jail chroot "${_mp}" /usr/bin/newaliases - # - # 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};" + command_hostid } @@ -700,6 +714,9 @@ configure) command_configure "$@" ;; + hostid) + command_hostid "$@" + ;; copy) command_copy "$@" ;;