How to completely rebuild your /etc/virtual directory

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » Email » Repair Broken or Missing

How to completely rebuild your /etc/virtual directoryLast Modified: Feb 16, 2016, 10:28 am
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

Related Helpfiles
My /etc/virtual/domainowners file is empty. How do I rebuild it?
My /etc/virtual/domains file is empty. How do I rebuild it?

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST