config: Use privileged decorator for set domainname action

Tests:

- Running flake8 as in .gitlab-ci.yml works.
- Setting the domain name again to update /etc/hosts file after hostname change
  works
- Setting the domain name from the text box works. New domain name is read back
  and shown properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-10-08 18:51:36 -04:00
1 parent 40bf6add75
commit b607174434
4 files changed
+36 -31

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-or-later
domainname="$1"
hostname=$(hostname)
if [ -z "$domainname" ] ; then
if grep -q 127.0.1.1 /etc/hosts ; then
sed -i "s/127.0.1.1.*/127.0.1.1 $hostname/" /etc/hosts
else
sed -i "/127.0.0.1.*/a \
127.0.1.1 $hostname" /etc/hosts
fi
else
if grep -q 127.0.1.1 /etc/hosts ; then
sed -i "s/127.0.1.1.*/127.0.1.1 $hostname.$domainname $hostname/" /etc/hosts
else
sed -i "/127.0.0.1.*/a \
127.0.1.1 $hostname.$domainname $hostname" /etc/hosts
fi
fi