Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 339:e1d6807b0c4d
Implement option handling for ftjail freebsd-update and the "-k" option
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 02 Dec 2022 22:01:43 +0100 |
| parents | a423bc0e2a3f |
| children | d3b5fe2712ca |
| files | docs/man/man8/ftjail-freebsd-update.rst sbin/ftjail |
| diffstat | 2 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/man/man8/ftjail-freebsd-update.rst Fri Dec 02 21:29:26 2022 +0100 +++ b/docs/man/man8/ftjail-freebsd-update.rst Fri Dec 02 22:01:43 2022 +0100 @@ -20,6 +20,12 @@ .. program:: ftjail freebsd-update +.. option:: -k + + Keep all temporary files. + + .. note:: On unexpected errors temp files are automatically kept. + Environment -----------
--- a/sbin/ftjail Fri Dec 02 21:29:26 2022 +0100 +++ b/sbin/ftjail Fri Dec 02 22:01:43 2022 +0100 @@ -44,7 +44,7 @@ build-etcupdate-current-tmpl DIRECTORY TARBALL - freebsd-update DIRECTORY + freebsd-update -[-k] DIRECTORY ENVIRONMENT: @@ -878,12 +878,27 @@ #: command_freebsd_update() { local _directory + local _opt_keep local _res _jailname _dir_mounts _dir_fn_fstab _dir_basename local _root_dataset _root_mountpoint _root_type _root_options - local _dummy + local _dummy _opt local _root_readonly + _opt_keep="no" + while getopts "k" _opt ; do + case ${_opt} in + k) + _opt_keep="yes" + ;; + \?|:) + return 2; + ;; + esac + done + shift $((OPTIND-1)) + OPTIND=1 + _directory="${1-}" [ -z "${_directory}" ] && { echo "ERROR: no directory given" 1>&2; return 2; } @@ -936,7 +951,11 @@ # al.) if needed: clone RW, mount, make the dirs, # umount, make the clone RO and continue "normally" by # completely mounting the stored fstab. - # + # + + if [ "${_opt_keep}" != "yes" ]; then + [ -n "${_dir_fn_fstab}" ] && [ -f "${_dir_fn_fstab}" ] && rm -f "${_dir_fn_fstab}" + fi }
