Date: Thu, 11 Jul 2002 13:07:57 +0300 From: Odhiambo Washington <wash@wananchi.com> To: Viktor Lazlo <viktorlazlo@telus.net> Cc: FBSD-Q <freebsd-questions@freebsd.org> Subject: Re: Shell Script gurus?? Message-ID: <20020711100757.GG74698@ns2.wananchi.com> In-Reply-To: <20020705001634.C21920-100000@njam.dhs.org> References: <20020705062435.GK56027@ns2.wananchi.com> <20020705001634.C21920-100000@njam.dhs.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
* Viktor Lazlo <viktorlazlo@telus.net> [20020705 10:18]: wrote:
>
>
> > Hi Victor,
> >
> > That could have done it, except for the fact that after the first (.), we can
> > have com, net, org, biz, info, co.ke, go.ke, or.ke (as in wananchi.com)
> > What I wanted is to discard everything after the (.), not just com ;-)
> >
> > This one below does it:
> >
> > MYDOMAIN=`echo $domain_name | awk -F\. ' { print $1 } '`
>
> Just replace the com with .*:
>
> unbored=`echo $bored | sed -n 's/\..*//p'`
>
> But it doesn't really matter which you use, they both do the same thing.
>
> Cheers,
>
> Viktor
Hi Victor,
Let me ask a few questions while I still have your attention.
Please take a look at this script I have made and comment on it.
I know it's such a newbie thing, and even the PASSWORD line
doesn't work. It has no error checking <hehehee>.
The rest of the parts do work though.
I have a few problems with it:
1. I want it to enforce the entering of the popboxes
2. For some reason I cannot figure out, The line that does
for dom in $domain_name; do $PASSWORD $domain_name ${MYDOMAIN}pass1
doesn't work - because when I test the password after completion, if fails.
I think I am missing something. I want to make the initial password for freebsd.co.ke to be
freebsdpass1, for example.
3. Also, how can I make the script to modify the httpd.conf to add virtual host entry at the bottom?
My virtual host entry is something like this:
<VirtualHost *:80>
ServerName webmail.$domain_name
ServerAlias $domain_name
ServerAdmin admin@wananchi.com
DocumentRoot /usr/local/www/htdocs/virtual/$domain_name
ScriptAlias /cgi-bin/ "/usr/local/www/htdocs/virtual/$domain_name/cgi-bin/"
#CustomLog "| /usr/local/sbin/cronolog /var/log/apache/%Y/%m/%d/$MYDOMAIN.log" combined
<Directory /usr/local/www/htdocs/virtual/$domain_name/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
ErrorDocument 404 /missing.html
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
An experienced hand like you can help me with that, yes?
Thank you in advance.
-Wash
--
Odhiambo Washington <wash@wananchi.com> "The box said 'Requires
Wananchi Online Ltd. www.wananchi.com Windows 95, NT, or better,'
Tel: 254 2 313985-9 Fax: 254 2 313922 so I installed FreeBSD."
GSM: 254 72 743 223 GSM: 254 733 744 121 This sig is McQ! :-)
I have learned
To spell hors d'oeuvres
Which still grates on
Some people's n'oeuvres.
-- Warren Knox
[-- Attachment #2 --]
#!/usr/local/bin/bash
#This script is meant to automate the administration of domains under Domain
# Plus!
ADDING="/root/bin/vmail-sql/admin-tools/VE-domain add"
DEACTIVATE="/root/bin/vmail-sql/admin-tools/VE-domain remove"
MAILUSER="exim"
POPBOXES="/root/bin/vmail-sql/admin-tools/VE-domain popboxes"
FORWARDER="/root/bin/vmail-sql/admin-tools/VE-forwarder add"
PASSWORD="/root/bin/vmail-sql/admin-tools/VE-passwd"
#MYDOMAIN=`echo $domain_name | awk -F\. ' { print $1 } '`
MYDOMAIN=`echo $domain_name | sed -n 's/\..*//p'`
VIRTUALS="/usr/local/etc/apache/virtuals.conf"
PROTODOCROOT="/usr/local/www/htdocs/virtual/kaysalt.com"
DOCSDIR="/usr/local/www/htdocs/virtual"
while :
do
clear
echo
echo "1. Enter Domain into MySQL Db"
echo "2. Create domain entry in Apache virtuals.conf"
echo "3. Remove entry if you entered in error..."
echo "9. Exit"
echo
echo -n Please select one choice:
read choice
case "$choice" in
1)
clear
if [ $UID = 0 ]
then
echo Entering domain name in MySQL DB:
echo ""
echo "This script is very rudimentary and has no error checking"
echo "so be sure about what you are doing before touching that ENTER key!!"
echo ""
domain_name=
echo -n Please supply the domain name to activate:
read domain_name
if [ $domain_name ]
then
echo ""
echo "Please type your own name for logging purposes, i.e Wash:"
read name
echo ""
echo "Please enter the number of mailboxes to allocate. The default is 5."
echo "WARNING: You must enter a number here OR "unlimited" or we abort this"
echo "procedure at this point."
echo ""
read mailboxes
# ( date; echo ""; /bin/echo $domain_name; echo ""; \
( date; echo ""; echo Domain $domain_name was activated by: $name; \
echo -------------------------------------------------\
-------------------- ; echo "") | tee -a /var/log/domainplus.log
for dom in $domain_name; do $ADDING $domain_name $MAILUSER
done
echo "Assigning mailboxes ........"
for dom in $domain_name; do $POPBOXES $domain_name $mailboxes
done
echo "Adding default forwarder for $domain_name as vdom@wananchi.com ....."
for dom in $domain_name; do $FORWARDER $domain_name _default_ vdom@wananchi.com
done
echo "Assigning the password....."
for dom in $domain_name; do $PASSWORD $domain_name ${MYDOMAIN}pass1
done
fi
fi
;;
2)
clear
if [ $UID = 0 ]
then
echo Creating document root files for this domain.
echo ""
for dom in $domain_name; do /bin/cp -Rp ${PROTODOCROOT} ${DOCSDIR}/$domain_name
done
for dom in $domain_name; do /bin/mkdir /tmp/uebimiau/$domain_name
done
for dom in $domain_name; do /usr/sbin/chown www /tmp/uebimiau/$domain_name
done
echo ""
echo Process completed successfully.
echo ""
echo Now edit ${DOCSDIR}/$domain_name/config.php and substitute kaysalt.com with $domain_name.
echo After that you have to add a VirtualHost entry at the bottom of ${VIRTUALS},
echo then reload apache using the command apachectl graceful.
echo "Now is the time to edit the file..."
for name in $domain_name; do /usr/bin/vi ${DOCSDIR}/$domain_name/config.php
done
fi
;;
3) clear
if [ $UID = 0 ]
then
echo We will now remove the domain name you entered in error.....
echo Please be careful next time...
domain_name=
echo -n Please tell me the domain name to DEACTIVATE:
read domain_name
if [ $domain_name ]
then
echo Removing domain directories from /tmp/uebimiau ..
for dom in $domain_name; do /bin/rm -rf /tmp/uebimiau/$domain_name
done
for dom in $domain_name; do /bin/rm -rf ${DOCSDIR}/$domain_name
done
for dom in $domain_name; do ${DEACTIVATE} $domain_name
done
echo The $domain_name was sucessfully deactivated. Bye.
fi
fi
;;
9)
exit
;;
*)
echo -n b | tr 'b' '\007'
echo Invalid choice. Please try again.
;;
esac
echo
echo -n Press Return to Continue...
read wait
done
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020711100757.GG74698>
