NOTE !!!
As of directadmin version 1.43 this script isnt needed any more becouse the abillity is build in to directadmin and covers all users all resellers and ssl accounts
http://www.directadmin.com/features.php?id=1377
I leave the post online for learning and idea's for other users
As we are currently adding ipv6 to or live systems and servers contain at least 1000 domains a server it was not really handy to add every thing by hand and da it self does not really has a function cq script for it.
After searching the forum i fond 1 post that came in handy but not yet fully what i needed so i used this script as basic and changed it to my needs.
So credits for the base script go to Icehosting forum post http://www.directadmin.com/forum/showthread.php?t=40405&highlight=mass+add+ip+to+account
Ok i created the script and added it to:
after creating the script chmod the file to 755
The script: (off course change YOUR IPV6 ADDRESS THAT YOU WANT TO ADD to the ip address you want to add!)
After the script is created you can run it with a cronjob for example:
Im not that great in bash scripts so iff you feel that i made any mistake or know a better way or if i forgot something feel free to correct me.
Update 10-12-12
I changed the code so it only works for all users of the main admin account.
Changed the code for adding the changes to the dns when using multi cluster to export the dns changed to the other dns servers it only updates the dns of the domain that is changed instead of all zone of the server.
As of directadmin version 1.43 this script isnt needed any more becouse the abillity is build in to directadmin and covers all users all resellers and ssl accounts
http://www.directadmin.com/features.php?id=1377
I leave the post online for learning and idea's for other users
As we are currently adding ipv6 to or live systems and servers contain at least 1000 domains a server it was not really handy to add every thing by hand and da it self does not really has a function cq script for it.
After searching the forum i fond 1 post that came in handy but not yet fully what i needed so i used this script as basic and changed it to my needs.
So credits for the base script go to Icehosting forum post http://www.directadmin.com/forum/showthread.php?t=40405&highlight=mass+add+ip+to+account
Ok i created the script and added it to:
and called it "add_ipv6_to_user.sh"cd /usr/local/directadmin/script/custom/
after creating the script chmod the file to 755
chmod 755 add_ipv6_to_user.sh
The script: (off course change YOUR IPV6 ADDRESS THAT YOU WANT TO ADD to the ip address you want to add!)
Code:
#Set the IPV6 IP here
IP="[COLOR="Red"]YOUR IPV6 ADDRESS THAT YOU WANT TO ADD[/COLOR]"
COUNTER="0"
#Set the server shared ipv4 ip address here
IP4="[COLOR="Red"]YOUR SERVER SHARED IPV4 HERE[/COLOR]"
#Does the IPV6 address exist?
COUNT_IP="`grep -c ${IP} /usr/local/directadmin/data/admin/ip.list`"
if [ ${COUNT_IP} -eq 0 ]; then
echo "IP ${IP} does not exist. Exiting..."
exit 1;
fi
#Does the IPV4 address exist?
COUNT_IP4="`grep -c ${IP4} /usr/local/directadmin/data/admin/ip.list`"
if [ ${COUNT_IP4} -eq 0 ]; then
echo "IP ${IP4} does not exist. Exiting..."
exit 1;
fi
for user in `ls /usr/local/directadmin/data/users`; do
{
COUNT_IP4_USER="`grep -c ${IP4} /usr/local/directadmin/data/users/$user/user_ip.list`"
if [ ${COUNT_IP4_USER} -eq 1 ]; then
COUNT_IP_USER="`grep -c ${IP} /usr/local/directadmin/data/users/$user/user_ip.list`"
if [ ${COUNT_IP_USER} -eq 0 ]; then
COUNTER="1"
echo "Adding ip to user_ip.list user $user"
echo "${IP}" >> /usr/local/directadmin/data/users/$user/user_ip.list
# added to update user amount using this ip in the ip config file
x="`grep value /usr/local/directadmin/data/admin/ips/${IP}`"
xx=$(echo $x|sed 's/value=//g')
let "val = $xx + 1"
replacement=s/${x}/value=${val}/
sed -i $replacement /usr/local/directadmin/data/admin/ips/${IP}
# end update ip config file
fi
if [ ${COUNT_IP_USER} -eq 0 ]; then
for domain in `cat /usr/local/directadmin/data/users/$user/domains.list`; do
{
if [ -e /usr/local/directadmin/data/users/$user/domains/$domain.ip_list ]; then
if [ ${COUNTER} -eq 0 ]; then
COUNTER="1"
fi
COUNT_IP_DOMAIN="`grep -c ${IP} /usr/local/directadmin/data/users/$user/domains/$domain.ip_list`"
if [ ${COUNT_IP_USER} -eq 0 ]; then
echo "Adding ip to domain.ip_list"
echo "${IP}" >> /usr/local/directadmin/data/users/$user/domains/$domain.ip_list
fi
COUNT_IP_DNS="`grep -c ${IP} /var/named/$domain.db`"
if [ ${COUNT_IP_DNS} -eq 0 ]; then
if [ ${COUNTER} -eq 0 ]; then
COUNTER="1"
fi
echo "Adding ip to dns zone"
echo "$domain. IN AAAA ${IP}" >> /var/named/$domain.db
echo "www IN AAAA ${IP}" >> /var/named/$domain.db
echo "ftp IN AAAA ${IP}" >> /var/named/$domain.db
# Check if domain uses local mail server
GREP_DOMAIN="`grep -c $domain /etc/virtual/domains`"
if [ ${GREP_DOMAIN} -eq 1 ]; then
echo "mail IN AAAA ${IP}" >> /var/named/$domain.db
echo "pop IN AAAA ${IP}" >> /var/named/$domain.db
echo "smtp IN AAAA ${IP}" >> /var/named/$domain.db
fi
echo "action=rewrite&value=named&domain=$domain" >> /usr/local/directadmin/data/task.queue
fi
fi
}
done;
fi
fi
}
done;
if [ ${COUNTER} -eq 1 ]; then
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
fi
exit 0;
After the script is created you can run it with a cronjob for example:
15 * * * * /usr/local/directadmin/script/custom/add_ipv6_to_user.sh >/dev/null 2>&1
Im not that great in bash scripts so iff you feel that i made any mistake or know a better way or if i forgot something feel free to correct me.
Update 10-12-12
I changed the code so it only works for all users of the main admin account.
Changed the code for adding the changes to the dns when using multi cluster to export the dns changed to the other dns servers it only updates the dns of the domain that is changed instead of all zone of the server.
Last edited: