l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2006 Feb 24 15:46

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)
Re: [vox-tech] script for adding virtual domain to web/mail server
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

---------- Original Message ----------------------------------
From: "Nick Schmalenberger" <nschmalenberger@fastmail.fm>
Reply-To: "lugod's technical discussion forum" <vox-tech@lists.lugod.org>
Date:  Fri, 24 Feb 2006 03:37:32 -0800

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

This is a keeper. Thanks! Some comments:
Assign $1, $2, etc. to clear variable names. ($2 is assigned
to USERWEBROOT, but then $2 is referenced in the code.)
By the way, what is a "user web root"?

"/var/log/apache2" is probably an Apache variable that
can be changed in "/etc/apache/httpd.conf". Therefore,
it should be a constant in this script, in case it changes.

Hope that helps.

I have a question: What is the "user" when a virtual domain
is added to your system?

>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
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:
Sunset Systems
Who graciously hosts our website & mailing lists!