Skip to content
Snippets Groups Projects
Commit 43cfe1ba authored by Bob Mottram's avatar Bob Mottram
Browse files

Separate function for changing local name

parent 5ca088b4
No related branches found
No related tags found
No related merge requests found
......@@ -1193,18 +1193,7 @@ function change_system_name {
sel=$?
case $sel in
0) NEW_SYSTEM_NAME=$(<"$data")
if [ "$NEW_SYSTEM_NAME" ]; then
if [ ${#NEW_SYSTEM_NAME} -gt 1 ]; then
sed -i "s|host-name=.*|host-name=$NEW_SYSTEM_NAME|g" /etc/avahi/avahi-daemon.conf
systemctl restart avahi-daemon
if grep -q "host-name=$NEW_SYSTEM_NAME" /etc/avahi/avahi-daemon.conf; then
install_web_admin
systemctl restart webadmin
dialog --title $"New local network name" \
--msgbox $"The name of this system on your local network was changed successfully" 6 70
fi
fi
fi
change_system_local_name "${NEW_SYSTEM_NAME}" interactive
;;
esac
rm -f "$data"
......
......@@ -95,6 +95,28 @@ EXTERNAL_IP_SERVICES=( \
'http://ipinfo.io/' \
'http://httpbin.org/ip')
function change_system_local_name {
NEW_SYSTEM_NAME="$1"
NEW_SYSTEM_NAME_INTERACTIVE="$2"
if [ "$NEW_SYSTEM_NAME" ]; then
if [ ${#NEW_SYSTEM_NAME} -gt 1 ]; then
sed -i "s|host-name=.*|host-name=$NEW_SYSTEM_NAME|g" /etc/avahi/avahi-daemon.conf
systemctl restart avahi-daemon
if grep -q "host-name=$NEW_SYSTEM_NAME" /etc/avahi/avahi-daemon.conf; then
install_web_admin
systemctl restart webadmin
searx_set_base_url
systemctl restart searx
if [ "$NEW_SYSTEM_NAME_INTERACTIVE" ]; then
dialog --title $"New local network name" \
--msgbox $"The name of this system on your local network was changed successfully" 6 70
fi
fi
fi
fi
}
function enable_mdns {
# files gw_name myhostname mdns4_minimal [NOTFOUND=return] dns
sed -i "s|hosts:.*|hosts: files mdns4_minimal mdns4 mdns dns|g" /etc/nsswitch.conf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment