Projekt

Obecné

Profil

« Předchozí | Další » 

Revize b8f0e126

Přidáno uživatelem Michal Kliment před více než 3 roky(ů)

Test validity of new config (fixes #1162)

Zobrazit rozdíly:

freenetis-dhcp-sync.sh
# config has been change
if [ `diff "$TMPFILE" "$DHCP_CONF" | wc -l` -gt 0 ]; then
echo "[INFO] `date -R` Downloaded (code: $status)"
echo "[INFO] `date -R` Backuping old config to $DHCP_CONF.save"
mv -f "$DHCP_CONF" "$DHCP_CONF".save
echo "[INFO] `date -R` Loading new config to $DHCP_CONF.save..."
# copy config
mv -f "$TMPFILE" "$DHCP_CONF"
#restart DHCP server
echo "[INFO] `date -R` Restarting ISC DHCP server"
echo "[INFO] `date -R` Testing new config..."
# new config is valid
if dhcpd -4 -t -cf "$TMPFILE" &>/dev/null;
then
echo "[INFO] `date -R` New config is valid"
echo "[INFO] `date -R` Backuping old config to $DHCP_CONF.save"
mv -f "$DHCP_CONF" "$DHCP_CONF".save
echo "[INFO] `date -R` Loading new config to $DHCP_CONF.save..."
# copy config
mv -f "$TMPFILE" "$DHCP_CONF"
#restart DHCP server
echo "[INFO] `date -R` Restarting ISC DHCP server"
killall -w dhcpd 2>/dev/null
dhcpd -4 -q -cf "$DHCP_CONF"
killall -w dhcpd 2>/dev/null
dhcpd -4 -q -cf "$DHCP_CONF"
else
echo "[ERROR] `date -R` Invalid new config -> keeping old configuration"
fi
else
echo "[INFO] `date -R` No change -> keeping old configuration"
fi

Také k dispozici: Unified diff