Bulk Delete

pjs32

New member
Joined
Sep 2, 2021
Messages
4
Hi,
We have over 1000 domains on Directadmin but they are no longer using our DNS/nameservers and so need removed - they are all under the admin user.

Is there a script that we could input all the domains we want removed our Directadmin install?
 

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
411
Location
The Earth
I have not tried this, but this simple script should work.

# domain_list.txt

Code:
hello.com
wassup.com
ok.com


# delete_domains.sh

Code:
#!/bin/bash


da_api_username="user"
da_api_password="password"
server="server.domain.com"
ssl_protocol="https"
port="2222"

readarray -t domains < domain_list.txt

cmd_api="CMD_API_DOMAIN"
method="POST"

for domain in "${domains[@]}"; do

        data="delete_data=yes&json=yes&action=select&delete=yes&confirmed=yes&delete_data_aware=yes&select0=${domain}"
        curl --silent --request "${method}" --user "${da_api_username}":"${da_api_password}" --data "${data}" "${ssl_protocol}://${server}:${port}/${cmd_api}"
done
 
Top