corrected hosts file name

This commit is contained in:
2024-10-19 11:28:51 +02:00
parent f7ce6199f9
commit 4870383a06

View File

@@ -3,14 +3,14 @@
DOMAIN=$DOMAIN DOMAIN=$DOMAIN
SELECTOR=$HOMEASSISTANT SELECTOR=$HOMEASSISTANT
HOMEASSISTANT_IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d '/' -f1) HOMEASSISTANT_IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d '/' -f1)
HOST_FILE=/etc/system/data/dns/host.local; HOST_FILE=/etc/system/data/dns/hosts.local;
EXISTS=$(grep -w -F $SELECTOR $HOST_FILE); EXISTS=$(grep -w -F $SELECTOR $HOST_FILE);
if [ -n "$EXISTS" ]; then if [ -n "$EXISTS" ]; then
# selector already exists in hosts file and SCALE is not in use # selector already exists in hosts file and SCALE is not in use
IP=$(echo $EXISTS | cut -d ' ' -f1); IP=$(echo $EXISTS | cut -d ' ' -f1);
sed "s/'$IP'/'$HOMEASSISTANT_IP'/g" $HOST_FILE > /tmp/host.local sed "s/'$IP'/'$HOMEASSISTANT_IP'/g" $HOST_FILE > /tmp/hosts.local
mv /tmp/host.local $HOST_FILE; mv /tmp/hosts.local $HOST_FILE;
else else
echo "'$HOMEASSISTANT_IP' '$SELECTOR'" >> $HOST_FILE echo "'$HOMEASSISTANT_IP' '$SELECTOR'" >> $HOST_FILE
fi fi