some awk & sed script

mrtg

大量重新命名 mrtg output 檔案

find . -iname "1.1.1.1_*" | awk -F "_" '{print "mv 1.1.1.1_" $2 " 2.2.2.2_" $2}' | sh

all-in-one command for cfgmaker

cfgmaker --snmp-options=:::::2 --global "WorkDir: /home/hosts/www/mrtg/html/idc/Juniper" --global "Options[_]: growright, bits" --global "Language: big5" --global 'AddHead[_]:<script type="text/javascript" src="//mrtg.jal.tw/google_analytics.js"></script>' --zero-speed=1000000000 --show-op-down --if-filter='$if_type!=1 && $if_type!=53 && $if_type!=24 && $if_type!=131 && $if_type!=135 && $if_type!=136 && $if_type!=137 && $if_type!=142 && $if_type!=150 && $if_type!=217 && $if_type!=218 && $if_type!=222 && $if_type!=223' public@8.8.8.8 --output=Juniper.cfg

Replace sensitive information after index page build.

/usr/bin/sed -i '' -e 's/iso-8859-15/big5/g' */*/index.html
/usr/bin/sed -i '' '/Command line/d' */*/index.html
/usr/bin/sed -i '' '/Command-Line/d' */*/index.html
/usr/bin/sed -i '' '/commandline/d' */*/index.html
/usr/bin/sed -i '' '/HTTP-EQUIV="Expires"/d' */*/index.html
/usr/bin/sed -i '' '/.switchs.jal.tw/d' */*/index.html

named (bind)

Replace bind zone file serial number with increased serial number. Complete script: [https://github.com/jal-tw/dnssec-reissue-and-bind-reload|Github]

<?php
$zone_file = "/usr/local/etc/namedb/master/jal.tw";
$serial = exec ("/usr/bin/grep serial $zone_file | /usr/bin/awk '{print $1}'");
$new_serial = $serial + 1;
"/usr/bin/sed -i '' -e 's/$serial/$new_serial/g' $zone_file";
?>
other/awk-sed.txt · 上一次變更: 2017/04/18 06:36 由 jal
上一頁 | 下一頁 | 回首頁 | RSS Feed | Facebook