[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [TEKNIK] Automatisk fremstilling af MySQL Databaser som root i BASH



Hej Martin.

Jeg har givet dig din vilje. :)
Der anvendes nu ikke længre arrays ved de pågældende løkker :)

Du har talent for at finde fejl. Vil du ikke nok se om du kan finde nogle fejl eller mangler der ødelægger funktionaliteten?

Her er koden:

#!/bin/bash
set -x
#
ROOTPASSWD='sencur'
MNDOMN='juac.dk'
MNDOMNUNDERSCORE='Juac_dk'
IP=90.184.106.85
#
for USRNME in /home/*
#USRARRAY=$(ls -l --format=single-column /home/)
#for USRNME in sslug@sslug
do
DIR="/home/${USRNME}/PUBLIC_HTML"
if [ ! -d ${DIR} ];
then
 mkdir ${DIR}
fi
if [ ! -e /home/${USRNME}/PUBLIC_HTML/DB_USER_PASSWD.txt ];
then
DBPASSWD=`mkpasswd qwerty`
mysql -uroot -p${ROOTPASSWD} << EOT
create user \'$USRNME\' identified by \'${DBPASSWD}\';
grant all privileges on \'$UNDERSCORENAME\'.* to \'$USRNME \'@\'localhost\';
exit;
EOT
echo "The username of the databases is ${USRNME}. And the password for the databases is ${DBPASSWD}" > "/home/${USRNME}/PUBLIC_HTML/your_databases.txt"
echo ${DBPASSWD} > "/home/${USRNME}/PUBLIC_HTML/DB_USER_PASSWD.txt"
fi
for USRDOMN in /home/${USRNME}/PUBLIC_HTML/*
# USRDOMNARRAY=$(ls -l --format=single-column /home/${USRNME}/PUBLIC_HTML/)
# for USRDOMN in sslug@sslug
do
 LNK=${USRDOMN}.${USRNME}.${MNDOMN}
 UNDERSCORENAME=${USRDOMN}_${USRNME}_${MNDOMNUNDERSCORE}
 echo "USRDOMN:"${USRDOMN}
 echo "USRNME:"${USRNME}
if [ ! -e /home/${USRNME}/PUBLIC_HTML/${USRDOMN}.reserved -a -d /home/${USRNME}/PUBLIC_HTML/${USRDOMN} ];
  then
  mkdir "/usr/lib/cgi-bin/${UNDERSCORENAME}"
  echo "<VirtualHost *:80>
ServerAdmin sslug@sslug
ServerName www.${LNK}
ServerAlias ${LNK}
DocumentRoot ${DIR}/${USRDOMN}
 # Set Document Root directory options
 <Directory />
   Options FollowSymlinks -Indexes Includes
   # Allow use of .htaccess file
   AllowOverride Limit FileInfo
 </Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/${UNDERSCORENAME}
 # Set CGI-BIN directory options
 <Directory /cgi-bin>
   AllowOverride None
   Options +ExecCGI -Multiviews +SymlinksIfOwnerMatch
   Order allow,deny
   Allow from all
 </Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>" > "/etc/apache2/sites-available/${UNDERSCORENAME}"
 /usr/sbin/a2ensite ${UNDERSCORENAME}
 echo "${IP} WWW.${LNK} ${LNK}" >> /etc/hosts
 #/etc/init.d/apache2 stop
 #/etc/init.d/apache2 start
 #/usr/sbin/apache2ctl configtest &&
 #/usr/sbin/apache2ctl graceful
 /etc/init.d/apache2 reload
 #DBPASSWD=`mkpasswd qwerty`
mysqladmin create ${UNDERSCORENAME} -u${USRNME} -p< "/home/${USRNME}/PUBLIC_HTML/DB_USER_PASSWD.txt" #echo "The username of the database ${UNDERSCORENAME} is ${USRNME}. And the password for the database is ${DBPASSWD}" > "${DIR}/${LNK}.txt"
 touch /home/${USRNME}/PUBLIC_HTML/${USRDOMN}.reserved
 fi
done
done

Hilsen Thomas :)

"Martin Møller Skarbiniks Pedersen" skrev i meddelelsen news:sslug@sslug

On Friday, 22 April 2011, Frank Damgaard <sslug@sslug> wrote:
On 2011-04-22 10:58, sslug@sslug wrote:
 ....


Men hvis man nu kunne få ls til kun at komme med mapper vil det være
bedre. Her tænker jeg på den inderste løkke.


nu ved jeg ikke lige hvilken inderste løkke du tænker på,
men du man da teste for directory med -d  :

 maybedir=.......
 if [ -d "$maybedir" ] ; then
     .....
 fi

Ja og evt. straks tage næste element i listen med continue, hvis
variablen f ikke peger på et directory. F.x.

for f in /home/*
do
  [ ! -d "$f" ] && continue
  echo $f
done

Hilsen Martin



--
--
Til uvedkommende, der læser med: Der er ingen grund til at læse min
mail. Jeg har intet at gøre med FARC, al-Jihad, al-Qaida, Hamas, Hizb
al-Mujahidin eller ETA. Jeg har aldrig gjort Zakat, går ikke ind for
Istishad, har ikke lavet en bilbombe eller kernevåben og jeg ved
dårligt nok, hvad Al Manar og бомба betyder.  Men tak for den udviste
interesse.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-05-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *