Ticket #318: fix_318-6.diff
| File fix_318-6.diff, 21.6 kB (added by anarcat, 5 months ago) |
|---|
-
debian/postinst
old new 83 83 # Mail server hostname 84 84 DEFAULT_MX="" 85 85 86 # MySQL configuration 87 MYSQL_HOST="" 88 MYSQL_DATABASE="" 89 MYSQL_USER="" 90 MYSQL_PASS="" 86 # Note: MySQL username/password configuration now stored in /etc/alternc/mysql-root.cnf 87 91 88 # quels clients mysql sont permis (%, localhost, etc) 92 89 MYSQL_CLIENT="" 93 90 … … 119 116 update_var alternc/ns2 NS2_HOSTNAME 120 117 update_var alternc/bind_internal BIND_INTERNAL 121 118 update_var alternc/default_mx DEFAULT_MX 122 update_var alternc/mysql/host MYSQL_HOST123 update_var alternc/mysql/db MYSQL_DATABASE124 update_var alternc/mysql/user MYSQL_USER125 update_var alternc/mysql/password MYSQL_PASS126 119 update_var alternc/mysql/client MYSQL_CLIENT 127 120 update_var alternc/alternc_location ALTERNC_LOC 128 121 update_var alternc/mynetwork SMTP_RELAY_NETWORKS 129 122 sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp 130 123 mv -f $CONFIGFILE.tmp $CONFIGFILE 131 124 125 # Setup grants 126 db_get "alternc/mysql/host" 127 MYSQL_HOST="$RET" 128 if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then 129 # compatibility shims with my.cnf 130 host="$RET" 131 db_get "alternc/mysql/db" 132 database="$RET" 133 db_get "alternc/mysql/user" 134 user="$RET" 135 db_get "alternc/mysql/password" 136 password="$RET" 137 138 # we source (instead of forking) mysql.sh so that it gets the local environment above 139 . /usr/share/alternc/install/mysql.sh 140 fi 141 132 142 # forget the password 133 143 db_reset alternc/mysql/password || true 134 144 db_fset alternc/mysql/password "seen" "false" || true -
debian/postrm
old new 15 15 16 16 case "$1" in 17 17 purge) 18 rm -f /etc/alternc/local.sh /etc/alternc/ bureau.conf18 rm -f /etc/alternc/local.sh /etc/alternc/mysql.cnf /etc/alternc/bureau.conf 19 19 rm -f /var/backups/alternc/etc-installed.tar.gz 20 20 21 21 # Purge database? -
debian/changelog
old new 1 1 alternc (0.9.7+dev) stable; urgency=low UNRELEASED 2 2 3 * move mysql configuration into a valid MySQL configuration file 4 (/etc/alternc/mysql.cnf). This fixes a serious security issue (#318) 5 where the MySQL root password was passed on the commandline. Those 6 changes are pretty invasive and might break upgrades, cron jobs and 7 your cat... 3 8 * standardisation of the web interface, along with some esthetic changes, by 4 9 Marc Angles, sponsored by Koumbit 5 10 * styles can now be changed locally in admin/styles/base.css -
debian/config
old new 38 38 # source the current config 39 39 . /etc/alternc/local.sh 40 40 fi 41 if [ -r /etc/alternc/mysql.cnf ]; then 42 # make mysql configuration available as shell variables 43 # to convert from .cnf to shell syntax, we: 44 # * match only lines with "equal" in them (/=/) 45 # * remove whitespace around the = and add a left quote operator ' (;s) 46 # * add a right quote operator at the end of line (;s) 47 # * convert mysql variables into our MYSQL_ naming convention (;s) 48 # * print the result (;p) 49 eval `sed -n -e "/=/{s/ *= */='/;s/\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_LOGIN/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/mysql.cnf` 50 fi 41 51 42 52 # mettre les valeurs de local.sh comme "default" pour debconf 43 53 db_get alternc/hostingname -
bureau/class/local.php
old new 13 13 14 14 $config_file = fopen('/etc/alternc/local.sh', 'r'); 15 15 while (FALSE !== ($line = fgets($config_file))) { 16 if ( ereg('^([A-Z0-9_]*)="([^"]*)"', $line, $regs)) {16 if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) { 17 17 $GLOBALS['L_'.$regs[1]] = $regs[2]; 18 18 if (isset($compat[$regs[1]])) { 19 19 $GLOBALS['L_'.$compat[$regs[1]]] = $regs[2]; … … 22 22 } 23 23 24 24 fclose($config_file); 25 26 $config_file = fopen('/etc/alternc/mysql.cnf', 'r'); 27 while (FALSE !== ($line = fgets($config_file))) { 28 if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) { 29 switch ($regs[1]) { 30 case "user": 31 $GLOBALS['L_MYSQL_LOGIN'] = $regs[2]; 32 break; 33 case "password": 34 $GLOBALS['L_MYSQL_PWD'] = $regs[2]; 35 break; 36 case "host": 37 $GLOBALS['L_MYSQL_HOST'] = $regs[2]; 38 break; 39 case "database": 40 $GLOBALS['L_MYSQL_DATABASE'] = $regs[2]; 41 break; 42 } 43 } 44 } 45 46 fclose($config_file); -
src/functions.sh
old new 309 309 else 310 310 # implantons localement ce que nous avons besoin, puisque admintools 311 311 # n'est pas là 312 mysql - h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE-B -N -e \312 mysql --defaults-file=/etc/alternc/mysql.cnf -B -N -e \ 313 313 'SELECT a.login FROM membres a, sub_domaines b WHERE a.uid = b.compte AND \ 314 314 CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;' 315 315 fi -
src/basedir_prot.sh
old new 18 18 . /etc/alternc/local.sh 19 19 . /usr/lib/alternc/functions.sh 20 20 21 if [ -z "$MYSQL_HOST" ]22 then23 MYSQL_HOST="localhost"24 fi25 26 21 echo -n "adding open_base_dir protection for:" 27 22 # boucle sur tous les domaines hébergés, ou sur les arguments de la 28 23 # ligne de commande -
src/sqlbackup.sh
old new 29 29 30 30 set -e 31 31 32 # Get mysql user and password :33 . /etc/alternc/local.sh34 35 32 function dobck { 36 33 local ext 37 34 local i … … 63 60 mv -f "${target_dir}/${db}.sql${ext}" \ 64 61 "${target_dir}/${db}.sql.${i}${ext}" 2>/dev/null || true 65 62 if [ "$compressed" -eq 1 ]; then 66 mysqldump - h"$MYSQL_HOST" -u"$login" -p"$pass" "$db"--add-drop-table --allow-keywords -Q -f -q -a -e |63 mysqldump --defaults-file=/etc/alternc/mysql-alternc.cnf --add-drop-table --allow-keywords -Q -f -q -a -e | 67 64 gzip -c > "${target_dir}/${db}.sql${ext}" 68 65 else 69 mysqldump - h"$MYSQL_HOST" -u"$login" -p"$pass" "$db"--add-drop-table --allow-keywords -Q -f -q -a -e \66 mysqldump --defaults-file=/etc/alternc/mysql-alternc.cnf --add-drop-table --allow-keywords -Q -f -q -a -e \ 70 67 > "${target_dir}/${db}.sql" 71 68 fi 72 69 … … 83 80 mode=1 84 81 fi 85 82 86 /usr/bin/mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" \ 87 "$MYSQL_DATABASE" -B << EOF | tail -n '+2' | dobck 83 /usr/bin/mysql --defaults-file=/etc/alternc/mysql.cnf -B << EOF | tail -n '+2' | dobck 88 84 SELECT login, pass, db, bck_history, bck_gzip, bck_dir 89 85 FROM db 90 86 WHERE bck_mode=$mode; -
src/update_domains.sh
old new 74 74 75 75 . "$CONFIG_FILE" 76 76 77 if [ -z "$MYSQL_HOST" -o -z "$MYSQL_DATABASE" -o -z "$MYSQL_USER" -o \ 78 -z "$MYSQL_PASS" -o -z "$DEFAULT_MX" -o -z "$PUBLIC_IP" ]; then 77 if [ -z "$DEFAULT_MX" -o -z "$PUBLIC_IP" ]; then 79 78 echo "Bad configuration. Please use:" 80 79 echo " dpkg-reconfigure alternc" 81 80 exit 1 … … 96 95 HTTP_DNS="$DATA_ROOT/dns" 97 96 HTML_HOME="$DATA_ROOT/html" 98 97 99 MYSQL_SELECT="mysql -h${MYSQL_HOST} -u${MYSQL_USER} 100 -p${MYSQL_PASS} -Bs ${MYSQL_DATABASE}" 101 MYSQL_DELETE="mysql -h${MYSQL_HOST} -u${MYSQL_USER} 102 -p${MYSQL_PASS} ${MYSQL_DATABASE}" 98 MYSQL_SELECT="mysql --defaults-file=/etc/alternc/mysql-alternc.cnf -Bs " 99 MYSQL_DELETE="mysql --defaults-file=/etc/alternc/mysql-alternc.cnf " 103 100 104 101 ######################################################################## 105 102 # Functions -
src/fixperms.sh
old new 63 63 done 64 64 } 65 65 66 mysql - h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE"-B -e "select uid,login from membres" |grep -v ^uid|doone66 mysql --defaults-file=/etc/alternc/mysql.cnf -B -e "select uid,login from membres" |grep -v ^uid|doone 67 67 -
tools/get_domains_by_account
old new 74 74 # Have to get AlternC conf file : 75 75 ! [ -f "$ALTERNC_CONF_FILE" ] && { echo $MISSING_CONF_FILE ; exit 1 ; } || . $ALTERNC_CONF_FILE 76 76 # Must have access to mysql to retreive accounts owning domains : 77 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 78 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e"select count(*) from domaines_standby;" > /dev/null 2>&179 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e "77 mysql="$mysql --defaults-file=/etc/alternc/mysql.cnf -B -N -e" 78 $mysql "select count(*) from domaines_standby;" > /dev/null 2>&1 79 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 80 80 81 81 # Does the stuff 82 82 $mysql "select concat(a.sub, if(a.sub=\"\",\"\", \".\"), a.domaine) from sub_domaines a, membres b where a.compte = b.uid and b.login = \"${1}\";" -
tools/top_http_users
old new 168 168 # Have to get AlternC conf file : 169 169 [ -f "$ALTERNC_CONF_FILE" ] || { echo $MISSING_CONF_FILE ; exit 1 ; } && . $ALTERNC_CONF_FILE 170 170 # Must have access to mysql to retreive accounts owning domains : 171 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 172 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e "select count(*) from domaines_standby;" > /dev/null 2>&1 173 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e " 174 171 mysql="$mysql --defaults-file=/etc/alternc/mysql.cnf -B -N -e" 172 $mysql "select count(*) from domaines_standby;" > /dev/null 2>&1 173 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 175 174 # Prevents executing more than one shell at the same time 176 175 $lockfilecreate --retry 1 $LOCK_FILE 177 176 if [ $? != 0 ] -
tools/get_account_by_domain
old new 75 75 [ "$1" = "-h" ] || [ "$1" = "--help" ] && { echo $HELP ; echo $USAGE ; exit 0 ; } 76 76 # Have to get AlternC conf file : 77 77 ! [ -f "$ALTERNC_CONF_FILE" ] && { echo $MISSING_CONF_FILE ; exit 1 ; } || . $ALTERNC_CONF_FILE 78 # Must have access to mysql to retreive accounts owning domains : 79 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 80 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e "select count(*) from domaines_standby;" > /dev/null 2>&1 81 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e " 78 mysql="$mysql --defaults-file=/etc/alternc/mysql.cnf" 79 $mysql -e "select count(*) from domaines_standby;" > /dev/null 2>&1 80 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 82 81 83 82 # Does the stuff 84 $mysql "select concat(a.login, \" (\", a.mail, \")\") from membres a, sub_domaines b where a.uid = b.compte and concat(if(sub=\"\", \"\", concat(sub, \".\")), domaine) = \"${1}\";"83 $mysql -B -N -e "select concat(a.login, \" (\", a.mail, \")\") from membres a, sub_domaines b where a.uid = b.compte and concat(if(sub=\"\", \"\", concat(sub, \".\")), domaine) = \"${1}\";" 85 84 86 85 -
install/alternc.install
old new 5 5 # on a new server. THIS SCRIPT ERASE ALL DATA ON THE AlternC SYSTEM !! 6 6 # YOU HAVE BEEN WARNED ! 7 7 8 # This script now assumes it has MySQL connectivity through 9 # /etc/alternc/mysql.cnf 10 8 11 set -e 9 12 10 13 . /usr/lib/alternc/functions.sh … … 78 81 79 82 . /etc/alternc/local.sh 80 83 84 # XXX: copy-paste from debian/config 85 if [ -r /etc/alternc/mysql.cnf ]; then 86 # make mysql configuration available as shell variables 87 # to convert from .cnf to shell syntax, we: 88 # * match only lines with "equal" in them (/=/) 89 # * remove whitespace around the = and add a left quote operator ' (;s) 90 # * add a right quote operator at the end of line (;s) 91 # * convert mysql variables into our MYSQL_ naming convention (;s) 92 # * print the result (;p) 93 eval `sed -n -e "/=/{s/ *= */='/;s/\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_LOGIN/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/mysql.cnf` 94 fi 95 81 96 WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again." 82 97 83 98 VERSION="`dpkg -s alternc | sed -n -e 's/^Version: \(.*\)/\1/p'`" … … 101 116 MONITOR_IP="127.0.0.1" 102 117 fi 103 118 104 SED_SCRIPT=" 119 # XXX: I assume this is secure if /tmp is sticky (+t) 120 # we should have a better way to deal with templating, of course. 121 SED_SCRIPT=`mktemp` 122 cat > $SED_SCRIPT <<EOF 105 123 s\\%%hosting%%\\$HOSTING\\; 106 124 s\\%%fqdn%%\\$FQDN\\; 107 125 s\\%%public_ip%%\\$PUBLIC_IP\\; … … 121 139 s\\%%fqdn_lettre%%\\$FQDN_LETTER\\; 122 140 s\\%%version%%\\$VERSION\\; 123 141 s\\%%ns2_ip%%\\$NS2_IP\\; 124 " 142 EOF 125 143 126 144 ####################################################################### 127 145 # Backup configuration files … … 145 163 for file in $CONFIG_FILES; do 146 164 TEMPLATE="$TEMPLATE_DIR/${file##etc/}" 147 165 if [ -f "$TEMPLATE" ]; then 148 sed - e"$SED_SCRIPT" < $TEMPLATE > /$file166 sed -f "$SED_SCRIPT" < $TEMPLATE > /$file 149 167 fi 150 168 done 169 rm -f $SED_SCRIPT 151 170 152 171 ####################################################################### 153 172 # Save installed files to check them during next install 154 173 # 155 174 tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES 156 175 157 ######################################################################158 # Initialize database159 #160 if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then161 echo "Setup MySQL and database..."162 /usr/share/alternc/install/mysql.sh "$MYSQL_HOST" "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE"163 fi164 165 176 ######################################################################## 166 177 # Ad-hoc fixes 167 178 # … … 263 274 /usr/lib/alternc/basedir_prot.sh 264 275 265 276 # Creating admin user if needed 266 HAS_ROOT= "`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1`"277 HAS_ROOT=`mysql --defaults-file=/etc/alternc/mysql.cnf -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1` 267 278 if [ "$HAS_ROOT" != "1" ]; then 268 279 echo "Creating admin user..." 269 280 echo "" -
install/upgrade_check.sh
old new 45 45 # run the proper program to interpret the upgrade script 46 46 case "$ext" in 47 47 sql) 48 mysql -f - h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASS $MYSQL_DATABASE\48 mysql -f --defaults-file=/etc/alternc/mysql.cnf \ 49 49 < $file || true 50 50 ;; 51 51 php) -
install/mysql.sh
old new 1 #!/bin/sh 1 #!/bin/sh 2 2 # 3 3 # $Id: mysql.sh,v 1.11 2006/01/11 22:51:28 anarcat Exp $ 4 4 # ---------------------------------------------------------------------- … … 28 28 # USAGE : "mysql.sh loginroot passroot systemdb" 29 29 # ---------------------------------------------------------------------- 30 30 # 31 32 # This script expects the following environment to exist: 33 # * host 34 # * user 35 # * password 36 # * database 37 # 38 # XXX: the sed script should be generated here 39 # 40 # So this file should generally be sourced like this: 41 # . /usr/share/alternc/install/mysql.sh 42 # 43 # Those values are used to set the username/passwords... 31 44 32 sqlserver="$1" 33 rootlogin="$2" 34 rootpass="$3" 35 systemdb="$4" 45 # The grant all is the most important right needed in this script. 46 echo "Granting users..." 47 cat <<EOF 48 host: $host 49 user: $user 50 password: $password 51 database: $database 52 EOF 36 53 37 if [ -z "$rootlogin" -o -z "$rootpass" -o -z "$systemdb" ] 38 then 39 echo "Usage: mysql.sh <mysqlserver> <rootlogin> <rootpass> <systemdb>" 40 exit 1 41 fi 54 MYSQL_CONFIG="/etc/alternc/mysql.cnf" 42 55 43 mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -h$sqlserver " 56 . /etc/alternc/local.sh 57 grant="GRANT ALL ON *.* TO '$user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$password' WITH GRANT OPTION" 44 58 45 # The grant all is the most important right needed in this script. 59 echo -n "Trying debian.cnf: " 60 mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" 46 61 # If this call fail, we may be connected to a mysql-server version 5.0. 47 echo "Granting users " 48 # In that case, change mysql parameters and retry. Use root / nopassword. 49 $ mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"50 if [ "$?" -ne "0" ] 62 # In that case, change mysql parameters and retry. Use root / nopassword. 63 if ! $mysql <<EOF 64 $grant 65 EOF 51 66 then 52 echo "debian-sys-maintainer doesn't have the right credentials, assuming we're doing an upgrade" 53 mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass" 54 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 55 if [ "$?" -ne "0" ] 56 then 57 echo "Still not working, assuming clean install and empty root password" 58 mysql="/usr/bin/mysql -h$sqlserver -uroot " 59 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 60 if [ "$?" -ne "0" ] 67 echo "failed: debian-sys-maintainer doesn't have the right credentials" 68 echo -n "are we doing an upgrade? " 69 mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" 70 if ! $mysql <<EOF 71 $grant 72 EOF 73 then 74 echo "No" 75 echo -n "Assuming clean install (empty root password)... " 76 mysql="/usr/bin/mysql -h$host -uroot " 77 if ! $mysql <<EOF 78 $grant 79 EOF 61 80 then 62 echo "Can't grant system user $rootlogin, aborting"; 63 exit 1 81 echo "Failed" 82 echo -n "Assuming pre 0.9.8 version... " 83 mysql="/usr/bin/mysql -h$MYSQL_HOST -u$MYSQL_LOGIN -p$MYSQL_PASS" 84 if ! $mysql <<EOF 85 $grant 86 EOF 87 then 88 echo "No." 89 echo "Can't grant system user $user, aborting"; 90 exit 1 91 fi 64 92 fi 65 93 fi 66 94 fi 95 echo "ok!" 67 96 68 # Now we can use rootlogin and rootpass. 69 mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass" 97 if [ -f $MYSQL_CONFIG ]; then 98 echo "Updating mysql configuration in $MYSQL_CONFIG" 99 else 100 echo "Creating mysql configuration in $MYSQL_CONFIG" 101 cat > $MYSQL_CONFIG <<EOF 102 # AlternC - Web Hosting System - MySQL Configuration 103 # Automatically generated by AlternC configuration, do not edit 104 # This file will be modified on package configuration 105 # (e.g. upgrade or dpkg-reconfigure alternc) 106 [client] 107 EOF 108 chown root:www-data $MYSQL_CONFIG 109 chmod 640 $MYSQL_CONFIG 110 fi 70 111 71 echo "Setting AlternC '$systemdb' system table and privileges " 72 $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;" 112 # create a sed script to create/update the file 113 function set_value() { 114 var=$1 115 RET=$2 116 grep -Eq "^ *$var=" $MYSQL_CONFIG || echo "$var=" >> $MYSQL_CONFIG 117 SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\" 118 } 73 119 74 echo "Installing AlternC schema " 75 $mysql $systemdb < /usr/share/alternc/install/mysql.sql 120 SED_SCRIPT="" 121 # hostname was empty in older (pre-0.9.6?) versions 122 if [ -z "$host" ]; then 123 host="localhost" 124 fi 125 set_value host $host 126 set_value database $database 127 set_value user $user 128 set_value password $password 76 129 77 /usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" 130 # take extra precautions here with the mysql password: 131 # put the sed script in a temporary file 132 SED_SCRIPT_NAME=`mktemp` 133 cat > $SED_SCRIPT_NAME <<EOF 134 $SED_SCRIPT 135 EOF 136 sed -f "$SED_SCRIPT_NAME" < $MYSQL_CONFIG > $MYSQL_CONFIG.$$ 137 mv -f $MYSQL_CONFIG.$$ $MYSQL_CONFIG 138 rm -f $SED_SCRIPT_NAME 139 140 echo "Checking for MySQL connectivity" 141 # Now we should be able to use the mysql configuration 142 mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" 143 144 $mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" 145 146 # Final mysql setup: db schema 147 148 echo "installing AlternC schema in $database..." 149 $mysql -e "CREATE DATABASE IF NOT EXISTS $database;" || echo cannot create database 150 $mysql < /usr/share/alternc/install/mysql.sql || echo cannot load database schema
