Skip to content

Instantly share code, notes, and snippets.

@Achterstraat
Created January 11, 2021 16:13
Show Gist options
  • Save Achterstraat/f9195a967c907907b6f7686f90997a04 to your computer and use it in GitHub Desktop.
Save Achterstraat/f9195a967c907907b6f7686f90997a04 to your computer and use it in GitHub Desktop.
Accounts overview included domains, subdomains, pointers and mailaliases in tabbed list!
#!/bin/sh
if [ ! -z "${1}" ]; then user="${1}"; else user=""; fi
users=/usr/local/directadmin/data/users
virtual=/etc/virtual
for u in `ls ${users}/*/users.list`;
do
r=`echo ${u} | cut -d/ -f7`
if [ -z "${user}" ]; then echo -e "R: ${r}"; fi
for u in `cat ${u}; echo ${r}`;
do
if [ -z "${user}" ]; then echo -e "\tU: ${u}"; else u="${user}"; fi
for d in `cat ${users}/${u}/domains.list`;
do
if [ -z "${user}" ]; then tabs="\t\t"; else tabs=""; fi
echo -e "${tabs}D: ${d}"
tabs+="\t"
if [ -f "${users}/${u}/domains/${d}.subdomains" ]; then
for s in `cat ${users}/${u}/domains/${d}.subdomains | sort`;
do
echo -e "${tabs}S: ${s}.${d}"
done
fi
if [ -f "${users}/${u}/domains/${d}.pointers" ]; then
for p in `cat ${users}/${u}/domains/${d}.pointers | sort | cut -d'=' -f1`;
do
echo -e "${tabs}P: ${p}"
done
fi
if [ -s ${virtual}/${d}/passwd ]; then
for e in `cat ${virtual}/${d}/passwd | sort | cut -d':' -f1`;
do
echo -e "${tabs}E: ${e}@${d}"
done
fi
done
if [ -z "${user}" ]; then continue; else exit; fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment