Commit 3a13ae1a authored by Benoît's avatar Benoît
Browse files

Added sm option : move whole server

parent 7cd05ad5
......@@ -15,13 +15,14 @@ if [ "$1" == "-h" ]||[ "$1" == "--help" ]; then
echo "Help :"
echo "Usage: ./slave-retrieve.sh [options] [argument]"
echo " -h, --help Display this help and exit."
echo " -d \$2 \$3 \$4 Move a domain from one server to another : Respectively input domain, old IP and new IP."
echo " -dm \$2 \$3 \$4 Move a domain from one server to another : Respectively input domain, old IP and new IP."
echo " -sm \$2 \$3 Move all domains from one server to another : Respectively input old IP and new IP."
echo " Without option : If an IP address is passed as an argument, the script will retrieve DNS zones from this IP."
echo " Without option or argument : The script will check the DNS zones for the IP adresses that have already been added."
exit
fi
if [ "$1" == "-d" ]; then
if [ "$1" == "-dm" ]; then
if [ -n "$4" ]; then
if [ -n "$5" ]; then
echo "Too many arguments"
......@@ -48,7 +49,47 @@ if [ "$1" == "-d" ]; then
else
echo "Missing argument(s)"
echo "Usage: ./slave-retrieve.sh [options] [argument]"
echo " -d \$2 \$3 \$4 Move a domain from one server to another : Respectively input domain, old IP and new IP."
echo " -dm \$2 \$3 \$4 Move a domain from one server to another : Respectively input domain, old IP and new IP."
exit
fi
fi
if [ "$1" == "-sm" ]; then
if [ -n "$3" ]; then
if [ -n "$4" ]; then
echo "Too many arguments"
exit
else
if [ -d "$fulldir/slaves/$2" ]; then
find "$fulldir/slaves/$2" -maxdepth 1 -type f -printf "%f\\n" > "/opt/zones_to_del.txt"
for i in $(cat /opt/zones_to_del.txt); do
delcommand="/usr/sbin/rndc delzone $i"
eval "$delcommand"
echo -e "$(date "+%d/%m/%Y %T") - Removing domain: $i\\n"
done
/usr/sbin/rndc reload
rm -f "$fulldir/slaves/$2/*"
rm -f "/opt/zones_to_del.txt"
echo "$psa_sql" | mysql -N -h"$host" -u"$psa_user" -p"$psa_password" "$psa_db" > "/opt/zones_to_add.txt"
for i in $(cat /opt/zones_to_add.txt); do
addcommand="/usr/sbin/rndc addzone $i '{type slave; file \"slaves/$3/$i\"; masters { $3; }; };'"
eval "$addcommand"
echo -e "$(date "+%d/%m/%Y %T") - Adding domain: $i\\n"
logger -t "$script_name" -- "/usr/sbin/rndc addzone $addcommand"
done
/usr/sbin/rndc reload
rm -f "/opt/zones_to_add.txt"
exit
else
echo "The specified old server IP does not exists."
exit
fi
fi
else
echo "Missing argument(s)"
echo "Usage: ./slave-retrieve.sh [options] [argument]"
echo " -sm \$2 \$3 Move all domains from one server to another : Respectively input old IP and new IP."
exit
fi
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment