Changeset 1617
- Timestamp:
- 05/12/06 11:42:59 (2 years ago)
- Files:
-
- alternc/trunk/install/mysql.sh (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
alternc/trunk/install/mysql.sh
r889 r1617 1 #!/bin/sh -e1 #!/bin/sh 2 2 # 3 3 # $Id: mysql.sh,v 1.11 2006/01/11 22:51:28 anarcat Exp $ … … 29 29 # ---------------------------------------------------------------------- 30 30 # 31 rootlogin=$132 rootpass=$233 systemdb=$334 31 35 mysql="mysql --defaults-file=/etc/mysql/debian.cnf" 32 rootlogin="$1" 33 rootpass="$2" 34 systemdb="$3" 35 36 if [ -z "$rootlogin" -o -z "$rootpass" -o -z "$systemdb" ] 37 then 38 echo "Usage: mysql.sh <rootlogin> <rootpass> <systemdb>" 39 exit 1 40 fi 41 42 mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" 36 43 37 44 if ! $mysql mysql -e "SHOW TABLES" >/dev/null 38 45 then 39 46 # is this an upgrade then? 40 mysql=" mysql -u$rootlogin -p$rootpass"47 mysql="/usr/bin/mysql -u$rootlogin -p$rootpass" 41 48 if ! $mysql mysql -e "SHOW TABLES" >/dev/null 42 49 then … … 46 53 fi 47 54 48 echo "Setting AlternC $systemdb system table and privileges " 55 # The grant all is the most important right needed in this script. 56 # If this call fail, we may be connected to a mysql-server version 5.0. 57 echo "Granting users " 58 # In that case, change mysql parameters and retry. Use root / nopassword. 59 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 60 if [ "$?" -ne "0" ] 61 then 62 echo "You are using mysql 5.0, so we try with root account and no password since debian-sys-maint doesn't work." 63 mysql="/usr/bin/mysql -uroot " 64 echo "Granting users " 65 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 66 if [ "$?" -ne "0" ] 67 then 68 echo "Can't grant system user $rootlogin, abording"; 69 exit 1 70 fi 71 fi 72 73 # Now we can use rootlogin and rootpass. 74 mysql="/usr/bin/mysql -u$rootlogin -p$rootpass" 75 76 echo "Setting AlternC '$systemdb' system table and privileges " 49 77 $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;" 78 50 79 echo "Installing AlternC schema " 51 80 $mysql $systemdb < /usr/share/alternc/install/mysql.sql 52 81 53 echo "Granting users " 54 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 55 56 mysql -u $rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" 82 /usr/bin/mysql -u$rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!"
