Improve doasedit()

This commit is contained in:
Sam A. 2022-06-14 18:03:40 +02:00
parent 2b21aa3365
commit 66440d4bd7
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA

View file

@ -2,18 +2,17 @@ doasedit() {
(( ${+commands[doas]} )) || return 1
doas -L
doas cp /etc/doas.conf /tmp/doas.conf
doas $EDITOR /tmp/doas.conf
if doas doas -C /tmp/doas.conf; then
echo "ok"
doas mv /tmp/doas.conf /etc/doas.conf
else
echo "error"
fi
doas -u root sh -c \
"cp /etc/doas.conf /tmp/doas.conf \
&& $EDITOR /tmp/doas.conf \
&& doas -C /tmp/doas.conf \
&& mv /tmp/doas.conf /etc/doas.conf \
&& echo 'ok' \
|| echo >&2 'error'"
local STATUS=$?
doas -L
[[ $STATUS -gt 0 ]] && return 1
}
get_ip() {