mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
40bf6add75
commit
b607174434
4 files changed
+36
-31
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user