fi
done
) > $hfile
- if [ $PLC_DNS_ENABLED -eq 1 ] ; then
- target=/etc/plc_hosts
- sort -u $hfile > $target
- else
- target=/etc/hosts
- cat /etc/hosts >> $hfile
- echo "#generated by /etc/plc.d/network" >/etc/hosts
- echo "127.0.0.1 localhost.localdomain localhost" >>/etc/hosts
- sort -u $hfile >> /etc/hosts
- fi
- chmod +r $target
+ grep -v "^#" /etc/hosts >> $hfile
+ echo "#generated by /etc/plc.d/network" >/etc/hosts
+ echo "127.0.0.1 localhost.localdomain localhost" >> $hfile
+ sort -u $hfile >> /etc/hosts
+ chmod +r /etc/hosts
rm -f $hfile
# Set up nameservers
+ rfile=$(mktemp)
(
echo "; generated by /etc/plc.d/network"
[ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
[ -n "$PLC_NET_DNS2" -a "$PLC_NET_DNS1" != "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
- ) > /etc/resolv.conf
- chmod +r /etc/resolv.conf
+ ) > $rfile
+ if [ -n "$PLC_NET_DNS1" -o -n "$PLC_NET_DNS2" ] ; then
+ mv $rfile /etc/resolv.conf
+ chmod 444 /etc/resolv.conf
+ else
+ rm -f $rfile
+ fi
result "$MESSAGE"
;;