From e06f8aea797619b69c0b78c42a0ffea729fc6b8f Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 15 Sep 2024 22:05:27 -0300 Subject: [PATCH] Create doas.conf if neccessary --- libexec/portzap/scripts/setup-doas | 27 ++++++++++++++++++--------- share/portzap/CHANGELOG | 5 +++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libexec/portzap/scripts/setup-doas b/libexec/portzap/scripts/setup-doas index 6ea0457..125ca29 100755 --- a/libexec/portzap/scripts/setup-doas +++ b/libexec/portzap/scripts/setup-doas @@ -17,12 +17,21 @@ sharedir="${localbase}"/share/portzap src="${sharedir}"/doas.conf dest="${localbase}"/etc/doas.conf # shellcheck disable=SC2002 -cat "${src}" | -while read -r line; do - if grep -q "${line}" "${dest}"; then - continue - fi - cat "${src}" >> "${dest}" - printok "modified ${dest}" - break -done +if [ -e "${dest}" ]; then + cat "${src}" | + while read -r line; do + if grep -q "${line}" "${dest}"; then + continue + fi + cat "${src}" >> "${dest}" + printok "modified ${dest}" + break + done +else + install -m "u=rw,go=" \ + -o root \ + -g wheel \ + "${src}" \ + "${localbase}"/etc + printok "installed ${dest}" +fi diff --git a/share/portzap/CHANGELOG b/share/portzap/CHANGELOG index b3d90ba..6c47fe8 100644 --- a/share/portzap/CHANGELOG +++ b/share/portzap/CHANGELOG @@ -2,6 +2,11 @@ ** vNEXT +**** Try to install ~doas.conf~ when it does not exist +When ~${PREFIX}/etc/doas.conf~ does not exist the ~setup-doas~ +script will try to install ~/usr/local/etc/doas.conf~ with +~root:wheel~ as the owner, and with ~u=rw,go=~ as the filemode + **** Log when ~portzap rm~ completes successfully Similar to other commands, log when the ~portzap rm~ command completes successfully