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>
next in thread | previous in thread | raw e-mail | index | archive | help
--AH+kv8CCoFf6qPuz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * 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 --AH+kv8CCoFf6qPuz Content-Type: application/x-sh Content-Disposition: attachment; filename="domainplus.sh" Content-Transfer-Encoding: quoted-printable #!/usr/local/bin/bash=0A=0A#This script is meant to automate the administra= tion of domains under Domain=0A# Plus!=0A=0AADDING=3D"/root/bin/vmail-sql/a= dmin-tools/VE-domain add"=0ADEACTIVATE=3D"/root/bin/vmail-sql/admin-tools/V= E-domain remove"=0AMAILUSER=3D"exim"=0APOPBOXES=3D"/root/bin/vmail-sql/admi= n-tools/VE-domain popboxes"=0AFORWARDER=3D"/root/bin/vmail-sql/admin-tools/= VE-forwarder add"=0APASSWORD=3D"/root/bin/vmail-sql/admin-tools/VE-passwd"= =0A#MYDOMAIN=3D`echo $domain_name | awk -F\. ' { print $1 } '`=0AMYDOMAIN= =3D`echo $domain_name | sed -n 's/\..*//p'`=0AVIRTUALS=3D"/usr/local/etc/ap= ache/virtuals.conf"=0APROTODOCROOT=3D"/usr/local/www/htdocs/virtual/kaysalt= .com"=0ADOCSDIR=3D"/usr/local/www/htdocs/virtual"=0A=0Awhile :=0Ado=0A=0Acl= ear=0Aecho=0Aecho "1. Enter Domain into MySQL Db"=0Aecho "2. Create domain = entry in Apache virtuals.conf"=0Aecho "3. Remove entry if you entered in er= ror..."=0Aecho "9. Exit"=0Aecho=0Aecho -n Please select one choice:=0Aread = choice=0A=0Acase "$choice" in=0A1) =0A clear=0A if [ $UID =3D 0 ]=0A = then=0A echo Entering domain name in MySQL DB:=0A echo ""=0A echo "= This script is very rudimentary and has no error checking"=0A echo "= so be sure about what you are doing before touching that ENTER key!!"=0A = echo ""=0A domain_name=3D=0A echo -n Please supply the d= omain name to activate:=0A read domain_name=0A if [ $domain_n= ame ]=0A then=0A echo ""=0A echo "Please type your own= name for logging purposes, i.e Wash:"=0A read name=0A echo "= "=0A echo "Please enter the number of mailboxes to allocate. The default is= 5."=0A echo "WARNING: You must enter a number here OR "unlimited" or we ab= ort this"=0A echo "procedure at this point."=0A echo ""=0A read mail= boxes=0A# ( date; echo ""; /bin/echo $domain_name; echo ""; \=0A ( da= te; echo ""; echo Domain $domain_name was activated by: $name; \=0A = echo -------------------------------------------------\=0A ---------= ----------- ; echo "") | tee -a /var/log/domainplus.log=0A for dom in $doma= in_name; do $ADDING $domain_name $MAILUSER=0A done=0A echo "Assigning mailb= oxes ........"=0A for dom in $domain_name; do $POPBOXES $domain_name $mailb= oxes=0A done=0A echo "Adding default forwarder for $domain_name as vdom@wan= anchi.com ....."=0A for dom in $domain_name; do $FORWARDER $domain_name _de= fault_ vdom@wananchi.com=0A done=0A echo "Assigning the password....."=0A f= or dom in $domain_name; do $PASSWORD $domain_name ${MYDOMAIN}pass1=0A = done=0A fi=0A fi=0A ;;=0A2)=0A clear=0A if [ $UID =3D 0 ]=0A = then =0A echo Creating document root files for this domain.=0A = echo ""=0A for dom in $domain_name; do /bin/cp -Rp ${PROTODOC= ROOT} ${DOCSDIR}/$domain_name=0A done=0A for dom in $domain_n= ame; do /bin/mkdir /tmp/uebimiau/$domain_name=0A done=0A for dom in $domain= _name; do /usr/sbin/chown www /tmp/uebimiau/$domain_name=0A done=0A = echo ""=0A echo Process completed successfully.=0A echo ""=0A= echo Now edit ${DOCSDIR}/$domain_name/config.php and substitute kay= salt.com with $domain_name.=0A echo After that you have to add a VirtualHos= t entry at the bottom of ${VIRTUALS},=0A echo then reload apache usi= ng the command apachectl graceful.=0A echo "Now is the time to edit the fil= e..."=0A for name in $domain_name; do /usr/bin/vi ${DOCSDIR}/$domain_name/c= onfig.php=0A done=0A fi=0A ;;=0A=0A=0A3) clear=0A if [ $UID =3D 0 ]=0A then= =0A echo We will now remove the domain name you entered in error.....=0A ec= ho Please be careful next time...=0A domain_name=3D=0A echo -n Pleas= e tell me the domain name to DEACTIVATE:=0A read domain_name=0A = if [ $domain_name ]=0A then=0A echo Removing domain directories = from /tmp/uebimiau ..=0A for dom in $domain_name; do /bin/rm -rf /tmp/uebim= iau/$domain_name=0A done=0A for dom in $domain_name; do /bin/rm -rf ${DOCSD= IR}/$domain_name=0A done=0A for dom in $domain_name; do ${DEACTIVATE} $doma= in_name=0A done=0A echo The $domain_name was sucessfully deactivated. Bye.= =0A fi=0A fi=0A ;;=0A9)=0A exit=0A ;;=0A*)=0A echo -n b | tr 'b' '\007'=0A = echo Invalid choice. Please try again.=0A ;;=0Aesac=0Aecho=0Aecho -n Press = Return to Continue...=0Aread wait=0Adone=0A --AH+kv8CCoFf6qPuz-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020711100757.GG74698>