How to completely rebuild your /etc/virtual directory

1) salvage any info you may have that's still good.. grab any /etc/virtual/domain.com/passwd files that you want because you will lose any data currently in the /etc/virtual directory (email passwords, aliases, quotas, mailing lists etc)

2) Delete it:

rm -rf /etc/virtual


3) Create it:

mkdir /etc/virtual
chmod 755 /etc/virtual
chown mail:mail /etc/virtual


4) Create the following script

#!/bin/sh

mkdir /etc/virtual/`hostname`
chown mail:mail /etc/virtual/`hostname`
chmod 711 /etc/virtual/`hostname`
echo `hostname` >> /etc/virtual/domains

for u in `ls /usr/local/directadmin/data/users`; do
{
for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
{
echo "$d: $u" >> /etc/virtual/domainowners
echo "$d" >> /etc/virtual/domains

DMN=/etc/virtual/$d

mkdir $DMN
chmod 711 $DMN
chown mail:mail $DMN

echo "$u: $u" > $DMN/aliases
echo "" > $DMN/autoresponder.conf
echo "" > $DMN/filter
echo "" > $DMN/filter.conf
echo "" > $DMN/passwd
echo "" > $DMN/quota
echo "" > $DMN/vacation.conf
chown mail:mail $DMN/*

mkdir $DMN/majordomo
chmod 751 $DMN/majordomo
chown majordomo:daemon $DMN/majordomo

mkdir $DMN/reply
chmod 700 $DMN/reply
chown mail:mail $DMN/reply

for p in `cat /usr/local/directadmin/data/users/$u/domains/$d.pointers 2>/dev/null`; do
{
echo "$p: $u"  >> /etc/virtual/domainowners
echo "$p" >> /etc/virtual/domains
ln -s $d /etc/virtual/$p
}
done;
}
done;
}
done;

chown mail:mail /etc/virtual/domains
chown mail:mail /etc/virtual/domainowners
chmod 644 /etc/virtual/domainowners
chmod 644 /etc/virtual/domains

Save this code to a script somewhere on your system, eg /root/fix.sh.  Chmod the script to 755, then run it:

chmod 755 /root/fix.sh
/root/fix.sh


5) Create misc. other files

cd /etc/virtual 
touch blacklist_domains whitelist_from use_rbl_domains bad_sender_hosts blacklist_senders whitelist_domains whitelist_hosts whitelist_senders 
echo 0 > limit 
mkdir usage 
chown mail:mail blacklist_domains whitelist_from use_rbl_domains bad_sender_hosts blacklist_senders whitelist_domains whitelist_hosts whitelist_senders limit usage


6) rebuild majordomo:

cd /usr/local/directadmin/scripts
./majordomo.sh


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 17932