mirror of
https://github.com/unraid/webgui.git
synced 2026-05-04 08:49:47 -05:00
Merge pull request #1713 from unraid/fix-add-local-to-hosts
hosts file improvements
This commit is contained in:
@@ -208,7 +208,6 @@ fi
|
||||
/bin/echo "$NAME" >/etc/HOSTNAME
|
||||
/bin/echo "# Generated" >/etc/hosts
|
||||
/bin/echo "127.0.0.1 $NAME localhost" >>/etc/hosts
|
||||
/bin/echo "54.149.176.35 keys.lime-technology.com" >>/etc/hosts
|
||||
|
||||
# LimeTech - restore the configured timezone
|
||||
if [[ $timeZone == custom ]]; then
|
||||
|
||||
+20
-2
@@ -30,6 +30,8 @@ DAEMON="Avahi mDNS/DNS-SD daemon"
|
||||
CALLER="avahi"
|
||||
AVAHI="/usr/sbin/avahi-daemon"
|
||||
CONF="/etc/avahi/avahi-daemon.conf"
|
||||
HOSTS="/etc/hosts"
|
||||
NAME=$(</etc/HOSTNAME)
|
||||
|
||||
# run & log functions
|
||||
. /etc/rc.d/rc.runlog
|
||||
@@ -49,6 +51,22 @@ disable(){
|
||||
sed -ri "s/^#?(use-$1)=.*/\1=no/" $CONF
|
||||
}
|
||||
|
||||
# when starting avahidaemon, add name.local to the hosts file
|
||||
add_local_to_hosts(){
|
||||
local old new
|
||||
old="^127\.0\.0\.1.*"
|
||||
new="127.0.0.1 $NAME $NAME.local localhost"
|
||||
sed -i "s/$old/$new/gm;t" $HOSTS
|
||||
}
|
||||
|
||||
# when stopping avahidaemon, remove name.local from the hosts file
|
||||
remove_local_from_hosts(){
|
||||
local old new
|
||||
old="^127\.0\.0\.1.*"
|
||||
new="127.0.0.1 $NAME localhost"
|
||||
sed -i "s/$old/$new/gm;t" $HOSTS
|
||||
}
|
||||
|
||||
avahid_running(){
|
||||
sleep 0.1
|
||||
$AVAHI -c
|
||||
@@ -67,7 +85,7 @@ avahid_start(){
|
||||
[[ $IPV4 == no ]] && disable ipv4 || enable ipv4
|
||||
[[ $IPV6 == no ]] && disable ipv6 || enable ipv6
|
||||
run $AVAHI -D
|
||||
if avahid_running; then REPLY="Started"; else REPLY="Failed"; fi
|
||||
if avahid_running; then add_local_to_hosts && REPLY="Started"; else REPLY="Failed"; fi
|
||||
else
|
||||
REPLY="Bind failed"
|
||||
fi
|
||||
@@ -82,7 +100,7 @@ avahid_stop(){
|
||||
REPLY="Already stopped"
|
||||
else
|
||||
run $AVAHI -k
|
||||
if ! avahid_running; then REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
if ! avahid_running; then remove_local_from_hosts && REPLY="Stopped"; else REPLY="Failed"; fi
|
||||
fi
|
||||
log "$DAEMON... $REPLY."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user