sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #101549
Re: Et lille script til test
Her er så noget af min kode. Jeg har brugt noget af Martins kode og
noget af mit "overkill" kode:
output ses længre nede.
Hverken din eller min apache kode virker.
" /etc/init.d/apache2 reload
# /usr/sbin/apachectl configtest && /usr/sbin/apachectl graceful
"
Der er desuden problemer med mysqladmin koden:
" + mysqladmin create tst3.tj.juac.dk -uroot -pVxO3rht6S8udQ
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
+ echo 'The username of the database tst3.tj.juac.dk is root. And the
password for the database is VxO3rht6S8udQ'
+ touch /home/tj/PUBLIC_HTML/tst3.reserved
"
Her er hele koden.
#!/bin/bash
set -x
#
MNDOMN='juac.dk'
IP=90.184.106.85
#
#for USRNME in /home/*
USRARRAY=$(ls -l --format=single-column /home/)
for USRNME in ${USRARRAY[@]}
do
DIR="/home/${USRNME}/PUBLIC_HTML"
if [ ! -d ${DIR} ];
then
mkdir ${DIR}
fi
# for USRDOMN in /home/${USRNME}/PUBLIC_HTML/*
USRDOMNARRAY=$(ls -l --format=single-column /home/${USRNME}/PUBLIC_HTML/)
for USRDOMN in ${USRDOMNARRAY[@]}
do
LNK=${USRDOMN}.${USRNME}.${MNDOMN}
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/${LNK}"
echo "<VirtualHost *:80>
ServerAdmin ${USRNME}@${MNDOMN}
ServerName www.${LNK}
ServerAlias ${LNK}
DocumentRoot ${DIR}/${USRDOMN}
# Set Document Root directory options
<Directory />
Options FollowSymlnks -Indexes Includes
# Allow use of .htaccess file
AllowOverride Limit FileInfo
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/${LNK}
# Set CGI-BIN directory options
<Directory /cgi-bin>
AllowOverride None
Options +ExecCGI -Multiviews +SymlnksIfOwnerMatch
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/${LNK}"
/usr/sbin/a2ensite ${LNK}
echo "${IP} WWW.${LNK} ${LNK}" >> /etc/hosts
/etc/init.d/apache2 reload
#/usr/sbin/apachectl configtest && /usr/sbin/apachectl graceful
dbpasswd=`mkpasswd qwerty`
mysqladmin create ${LNK} -uroot -p${dbpasswd}
echo "The username of the database ${LNK} is root. And the password
for the database is ${dbpasswd}" > "${DIR}/${LNK}.database.txt"
touch /home/${USRNME}/PUBLIC_HTML/${USRDOMN}.reserved
fi
done
done
Her er outputet fra mit program:
root@debian:/media/d644e576-b072-47d8-8f77-7b11448079b1# ./addsubdomain4
+ MNDOMN=juac.dk
+ IP=90.184.106.85
++ ls -l --format=single-column /home/
+ USRARRAY=tj
+ for USRNME in '${USRARRAY[@]}'
+ DIR=/home/tj/PUBLIC_HTML
+ '[' '!' -d /home/tj/PUBLIC_HTML ']'
++ ls -l --format=single-column /home/tj/PUBLIC_HTML/
+ USRDOMNARRAY='tst1
tst1.reserved
tst1.tj.juac.dk.database.txt
tst2
tst2.reserved
tst2.tj.juac.dk.database.txt
tst3'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst1.tj.juac.dk
+ echo USRDOMN:tst1
USRDOMN:tst1
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst1.reserved -a -d
/home/tj/PUBLIC_HTML/tst1 ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst1.reserved.tj.juac.dk
+ echo USRDOMN:tst1.reserved
USRDOMN:tst1.reserved
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst1.reserved.reserved -a -d
/home/tj/PUBLIC_HTML/tst1.reserved ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst1.tj.juac.dk.database.txt.tj.juac.dk
+ echo USRDOMN:tst1.tj.juac.dk.database.txt
USRDOMN:tst1.tj.juac.dk.database.txt
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst1.tj.juac.dk.database.txt.reserved
-a -d /home/tj/PUBLIC_HTML/tst1.tj.juac.dk.database.txt ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst2.tj.juac.dk
+ echo USRDOMN:tst2
USRDOMN:tst2
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst2.reserved -a -d
/home/tj/PUBLIC_HTML/tst2 ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst2.reserved.tj.juac.dk
+ echo USRDOMN:tst2.reserved
USRDOMN:tst2.reserved
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst2.reserved.reserved -a -d
/home/tj/PUBLIC_HTML/tst2.reserved ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst2.tj.juac.dk.database.txt.tj.juac.dk
+ echo USRDOMN:tst2.tj.juac.dk.database.txt
USRDOMN:tst2.tj.juac.dk.database.txt
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst2.tj.juac.dk.database.txt.reserved
-a -d /home/tj/PUBLIC_HTML/tst2.tj.juac.dk.database.txt ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=tst3.tj.juac.dk
+ echo USRDOMN:tst3
USRDOMN:tst3
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/tst3.reserved -a -d
/home/tj/PUBLIC_HTML/tst3 ']'
+ mkdir /usr/lib/cgi-bin/tst3.tj.juac.dk
+ echo '<VirtualHost *:80>
ServerAdmin tj@xxxxxxx
ServerName www.tst3.tj.juac.dk
ServerAlias tst3.tj.juac.dk
DocumentRoot /home/tj/PUBLIC_HTML/tst3
# Set Document Root directory options
<Directory />
Options FollowSymlnks -Indexes Includes
# Allow use of .htaccess file
AllowOverride Limit FileInfo
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/tst3.tj.juac.dk
# Set CGI-BIN directory options
<Directory /cgi-bin>
AllowOverride None
Options +ExecCGI -Multiviews +SymlnksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>'
+ /usr/sbin/a2ensite tst3.tj.juac.dk
Enabling site tst3.tj.juac.dk.
Run '/etc/init.d/apache2 reload' to activate new configuration!
+ echo '90.184.106.85 WWW.tst3.tj.juac.dk tst3.tj.juac.dk'
+ /etc/init.d/apache2 restart
Syntax error on line 8 of /etc/apache2/sites-enabled/tst1.tj.juac.dk:
Illegal option FollowSymlnks
Action 'configtest' failed.
The Apache error log may have more information.
failed!
++ mkpasswd qwerty
+ dbpasswd=VxO3rht6S8udQ
+ mysqladmin create tst3.tj.juac.dk -uroot -pVxO3rht6S8udQ
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
+ echo 'The username of the database tst3.tj.juac.dk is root. And the
password for the database is VxO3rht6S8udQ'
+ touch /home/tj/PUBLIC_HTML/tst3.reserved
root@debian:/home/tj/PUBLIC_HTML#
Mvh. Thomas
Follow ups
References