If i may contribute with this.
I wanted a small script to list all users and domains easy to a txt-file.
I choosed v-list-domains, you can change it to whatever you want not already used by MyVestaCP.
Paste the contents from this - do any changes you want for the location of the output-file.
Code: Select all
#!/bin/bash
usage() {
echo "Usage: $0 [-f] [-l]"
echo " -f Save to file (/root/domains-DATE.txt)"
echo " -l Print to terminal"
exit 1
}
TO_FILE=false
TO_LIST=false
while getopts "fl" opt; do
case $opt in
f) TO_FILE=true ;;
l) TO_LIST=true ;;
*) usage ;;
esac
done
if ! $TO_FILE && ! $TO_LIST; then
usage
fi
output=()
for user in /usr/local/vesta/data/users/*; do
user=$(basename "$user")
domains=$(/usr/local/vesta/bin/v-list-web-domains "$user" plain 2>/dev/null | cut -f1)
if [[ -n "$domains" ]]; then
output+=("$(echo "${user^^}")")
output+=("$domains")
output+=("") # blank line
fi
done
final_output=$(printf "%s\n" "${output[@]}")
if $TO_LIST; then
echo "$final_output"
fi
if $TO_FILE; then
OUTFILE="/root/domains-$(date +%Y%m%d).txt"
echo "$final_output" > "$OUTFILE"
echo "Saved to: $OUTFILE"
fi
then
How to use
v-list-domains (shows help-text)
v-list-domains -f (saves the list to a file)
v-list-domains -l (lists it on screen)
The output shows the user + the domains on that account. Like this
Code: Select all
USER1
domain1.xx
domai2.xx
USER2
domain4.xx
subdomain.domain.xx