Add libexec/sourcezap/setup/
This commit is contained in:
parent
c97b48bc0d
commit
36cb7591ee
2 changed files with 41 additions and 21 deletions
|
@ -5,8 +5,6 @@ set -e
|
|||
# variables
|
||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
|
||||
libexec="${localbase}"/libexec/sourcezap
|
||||
conf=$(cat "${localbase}"/share/sourcezap/doas.conf)
|
||||
doas="${localbase}"/etc/doas.conf
|
||||
|
||||
##
|
||||
# functions
|
||||
|
@ -14,11 +12,7 @@ doas="${localbase}"/etc/doas.conf
|
|||
|
||||
##
|
||||
# main
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
printerr "you must be root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
if id -u _sourcezap > /dev/null 2>&1; then
|
||||
printok "_sourcezap user exists"
|
||||
else
|
||||
|
@ -27,12 +21,10 @@ else
|
|||
-m \
|
||||
-s /sbin/nologin
|
||||
chmod u=rwX,g=rX,o= /home/_sourcezap/
|
||||
printok "create _sourcezap user"
|
||||
printok "_sourcezap user created"
|
||||
fi
|
||||
|
||||
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
|
||||
printok "${doas} is up to date"
|
||||
"${libexec}"/setup/setup-doas
|
||||
else
|
||||
echo "$conf" >> "$doas"
|
||||
printok "update ${doas} (note: review the update)"
|
||||
printerr "you must be root"
|
||||
exit 1
|
||||
fi
|
||||
|
|
28
libexec/sourcezap/setup/setup-doas
Executable file
28
libexec/sourcezap/setup/setup-doas
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
##
|
||||
# variables
|
||||
localbase=$(realpath "$(dirname "$0")"/../../..)
|
||||
libexec="${localbase}"/libexec/sourcezap
|
||||
sharedir="${localbase}"/share/sourcezap
|
||||
|
||||
##
|
||||
# functions
|
||||
. "${libexec}"/functions/print.sh
|
||||
|
||||
install_doasconf()
|
||||
{
|
||||
src="${sharedir}"/doas.conf
|
||||
dest="${localbase}"/etc/doas.conf
|
||||
if grep -Fq "$(cat "${src}")" "${dest}"; then
|
||||
printok "doas.conf is up to date"
|
||||
else
|
||||
cat "${src}" >> "${dest}"
|
||||
printok "${dest} updated"
|
||||
fi
|
||||
}
|
||||
|
||||
##
|
||||
# main
|
||||
install_doasconf
|
Loading…
Reference in a new issue