Created
August 26, 2014 12:49
-
-
Save shimaore/ce2a13463110b9c08f60 to your computer and use it in GitHub Desktop.
Vim: update bind9 serial numbers automatically when loading file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Inspired by http://www.debian-administration.org/article/381/Updating_bind_serial_numbers_automatically | |
function UPDSERIAL(date, num) | |
if (strftime("%Y%m%d") == a:date) | |
return a:date . a:num+1 | |
endif | |
return strftime("%Y%m%d") . '01' | |
endfunction | |
command Soa :%s/\(2[0-9]\{7}\)\([0-9]\{2}\)\(\s*;\s*serial\s*\)/\=UPDSERIAL(submatch(1),submatch(2)) . submatch(3)/g | |
autocmd BufNewFile,BufRead /etc/bind/primary/* Soa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment