sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #101587
Problemer med MySQL
Øverst er koden og nederst ouputet
Jeg har igen ikke haft mulighed for at køre de to løkker unden arrays med et
fungerende resultat har stillet dem tilbage igen. Ved ikke hvorfor. beklager
desuden får jeg følgende fejl
+ mysql -uroot -p""dummy""
ERROR at line 1: Unknown command '\''.
og længre nede
+ mysqladmin create test_tj_Juac_dk -utj -pu1PDgtO7Cw/kQ
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'tj'@'localhost' (using password: YES)'
ved
mysql -uroot -p${ROOTPASSWD} << EOT
create user \'$USRNME\' identified by \'${DBPASSWD}\';
grant all privileges on \'$UNDERSCORENAME\'.* to \'$USRNME\'@\'localhost\';
exit;
EOT
og ved
DBPASSWD_TMP=`cat "/home/${USRNME}/PUBLIC_HTML/DB_USER_PASSWD.txt"`
echo "${DBPASSWD_TMP}"
mysqladmin create ${UNDERSCORENAME} -u${USRNME} -p${DBPASSWD_TMP}
hjælp ønskes :)
Thomas :)
Her er hele koden
#!/bin/bash
set -x
#
ROOTPASSWD='dummy'
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 ${USRARRAY[@]}
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`
echo "${DBPASSWD}"
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 ${USRDOMNARRAY[@]}
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 ${USRNME}@${MNDOMN}
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
echo "${DBPASSWD}"
DBPASSWD_TMP=`cat "/home/${USRNME}/PUBLIC_HTML/DB_USER_PASSWD.txt"`
echo "${DBPASSWD_TMP}"
mysqladmin create ${UNDERSCORENAME} -u${USRNME} -p${DBPASSWD_TMP}
touch /home/${USRNME}/PUBLIC_HTML/${USRDOMN}.reserved
chown -R www-data:${USRNME} /home/${USRNME}/PUBLIC_HTML/
find /home/${USRNME}/PUBLIC_HTML/ -type f | xargs chmod -R 0644
find /home/${USRNME}/PUBLIC_HTML/ -type d | xargs chmod -R 0755
fi
done
done
Og her er outputet
debian:/media/disk# ./addsubdomain37
+ ROOTPASSWD=""dummy""
+ MNDOMN=juac.dk
+ MNDOMNUNDERSCORE=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 ']'
+ '[' '!' -e /home/tj/PUBLIC_HTML/DB_USER_PASSWD.txt ']'
++ mkpasswd qwerty
+ DBPASSWD=u1PDgtO7Cw/kQ
+ echo u1PDgtO7Cw/kQ
u1PDgtO7Cw/kQ
+ mysql -uroot -p""dummy""
ERROR at line 1: Unknown command '\''.
+ echo 'The username of the databases is tj. And the password for the
databases is u1PDgtO7Cw/kQ'
+ echo u1PDgtO7Cw/kQ
++ ls -l --format=single-column /home/tj/PUBLIC_HTML/
+ USRDOMNARRAY='DB_USER_PASSWD.txt
test
your_databases.txt'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=DB_USER_PASSWD.txt.tj.juac.dk
+ UNDERSCORENAME=DB_USER_PASSWD.txt_tj_Juac_dk
+ echo USRDOMN:DB_USER_PASSWD.txt
USRDOMN:DB_USER_PASSWD.txt
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/DB_USER_PASSWD.txt.reserved -a -d
/home/tj/PUBLIC_HTML/DB_USER_PASSWD.txt ']'
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=test.tj.juac.dk
+ UNDERSCORENAME=test_tj_Juac_dk
+ echo USRDOMN:test
USRDOMN:test
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/test.reserved -a -d
/home/tj/PUBLIC_HTML/test ']'
+ mkdir /usr/lib/cgi-bin/test_tj_Juac_dk
+ echo '<VirtualHost *:80>
ServerAdmin tj@xxxxxxx
ServerName www.test.tj.juac.dk
ServerAlias test.tj.juac.dk
DocumentRoot /home/tj/PUBLIC_HTML/test
# 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/test_tj_Juac_dk
# 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>'
+ /usr/sbin/a2ensite test_tj_Juac_dk
Enabling site test_tj_Juac_dk.
Run '/etc/init.d/apache2 reload' to activate new configuration!
+ echo '90.184.106.85 WWW.test.tj.juac.dk test.tj.juac.dk'
+ /etc/init.d/apache2 reload
Reloading web server config: apache2Warning: DocumentRoot
[/home/tj/PUBLIC_HTML/z] does not exist
Warning: DocumentRoot [/home/tj/PUBLIC_HTML/zz] does not exist
Warning: DocumentRoot [/home/tj/PUBLIC_HTML/zzz] does not exist
Warning: DocumentRoot [/home/tj/PUBLIC_HTML/zzzz] does not exist
.
+ echo u1PDgtO7Cw/kQ
u1PDgtO7Cw/kQ
++ cat /home/tj/PUBLIC_HTML/DB_USER_PASSWD.txt
+ DBPASSWD_TMP=u1PDgtO7Cw/kQ
+ echo u1PDgtO7Cw/kQ
u1PDgtO7Cw/kQ
+ mysqladmin create test_tj_Juac_dk -utj -pu1PDgtO7Cw/kQ
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'tj'@'localhost' (using password: YES)'
+ touch /home/tj/PUBLIC_HTML/test.reserved
+ chown -R www-data:tj /home/tj/PUBLIC_HTML/
+ find /home/tj/PUBLIC_HTML/ -type f
+ xargs chmod -R 0644
+ find /home/tj/PUBLIC_HTML/ -type d
+ xargs chmod -R 0755
+ for USRDOMN in '${USRDOMNARRAY[@]}'
+ LNK=your_databases.txt.tj.juac.dk
+ UNDERSCORENAME=your_databases.txt_tj_Juac_dk
+ echo USRDOMN:your_databases.txt
USRDOMN:your_databases.txt
+ echo USRNME:tj
USRNME:tj
+ '[' '!' -e /home/tj/PUBLIC_HTML/your_databases.txt.reserved -a -d
/home/tj/PUBLIC_HTML/your_databases.txt ']'
debian:/media/disk#