Add to Favourites Add to Favourites    Print this Article Print this Article

How to completely rebuild your /etc/virtual directory

1) Make a backup of the current /etc/virtual directory.

cd /etc
cp -Rp virtual virtual.backup

2) Ensure it exists:

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

3) Create the following script


echo -n '' > /etc/virtual/domains
echo -n '' > /etc/virtual/domainowners

mkdir -p /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


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

               touch $DMN/aliases
               if [ ! -s $DMN/aliases ]; then
                       echo "$u: $u" > $DMN/aliases
               touch $DMN/autoresponder.conf
               touch $DMN/filter
               touch $DMN/filter.conf
               touch $DMN/passwd
               touch $DMN/quota
               touch $DMN/vacation.conf
               chown mail:mail $DMN/*

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

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

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

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/  Chmod the script to 755, then run it:

chmod 755 /root/

4) Create other related email files, and update your exim.conf:

5) rebuild majordomo:

cd /usr/local/directadmin/scripts

Was this answer helpful?

Also Read