From d99af1d51601ba81a492411a8dbbf07b61b95491 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Wed, 17 Apr 2024 07:10:26 -0300 Subject: [PATCH] Fix the population of doas.conf We weren't populating doas.conf when it had vaguely similar content already present. --- libexec/portzap/portzap-setup | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libexec/portzap/portzap-setup b/libexec/portzap/portzap-setup index 54c6ab2..2a25011 100755 --- a/libexec/portzap/portzap-setup +++ b/libexec/portzap/portzap-setup @@ -8,16 +8,24 @@ doas="${localbase}"/etc/doas.conf ## # main -if ! id -u _portzap > /dev/null 2>&1; then +if id -u _portzap > /dev/null 2>&1; then + echo "[-] The _portzap user exists" + echo "[-] Add user(s) to the _portzap group:" + echo "root# pw groupmod -n _portzap -m user1,user2" +else pw useradd -n _portzap \ -c "portzap user" \ -m \ -s /sbin/nologin chmod u=rwX,g=rX,o= /home/_portzap/ -echo "[ok] add _portzap user, group and home directory" + echo "[-] The _portzap user, group and home directory have been created." + echo "[-] Add user(s) to the _portzap group:" + echo "root# pw groupmod -n _portzap -m user1,user2" fi -if ! grep -F "${conf}" "${doas}" > /dev/null 2>&1; then - echo "${conf}" >> "${doas}" - echo "[ok] modify ${doas}" +if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then + echo "[-] No changes made to ${doas}" +else + echo "$conf" >> "$doas" + echo "[-] ${doas} has been changed. Please review the changes" fi