# HG changeset patch # User Franz Glasner # Date 1670014903 -3600 # Node ID e1d6807b0c4d327f1c9835b53a45aa199a6b4e36 # Parent a423bc0e2a3f37bfdae9c9ed6959e8046b40b0c8 Implement option handling for ftjail freebsd-update and the "-k" option diff -r a423bc0e2a3f -r e1d6807b0c4d docs/man/man8/ftjail-freebsd-update.rst --- 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 ----------- diff -r a423bc0e2a3f -r e1d6807b0c4d sbin/ftjail --- 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 }