mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-03 19:23:42 +01:00
Merge pull request #918 from BastilleBSD/tschettervictor-patch-2
template: Add LINE_IN_FILE as HOOK
This commit is contained in:
@@ -114,6 +114,19 @@ render() {
|
||||
fi
|
||||
}
|
||||
|
||||
line_in_file() {
|
||||
_jailpath="${1}"
|
||||
_filepath="$(echo ${2} | awk '{print $2}')"
|
||||
_line="$(echo ${2} | awk '{print $1}')"
|
||||
if [ -f "${_jailpath}/${_filepath}" ]; then
|
||||
if ! grep -qxF "${_line}" "${_jailpath}/${_filepath}"; then
|
||||
echo "${_line}" >> "${_jailpath}/${_filepath}"
|
||||
fi
|
||||
else
|
||||
warn "Path not found for line_in_file: ${_filepath}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle options.
|
||||
AUTO=0
|
||||
while [ "$#" -gt 0 ]; do
|
||||
@@ -380,6 +393,10 @@ for _jail in ${JAILS}; do
|
||||
render "${bastille_jail_path}" "${_args}"
|
||||
continue
|
||||
;;
|
||||
lif|lineinfile|line_in_file)
|
||||
line_in_file "${bastille_jail_path}" "${_args}"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! eval "bastille ${_cmd} ${_jail} ${_args}"; then
|
||||
|
||||
Reference in New Issue
Block a user