comparison sbin/fjail @ 226:73f2436fdf86

Make "hostid" a separate command for printint hostid proposals
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 01 Sep 2022 09:32:03 +0200
parents ffd24013d346
children a7a9fd895d30
comparison
equal deleted inserted replaced
225:ffd24013d346 226:73f2436fdf86
66 66
67 configure MOUNPOINT 67 configure MOUNPOINT
68 68
69 Configure some basic parts of the system at MOUNTPOINT: 69 Configure some basic parts of the system at MOUNTPOINT:
70 disable root password, syslog and other basic configuration settings 70 disable root password, syslog and other basic configuration settings
71
72 hostid
73
74 Print proposals for a hostuuid and hostid
71 75
72 copy [OPTIONS] SOURCE-DATASET DEST-DATASET 76 copy [OPTIONS] SOURCE-DATASET DEST-DATASET
73 77
74 Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive". 78 Copy a tree of ZFS datasets with "zfs send -R" and "zfs receive".
75 Note that the destination dataset must not exist already. 79 Note that the destination dataset must not exist already.
322 find "${_mp}/boot" -type f -delete 326 find "${_mp}/boot" -type f -delete
323 } 327 }
324 328
325 329
326 # 330 #
331 # "hostid" -- print a proposal for hostid/hostuuid settings in a jail
332 #
333 # command_hostid
334 #
335 command_hostid() {
336 #
337 # hostid and hostuuid should be set (at least for consistency ressons)
338 # in vnet jails (see /etc/rc.d/hostid and /etc/rc.d/hostid_save).
339 # They can be set in the jail.conf.
340 # Print one here that can be pasted into the jail.conf if needed.
341 #
342 # hostid and hostuuid for non-vnet jails are inherited from the parent/host.
343 #
344 # See also /etc/rc.d/hostid and /etc/rc.d/hostid_save.
345 #
346 local _new_hostuuid _new_hostid
347 _new_hostuuid="$(uuidgen)"
348 _new_hostid="$(echo -n ${_new_hostuuid} | /sbin/md5)"
349 _new_hostid="0x${_new_hostid%%????????????????????????}"
350
351 echo "Proposed hostuuid/hostid:"
352 echo " host.hostuuid = \"${_new_hostuuid}\";"
353 echo " host.hostid = $((_new_hostid));"
354 #echo " host.hostid = ${_new_hostid};"
355 }
356
357
358 #
327 # "configure" -- configure the mountpoint 359 # "configure" -- configure the mountpoint
328 # 360 #
329 # command_configure mountpoint 361 # command_configure mountpoint
330 # 362 #
331 command_configure() { 363 command_configure() {
332 # mountpoint 364 # mountpoint
333 local _mp 365 local _mp
334 local _new_hostuuid _new_hostid
335 366
336 _mp="$1" 367 _mp="$1"
337 368
338 if [ -z "${_mp}" ]; then 369 if [ -z "${_mp}" ]; then
339 echo "ERROR: no mountpoint given" >&2 370 echo "ERROR: no mountpoint given" >&2
371 fi 402 fi
372 403
373 # Call newaliases within the jail 404 # Call newaliases within the jail
374 chroot "${_mp}" /usr/bin/newaliases 405 chroot "${_mp}" /usr/bin/newaliases
375 406
376 # 407 command_hostid
377 # hostid and hostuuid should be set (at least for consistency ressons)
378 # in vnet jails (see /etc/rc.d/hostid and /etc/rc.d/hostid_save).
379 # They can be set in the jail.conf.
380 # Print one here that can be pasted into the jail.conf if needed.
381 #
382 # hostid and hostuuid for non-vnet jails are inherited from the parent/host.
383 #
384 # See also /etc/rc.d/hostid and /etc/rc.d/hostid_save.
385 #
386 _new_hostuuid="$(uuidgen)"
387 _new_hostid="$(echo -n ${_new_hostuuid} | /sbin/md5)"
388 _new_hostid="0x${_new_hostid%%????????????????????????}"
389
390 echo "Proposed hostuuid/hostid:"
391 echo " host.hostuuid = \"${_new_hostuuid}\";"
392 echo " host.hostid = $((_new_hostid));"
393 #echo " host.hostid = ${_new_hostid};"
394 } 408 }
395 409
396 410
397 # 411 #
398 # "copy" -- ZFS copy of datasets 412 # "copy" -- ZFS copy of datasets
698 command_populate "$@" 712 command_populate "$@"
699 ;; 713 ;;
700 configure) 714 configure)
701 command_configure "$@" 715 command_configure "$@"
702 ;; 716 ;;
717 hostid)
718 command_hostid "$@"
719 ;;
703 copy) 720 copy)
704 command_copy "$@" 721 command_copy "$@"
705 ;; 722 ;;
706 *) 723 *)
707 echo "ERROR: unknown command \`${command}'" >&2 724 echo "ERROR: unknown command \`${command}'" >&2