template: Add LINE_IN_FILE as HOOK

#694
This commit is contained in:
tschettervictor
2025-04-02 23:48:32 -06:00
committed by GitHub
parent 321a0975e0
commit 2b1d468040

View File

@@ -114,6 +114,18 @@ render() {
fi
}
line_in_file() {
_line="${1}"
_file_path="${2}"
if [ -f "${_file_path}" ]; then
if ! grep -qxF "${_line}" "${_file_path}"; then
echo "${_line}" >> "${_file_path}"
fi
else
warn "Path not found for line_in_file: ${2}"
fi
}
# Handle options.
AUTO=0
while [ "$#" -gt 0 ]; do
@@ -380,6 +392,10 @@ for _jail in ${JAILS}; do
render "${bastille_jail_path}" "${_args}"
continue
;;
lif|lineinfile|line_in_file)
line_in_file "${_args}"
continue
;;
esac
if ! eval "bastille ${_cmd} ${_jail} ${_args}"; then