Skip to content

Instantly share code, notes, and snippets.

@alecs
Created December 30, 2018 17:13
Show Gist options
  • Save alecs/597f5953d9de4843ab28c42cc62eb071 to your computer and use it in GitHub Desktop.
Save alecs/597f5953d9de4843ab28c42cc62eb071 to your computer and use it in GitHub Desktop.
named2imscpSQL.sh
#!/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