Created
September 11, 2014 05:44
-
-
Save makotom/8810f1a7ca20fc3f2732 to your computer and use it in GitHub Desktop.
Zone file updator for LuaDNS. No longer maintained.
This file contains 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
(function(){ | |
var DIRNAME = "/tmp/ddns", | |
REPORTS_DIR = DIRNAME + "/reports", | |
ZONEFILE = DIRNAME + "/ddns.makotom.net.lua", | |
fs = require("fs"); | |
(function(){ | |
var reports = fs.readdirSync(REPORTS_DIR), | |
table = [], | |
zone = ""; | |
reports.forEach(function(fileName){ | |
var name = fileName.replace(/\.html$/, ""), | |
ip6Catch = /REMOTE_ADDR<dd>([0-9a-f:]+)$/m.exec(fs.readFileSync(REPORTS_DIR + "/" + fileName).toString()), | |
ip6 = (ip6Catch !== null && typeof ip6Catch[1] === typeof "") ? ip6Catch[1] : "::1"; | |
table.push({ | |
name : name, | |
addr : ip6 | |
}); | |
}); | |
table.forEach(function(record){ | |
zone += "aaaa(\"" + record.name + "\", \"" + record.addr + "\", 300)\n"; | |
}); | |
fs.writeFileSync(ZONEFILE, zone); | |
})(); | |
})(); |
This file contains 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
#!/usr/bin/bash | |
WD=$(dirname $(realpath $0)) | |
cd $WD | |
node buildZone.js | |
git commit -a -m "Auto update: `date`" | |
GIT_SSH=$WD/ssh git push -u | |
cd - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment