l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
May 5: Social gathering
Next Installfest:
Latest News:
Mar. 17: DavisGIG: municipal fiber for Davis
Page last updated:
2006 Feb 25 01:01

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] script for adding virtual domain to web/mail server
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] script for adding virtual domain to web/mail server

I have written this script for adding a virtual domain to a web/mail
server and I'd like some comments or suggestions.


if (($#==0)); then echo -e "Usage: vdomadd USERNAME DOMAIN
[PASSWORD]\nIf password field is 'auto', password will be generated, if
no argument is given login will be disabled, else PASSWORD will be set
as the parameter. If set, the user password is also the postmaster
password for that domain."; exit; fi


if grep $1 /etc/passwd > /dev/null ; then echo -e "Invalid, user
exists."; else
# makes the new account and user web directory
adduser --disabled-login $1
if (($#==3)) 
        if expr $3 : auto; then newpw=`pwgen`
        else newpw=$3
        echo "$1's password is: $newpw"
        echo "$1:$newpw" | chpasswd
else echo "Password parameter blank, login disabled."
chown -R $1:$1 /$USERDIRS/$1

#adds new line to /etc/hosts
echo -e "`getip.pl` $2 www.$2 mail.$2" >> /etc/hosts

# makes the apache virtual domain file
echo -e "#virtual domain configuration for $1
<VirtualHost www.$2>
ServerName www.$2
ServerAlias $2
TransferLog /var/log/apache2/$2/www/access.log
LogFormat combined

<VirtualHost mail.$2>
ServerName mail.$2
DocumentRoot /usr/share/squirrelmail/
TransferLog /var/log/apache2/$2/mail/access.log
LogFormat combined
" > /etc/apache2/sites-available/$2
mkdir /var/log/apache2/$2/www/
mkdir /var/log/apache2/$2/mail/
a2ensite $2
/etc/init.d/apache2 reload

touch /var/log/apache2/$2/www/access.log.0
mkdir /$USERDIRS/$1/$USERWEBROOT/stats/
# makes the webalizer configuration file
echo -e "#webalizer configuration for $2 virtual domain
LogFile /var/log/apache2/$2/www/access.log.0
OutputDir /$USERDIRS/$1/$USERWEBROOT/stats/
Hostname www.$2
" > /etc/webalizer.d/$2.conf

# adds domain to qmail
/home/vpopmail/bin/vadddomain $2 $newpw



http://www.fastmail.fm - IMAP accessible web-mail

vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.