From 2b1d4680404aaed4dd606cadf290b7bf4aa3458a Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:48:32 -0600 Subject: [PATCH] template: Add LINE_IN_FILE as HOOK #694 --- usr/local/share/bastille/template.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index b3ca2ffa..8e97feeb 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -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