edit: Update for new functions

This commit is contained in:
tschettervictor
2025-02-23 10:07:15 -07:00
committed by GitHub
parent a200337526
commit aeac03d995

View File

@@ -34,33 +34,52 @@
. /usr/local/etc/bastille/bastille.conf . /usr/local/etc/bastille/bastille.conf
usage() { usage() {
error_exit "Usage: bastille edit TARGET [filename]" error_notify "Usage: bastille edit [option(s)] TARGET [filename]"
cat << EOF
Options:
-x | --debug Enable debug mode.
EOF
exit 1
} }
# Handle special-case commands first. # Handle options.
case "$1" in while [ "$#" -gt 0 ]; do
help|-h|--help) case "${1}" in
usage -h|--help|help)
;; usage
esac ;;
-x|--debug)
enable_debug
shift
;;
-*)
error_notify "Unknown Option: \"${1}\""
usage
;;
*)
break
;;
esac
done
if [ $# -gt 1 ]; then if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
usage usage
elif [ $# -eq 1 ]; then fi
TARGET_FILENAME="${1}"
TARGET="${1}"
if [ "$#" -eq 2 ]; then
TARGET_FILENAME="${2}"
else
TARGET_FILENAME="jail.conf"
fi fi
bastille_root_check bastille_root_check
set_target_single "${TARGET}"
if [ -z "${EDITOR}" ]; then if [ -z "${EDITOR}" ]; then
# shellcheck disable=SC2209 EDITOR=edit
EDITOR=vi
fi fi
for _jail in ${JAILS}; do "${EDITOR}" "${bastille_jailsdir}/${TARGET}/${TARGET_FILENAME}"
if [ -n "${TARGET_FILENAME}" ]; then
"${EDITOR}" "${bastille_jailsdir}/${_jail}/${TARGET_FILENAME}"
else
"${EDITOR}" "${bastille_jailsdir}/${_jail}/jail.conf"
fi
done