Created
December 30, 2018 17:13
-
-
Save alecs/597f5953d9de4843ab28c42cc62eb071 to your computer and use it in GitHub Desktop.
named2imscpSQL.sh
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
#!/bin/bash | |
# | |
# iMSCP dns entries importer | |
# | |
# What you need: standard zone file with columns separated by a TAB and the target domain ID | |
# Usage: | |
# named2imscpSQL.sh domain.tld 93 | |
# | |
# Copyleft alecs@negulescu.me | |
# | |
if [[ -n "$1" && -n "$2" ]]; then | |
echo -e "insert into domain_dns (domain_id,alias_id,domain_dns,domain_class,domain_type,domain_text,owned_by,domain_dns_status) values " | |
iter=0 | |
IFS=\t cat $1 | while read hname ttl in type entry; do | |
[ $iter -gt 0 ] && echo "," | |
echo -n "(${2}, 0, \"${hname} ${ttl}\", \"${in}\", \"${type}\", \"${entry}\", \"custom_dns_feature\", \"toadd\")" | |
let iter++ | |
done | |
echo -e ";\n" | |
else | |
echo "Usage: $0 zone-file.db domain_id" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment