Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/ftjail @ 308:2102b46566f0
Implement "ftjail build-etcupdate-curent-tmpl".
This allows to build a current tree suitable for using with etcupdate's default
and extract modes: allow updating a system without having a corresponding
source tree.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 23 Sep 2022 00:37:33 +0200 |
| parents | 23bcbbbd99ea |
| children | 8dbd11726ee5 |
comparison
equal
deleted
inserted
replaced
| 307:23bcbbbd99ea | 308:2102b46566f0 |
|---|---|
| 39 populate-tmpl -L|-P DIRECTORY BASETXZ | 39 populate-tmpl -L|-P DIRECTORY BASETXZ |
| 40 | 40 |
| 41 snapshot-tmpl BASE-RO SKELETON-RW SNAPSHOT-NAME | 41 snapshot-tmpl BASE-RO SKELETON-RW SNAPSHOT-NAME |
| 42 | 42 |
| 43 copy-skel [-A] [-L] [-M MOUNTPOINT] [-P] [-u] SOURCE-DS SNAPSHOT-NAME TARGET-DS | 43 copy-skel [-A] [-L] [-M MOUNTPOINT] [-P] [-u] SOURCE-DS SNAPSHOT-NAME TARGET-DS |
| 44 | |
| 45 build-etcupdate-current-tmpl DIRECTORY TARBALL | |
| 44 | 46 |
| 45 ENVIRONMENT: | 47 ENVIRONMENT: |
| 46 | 48 |
| 47 All environment variables that affect "zfs" are effective also. | 49 All environment variables that affect "zfs" are effective also. |
| 48 | 50 |
| 763 echo "Destroying unneeded snapshots ..." | 765 echo "Destroying unneeded snapshots ..." |
| 764 zfs destroy -rv "${_ds_target}@${_snapshot_name}" | 766 zfs destroy -rv "${_ds_target}@${_snapshot_name}" |
| 765 } | 767 } |
| 766 | 768 |
| 767 | 769 |
| 770 #: | |
| 771 #: Implement the "build-etcupdate-current-tmpl" command | |
| 772 #: | |
| 773 command_build_etcupdate_current_tmpl() { | |
| 774 local _directory _tarball | |
| 775 | |
| 776 _directory="${1-}" | |
| 777 _tarball="${2-}" | |
| 778 | |
| 779 [ -z "${_directory}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } | |
| 780 [ -z "${_tarball}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } | |
| 781 [ -e "${_tarball}" ] && { echo "ERROR: \`${_tarball}' exists already" 1>&2; return 1; } | |
| 782 | |
| 783 if ! tar -cjf "${_tarball}" -C "${_directory}/var/db/etcupdate/current" . ; then | |
| 784 rm -f "${_tarball}" || true | |
| 785 return 1 | |
| 786 fi | |
| 787 } | |
| 788 | |
| 789 | |
| 768 # | 790 # |
| 769 # Global option handling | 791 # Global option handling |
| 770 # | 792 # |
| 771 while getopts "Vh" _opt ; do | 793 while getopts "Vh" _opt ; do |
| 772 case ${_opt} in | 794 case ${_opt} in |
| 820 command_snapshot_tmpl "$@" | 842 command_snapshot_tmpl "$@" |
| 821 ;; | 843 ;; |
| 822 copy-skel) | 844 copy-skel) |
| 823 command_copy_skel "$@" | 845 command_copy_skel "$@" |
| 824 ;; | 846 ;; |
| 847 build-etcupdate-current-tmpl) | |
| 848 command_build_etcupdate_current_tmpl "$@" | |
| 849 ;; | |
| 825 configure) | 850 configure) |
| 826 echo "ERROR: use \`fjail configure' instead" 1>&2; | 851 echo "ERROR: use \`fjail configure' instead" 1>&2; |
| 827 exit 2 | 852 exit 2 |
| 828 ;; | 853 ;; |
| 829 *) | 854 *) |
