Index: macosx_installer/lams/db/README.txt =================================================================== diff -u -r9226515349726d34eda36d3c75da8b9351c8c72c -rd25a496da6000fcffc569f2611183c953a9e3977 --- macosx_installer/lams/db/README.txt (.../README.txt) (revision 9226515349726d34eda36d3c75da8b9351c8c72c) +++ macosx_installer/lams/db/README.txt (.../README.txt) (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -1,9 +1,10 @@ If you need to reset LAMS, you should be able to run this script but take into account that this WILL WIPE OUT ALL THE EXISTING INFORMATION!! - /usr/local/lams/ant/bin/ant -v -logfile database.log insert-data +If you want to change any db settings, modify the db.properties file accodingly. -Note that if the MySQL password is *not* blank, then you should change this in the db.properties file. + /usr/local/lams/ant/bin/ant -v -logfile database.log insert-data + If you have questions or comments: http://lamscommunity.org Thanks Index: macosx_installer/lams/db/addrootpass.sh =================================================================== diff -u --- macosx_installer/lams/db/addrootpass.sh (revision 0) +++ macosx_installer/lams/db/addrootpass.sh (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -0,0 +1,22 @@ +unset -v input + +input="$(/usr/bin/osascript 2>/dev/null <<-'__HEREDOC__' + with timeout of 300 seconds + tell application "Finder" + activate + set Input to display dialog "Please enter your MySQL Root password:" \ + with title "Password" \ + with icon caution \ + default answer "" \ + buttons {"Cancel", "OK"} \ + default button 2 \ + with hidden answer \ + giving up after 295 + return text returned of Input as string + end tell + end timeout +__HEREDOC__ +)" + +echo "db.root.password=${input}" >> db.properties + Index: macosx_installer/lams/db/checkmysqlversion.class =================================================================== diff -u Binary files differ Index: macosx_installer/lams/db/checkmysqlversion.java =================================================================== diff -u --- macosx_installer/lams/db/checkmysqlversion.java (revision 0) +++ macosx_installer/lams/db/checkmysqlversion.java (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -0,0 +1,101 @@ +import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Properties; +import java.sql.SQLException; +import java.net.UnknownHostException; + +public class checkmysqlversion +{ + private String dbDriverClass; + private String dbDriverUrl; + private String dbUsername; + private String dbPassword; + + private double minMysqlVersion; + + // Check that the mysql version is valid + public static void main(String[] args) throws SQLException, UnknownHostException + { + // System.out.println("Java program invoked"); + checkmysqlversion me = new checkmysqlversion(); + + // System.out.println("args.length: " + args.length); + if (args.length < 3) + { + System.out.println("Usage: Java checkmysqlversion dbDriverUrl dbUsername dbPassword"); + System.exit(1); + } + else + { + try + { + me.execute(args[0], args[1], args[2]); + } + catch (UnknownHostException e) + { + System.out.println("MySql Host is not valid, please enter a new value"); + System.exit(1); + } + } + } + + public void execute(String url, String user, String pass) throws SQLException, UnknownHostException + { + try{ + this.dbDriverClass = "com.mysql.jdbc.Driver"; + this.dbDriverUrl = url; + this.dbUsername = user; + //this.dbPassword = pass; + this.minMysqlVersion = 5.0; + + if (pass != null) {this.dbPassword = pass;} + else {this.dbPassword = "";} + + + Class.forName(dbDriverClass); + Connection conn = DriverManager.getConnection(dbDriverUrl, dbUsername, dbPassword); + conn.setAutoCommit(false); + //PreparedStatement stmt = conn.prepareStatement("SELECT * FROM lams_configuration WHERE config_key= \"Version\""); + PreparedStatement stmt = conn.prepareStatement("SHOW variables WHERE Variable_name=\"version\""); + ResultSet results = stmt.executeQuery(); + + if (results.first() == false) + { + throw new SQLException("Could not find mysql version using url: " + dbDriverUrl); + } + else + { + String mysqlVersion = results.getString("Value"); + // If mysqlversion >= 5.0 + if (Double.parseDouble(mysqlVersion.substring(0,3)) >= minMysqlVersion ) + { + System.out.println("MySQL version " + mysqlVersion + " is compatible with this version of LAMS."); + } + else + { + throw new SQLException("The MySQL version you are attemping to use: " +mysqlVersion+ " is not compatible with this version of LAMS. Required version: " + minMysqlVersion); + } + } + conn.close(); + } + catch (SQLException e) + { + System.out.println(e.getMessage()); + // System.out.println("\nMySQL check failed. Please check your root password.\n"); + System.exit(1); + } + + catch (Exception e) + { + System.out.println(e.getMessage()); + System.out.println("\nUnknown failure checking MySQL version.\n"); + e.printStackTrace(); + System.exit(1); + } + } + +} Index: macosx_installer/lams/db/db.properties =================================================================== diff -u -rffeee04c40065337d8a96fb849feebaeff6cfa44 -rd25a496da6000fcffc569f2611183c953a9e3977 --- macosx_installer/lams/db/db.properties (.../db.properties) (revision ffeee04c40065337d8a96fb849feebaeff6cfa44) +++ macosx_installer/lams/db/db.properties (.../db.properties) (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -18,17 +18,15 @@ # http://www.gnu.org/licenses/gpl.txt # project-wide properties +project=LAMS lams_version=2.3.5 #database access db.host=localhost db.name=lams2 db.driver=com.mysql.jdbc.Driver db.encoding=utf8 -db.root.password= -db.username=root -db.password= +db.username=lams +db.password=lamsdemo db.driver.jar=/usr/local/lams/jboss-4.0.2/server/default/deploy/lams.ear/mysql-connector-java-5.0.8-bin.jar -db.schema= -db.catalog= -db.script=lams2.3.5.sql \ No newline at end of file +db.script=lams2.3.5.sql Index: macosx_installer/lams/db/dbcheck.sh =================================================================== diff -u --- macosx_installer/lams/db/dbcheck.sh (revision 0) +++ macosx_installer/lams/db/dbcheck.sh (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -0,0 +1,16 @@ +#!/bin/sh + +cd /usr/local/lams/db/ +# Let's check if the root password is blank +export blank_password=`java -cp .:/usr/local/lams/jboss-4.0.2/server/default/deploy/lams.ear/mysql-connector-java-5.0.8-bin.jar checkmysqlversion jdbc:mysql://localhost/ root ''` + +echo "$blank_password" > database.log + +if echo "$blank_password" |grep "is compatible" > /dev/null 2>&1; +then + echo "db.root.password=" >> db.properties + /usr/local/lams/db/dbscript.sh +else + /usr/local/lams/db/addrootpass.sh + /usr/local/lams/db/dbscript.sh +fi \ No newline at end of file Index: macosx_installer/lams/db/dbscript.sh =================================================================== diff -u -r9226515349726d34eda36d3c75da8b9351c8c72c -rd25a496da6000fcffc569f2611183c953a9e3977 --- macosx_installer/lams/db/dbscript.sh (.../dbscript.sh) (revision 9226515349726d34eda36d3c75da8b9351c8c72c) +++ macosx_installer/lams/db/dbscript.sh (.../dbscript.sh) (revision d25a496da6000fcffc569f2611183c953a9e3977) @@ -2,4 +2,5 @@ cd /usr/local/lams/db/ /usr/local/lams/ant/bin/ant -logfile database.log insert-data -mv -f /usr/local/lams/LAMS\ 2\ Server.app /Applications +unzip /usr/local/lams/app/app.zip -d /Applications +/usr/bin/open /Applications/LAMS\ 2\ Server.app