And now for something completely diffrent :-)
"Jóhann B. Guðmundsson"
johannbg at hi.is
Wed Feb 28 18:09:26 UTC 2007
Hello chaps
Ever thougt of creating contrib directory that would come with DHCP server
like contrib folder under doc/ which could contributed scripts,examples
howto´s etc etc..
We could point users on the directory and Ralph and Ted could include
contributed examples, setups,
scripts perhaps in next edition of DHCP Handbook.
Got more up my sleeve if needed
Best regards
Johann B.
Sample one
#!/bin/bash
#
# Script that runs syntax check against is DHCP file
# If correct then backs up the current file and copys the file
# in question over the current one and restarts the DHCP server...
#file="file.new" # The file you will be
changing/editing
#file2="file" # The running file
#dt="/path/to/dhcpd -t -cf " # Change syntax to where ever
dhcpd is
# On RHEL 4 check against single file
file="/etc/dhcpd.conf.new"
file2="/etc/dhcpd.conf"
dt="/usr/sbin/dhcpd -t -cf $file"
if $dt; then
echo "Syntax OK"
cp $file2 $file2.bak
cp $file $file2
service dhcpd restart # For other OS than Redhat you need
to HUP the daemon or stop and start it
else
echo "Syntax not Ok!!! check $file"
exit 192
fi
exit 0
Sample 2
#!/bin/bash
#
# Script that runs syntax check against is DHCP file
# If correct then backs up the current file and copys the file
# in question over the current one and restarts the DHCP server...
# this script is useful where there is some automated process that
# changes the file in question for example some web interface
# which is used to register the mac addresses...
#
# diffrence from sample one it will run the script silently, if it fails
# stop running and mail the dhcp admin...
#file="file.new" # The file you will be
changing/editing
#file2="file" # The running file
#dt="/path/to/dhcpd -t -cf " # Change syntax to where ever
dhcpd is
#da="dhcpadmin at example.com # Mail address of who's responsible of
running the DHCP server
# On RHEL 4 Silent check against single file, mail on error
file="/etc/dhcpd.conf.new"
file2="/etc/dhcpd.conf"
dt="/usr/sbin/dhcpd -t -cf $file"
da="dhcpadmin at example.com"
if $dt &> /dev/null ; then
cp $file2 $file2.bak
cp $file $file2
service dhcpd restart # For other OS than Redhat you need
to HUP the daemon or stop and start it
else
echo "Syntax not Ok!!! check $file" | mail -s "From DHCP
Server: Arg!! wrong syntax in file" $da
exit 192
fi
exit 0
--
Jóhann B. Guðmundsson. RHCE,CCSA
Unix Kerfistjóri.
Kerfistjórn.
Reiknistofnun Háskóla Íslands.
Tæknigarði, Dunhaga 5. Rafpóstur: johannbg at hi.is
107 Reykjavík. Sími: 525-4267
Ísland. Bréfasími: 552-8801
Johann B. Gudmundsson. RHCE,CCSA
Unix System Engineer.
IT Management.
Reiknistofnun University of Iceland.
Taeknigardi, Dunhaga 5. Email: johannbg at hi.is
IS-107 Reykjavik. Phone: +354-525-4267
Iceland. Fax: +354-552-8801
More information about the dhcp-users
mailing list