All pastes #1360715 Raw Edit

AddDNSHost script

public shellscript v1 · immutable
#1360715 ·published 2009-03-14 15:18 UTC
rendered paste body
#!/bin/bashuser=`whoami`if [ $user != "root" ]; then	echo "You must be root to execute this"	exitfiif [ -z "$1" ]; then	echo "You must specify a zone file to update"	exitfi_in_file="$1"echo "Finding serial in: $_in_file"_get_serial=`cat $_in_file | grep -i "serial" | cut -d ";" -f1`function parseserial{	_get_serial=$1}function incrementserial{	_get_inc=`getincval $_get_serial`	_date=`date +%Y%m%e$_get_inc`	_get_serial=$(( $_date + 1 ))}parseserial $_get_serial_old_serial=$_get_serialecho "Serial Found: $_get_serial"echo "Incrementing serial by one"incrementserial $_get_serialecho "Serial incremented to: $_get_serial"##- echo day | sed s/day/night/ #	replaces day with night#- we need to: replace old with new#	sed s/<old_serial>/<new_serial/#echo "Making backup ( $_in_file -> $_in_file-$_old_serial )"cp $_in_file $_in_file-$_old_serialecho "Replacing old serial ( $_old_serial ) with new serial ( $_get_serial ) and creating tmp file"sed s/$_old_serial/$_get_serial/ <$_in_file> $_in_file.tmpecho "Moving tmp file into primary location"mv $_in_file.tmp $_in_file#$2 = domain#$3 = type#$4 = type #$5 = IP#_parse_line="$2       $3        $4        $5"#echo _parse_line >> $_in_file