Added add_domain_slave.sh #50
43
scripts/add_domain_slave.sh
Executable file
43
scripts/add_domain_slave.sh
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
slaveServer="ns.slave.example.com"
|
||||||
|
sshUser="example"
|
||||||
|
clientName="example"
|
||||||
|
webServerName="example"
|
||||||
|
mailAddress="admin@example.com"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOT
|
||||||
|
$0 domain_to_add
|
||||||
|
Exemple: $0 mydomain.com
|
||||||
|
|||||||
|
EOT
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# != 1 ]]; then
|
||||||
|
echo "Need only one argument!"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
domain=$1
|
||||||
|
# Remove www. if any.
|
||||||
|
domain=${domain#www.}
|
||||||
|
|
||||||
|
# Connect to $slaveServer and add slave domain.
|
||||||
|
stdin=/tmp/empty-in
|
||||||
|
stdout=/tmp/empty-out
|
||||||
|
result=/tmp/result
|
||||||
mtrossevin
commented
Should be using Should be using `mktemp(1)`.
|
|||||||
|
[[ -e $stdin ]] && rm -f $stdin
|
||||||
|
[[ -e $stdout ]] && rm -f $stdout
|
||||||
|
empty -f -i $stdin -o $stdout -L $result ssh ${sshUser}@${slaveServer} "sudo /usr/share/scripts/bind-slave-${clientName}.sh"
|
||||||
mtrossevin
commented
1. What is this `empty` command ?
2. This require ssh access to the secondary DNS server, even if we did limit access to this one command, this seems like a bad idea.
|
|||||||
|
# Responses to question of add slave domain script.
|
||||||
|
sleep 2
|
||||||
|
echo "$domain" > $stdin
|
||||||
|
sleep 2
|
||||||
|
# Send mail
|
||||||
|
subject="[AUTO-${clientName}] Added slave domain of $webServerName $domain"
|
||||||
mtrossevin
commented
Should almost definitely also add Should almost definitely also add `Auto-Submitted: auto-generated` header in the mail.
|
|||||||
|
mail -s "$subject" $mailAddress < $result
|
||||||
|
cat $result
|
||||||
|
# Cleaning
|
||||||
|
rm $result
|
||||||
|
|
Loading…
Reference in a new issue
Should be using example.com here too.