Index: unix_installer/installer-package/bin/checkmysql.java =================================================================== diff -u --- unix_installer/installer-package/bin/checkmysql.java (revision 0) +++ unix_installer/installer-package/bin/checkmysql.java (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -0,0 +1,84 @@ +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; + +public class checkmysql +{ + private String version; + private String dbDriverClass; + private String dbDriverUrl; + private String dbUsername; + private String dbPassword; + + // Check that the mysql version is valid + public static void main(String[] args) throws SQLException + { + checkmysql me = new checkmysql(); + + if (args.length < 4) + { + System.out.println("Usage: Java checkmysql dbDriverUrl dbUsername dbPassword version"); + System.exit(1); + } + else + { + me.execute(args[0], args[1], args[2], args[3]); + } + } + + public void execute(String url, String user, String pass, String version) throws SQLException + { + + try{ + this.version = version; + this.dbDriverClass = "com.mysql.jdbc.Driver"; + this.dbDriverUrl = url; + this.dbUsername = user; + this.dbPassword = pass; + + Class.forName(dbDriverClass); + Connection conn = DriverManager.getConnection(dbDriverUrl, dbUsername, dbPassword); + conn.setAutoCommit(false); + PreparedStatement stmt = conn.prepareStatement("show variables where Variable_name=\"version\""); + ResultSet results = stmt.executeQuery(); + + if (results.first() == false) + { + throw new SQLException("No version row found in database"); + } + else + { + String dbVersion = results.getString("Value"); + if (dbVersion.contains(version) == false) + { + throw new SQLException("Your MySql Version: \"" + dbVersion + "\" is not compatible LAMS"); + } + else + { + System.out.println("MySql host is compatible with LAMS."); + } + + } + conn.close(); + } + catch (SQLException e) + { + System.out.println(e.getMessage()); + System.out.println("MySql check failed. Check that your MYSQL_HOST variable in lams.properties points to a MySql 5.x installation"); + System.exit(1); + } + catch (Exception e) + { + System.out.println(e.getMessage()); + System.out.println("Unknown failure finding MySql version"); + e.printStackTrace(); + System.exit(1); + } + } + +} Index: unix_installer/installer-package/bin/run-lams.sh =================================================================== diff -u -rc6a8998567722aec174bb639b1fb4d81dece93d8 -r9fd5236dbae4577a841b5e4de5132768436954d5 --- unix_installer/installer-package/bin/run-lams.sh (.../run-lams.sh) (revision c6a8998567722aec174bb639b1fb4d81dece93d8) +++ unix_installer/installer-package/bin/run-lams.sh (.../run-lams.sh) (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -26,7 +26,7 @@ echo " " echo "LAMS will take a few minutes to startup..." echo " " -echo "Check server/default/log/boot.log and server/default/log/server.log to see if LAMS has started correctly. The server.log will contain a line similar to 'JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)] Started in 1m:6s:987ms' when LAMS has finished loading." +echo "Check server/defalt/log/boot.log and server/defalt/log/server.log to see if LAMS has started correctly. The server.log will contain a line similar to 'JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)] Started in 1m:6s:987ms' when LAMS has finished loading." echo " " nohup ./run.sh > /dev/null & Index: unix_installer/upgrader-package/bin/UpdateLAMS202Chat.java =================================================================== diff -u --- unix_installer/upgrader-package/bin/UpdateLAMS202Chat.java (revision 0) +++ unix_installer/upgrader-package/bin/UpdateLAMS202Chat.java (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -0,0 +1,130 @@ +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 org.hibernate.Hibernate; +import org.hibernate.id.Configurable; +import org.hibernate.id.IdentifierGenerator; +import org.hibernate.id.UUIDHexGenerator; + +public class UpdateLAMS202Chat { + + private String XMPPConference; + private String dbDriverClass; + private String dbDriverUrl; + private String dbUsername; + private String dbPassword; + private String crPath; + + /** + * Dump out a list of all the nodes in the content repository, with their type and expected paths + * @throws Exception + */ + public static void main(String[] args) throws Exception { + UpdateLAMS202Chat me = new UpdateLAMS202Chat(); + + if (args.length < 4) + { + System.out.println("Usage: Java XMPPConference dbDriverUrl dbUsername dbPassword crPath"); + System.exit(1); + } + + String dbDriverUrl = args[0]; + String dbUsername = args[1]; + String dbPassword = args[2]; + String crPath = args[3]; + me.execute(dbDriverUrl, dbUsername, dbPassword, crPath); + } + + public void execute(String dbDriverUrl, String dbUsername, String dbPassword, String crPath) throws Exception { + + dbDriverClass = "com.mysql.jdbc.Driver"; + /* + dbDriverUrl = "jdbc:mysql://localhost/lams_demo?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useUnicode=true"; + dbUsername = "root"; + dbPassword = "secret4141"; + crPath = "/var/opt/lams/repository"; + */ + + this.dbDriverClass = dbDriverClass; + this.dbDriverUrl = dbDriverUrl; + this.dbUsername = dbUsername; + this.dbPassword = dbPassword; + this.crPath = crPath; + + String getChatSessions = "SELECT uid, jabber_room, room_created from tl_lachat11_session"; + String getXmppConference = "SELECT config_value FROM lams_configuration WHERE config_key='XmppConference'"; + String updateChatSessions = "UPDATE tl_lachat11_session set room_created=?, jabber_room=? where uid=?"; + + Class.forName(dbDriverClass); + Connection conn = DriverManager.getConnection(dbDriverUrl, dbUsername, dbPassword); + conn.setAutoCommit(false); + PreparedStatement stmt = conn.prepareStatement(getChatSessions); + ResultSet results = stmt.executeQuery(); + + // getting XmppConference value from db. + Statement xmppStmt = conn.createStatement(); + ResultSet xmppResult = xmppStmt.executeQuery(getXmppConference); + + if (xmppResult.next()) + { + XMPPConference = xmppResult.getString(1); + System.out.println(XMPPConference); + } + else + { + conn.close(); + System.out.println("Could not find XMPP Conference."); + System.exit(1); + } + + PreparedStatement stmtUpdate = conn.prepareStatement(updateChatSessions); + + IdentifierGenerator idGenerator = new UUIDHexGenerator(); + ((Configurable) idGenerator).configure(Hibernate.STRING, + new Properties(), null); + + while (results.next()) + { + Long uid = results.getLong("uid"); + Boolean room_created = results.getBoolean("room_created"); + String jabber_room = results.getString("jabber_room"); + + String set_jabber_room; + Boolean set_room_created; + // checking if jabber_room is null + if (results.wasNull()) { + // tool session was created by the room doesnt exist on the jabber server + // generating a unique jabber room name + set_room_created = false; + set_jabber_room = (String) idGenerator.generate(null, null) + "@" + XMPPConference; + + } else { + // jabber has already been created + set_room_created = true; + set_jabber_room = jabber_room; + } + + stmtUpdate.setBoolean(1, set_room_created); + stmtUpdate.setString(2, set_jabber_room); + stmtUpdate.setLong(3, uid); + stmtUpdate.addBatch(); + + System.out.print(uid + "\t"); + System.out.print(room_created + "\t"); + System.out.print(jabber_room + "\n"); + + } + + int[] upCount = stmtUpdate.executeBatch(); + + conn.commit(); + conn.close(); + } + +} \ No newline at end of file Index: unix_installer/upgrader-package/bin/checkmysql.java =================================================================== diff -u -r0965ee8a6bd49be2d53cad08225f707b32a61674 -r9fd5236dbae4577a841b5e4de5132768436954d5 --- unix_installer/upgrader-package/bin/checkmysql.java (.../checkmysql.java) (revision 0965ee8a6bd49be2d53cad08225f707b32a61674) +++ unix_installer/upgrader-package/bin/checkmysql.java (.../checkmysql.java) (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -1,89 +1,84 @@ +import java.io.File; import java.sql.Connection; +import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.DriverManager; +import java.sql.Statement; import java.util.Properties; -import java.io.*; +import java.sql.SQLException; public class checkmysql { - private String dbname, dbuser, dbpass, dburl; - - private static final String reqLamsVersion = "2.0"; - - public static void main(String args[]) + private String version; + private String dbDriverClass; + private String dbDriverUrl; + private String dbUsername; + private String dbPassword; + + // Check that the mysql version is valid + public static void main(String[] args) throws SQLException { - new checkmysql(); + checkmysql me = new checkmysql(); + + if (args.length < 4) + { + System.out.println("Usage: Java checkmysql dbDriverUrl dbUsername dbPassword version"); + System.exit(1); + } + else + { + me.execute(args[0], args[1], args[2], args[3]); + } } - - public checkmysql() + public void execute(String url, String user, String pass, String version) throws SQLException { - readProperties(); - System.out.println("Checking mysql installation"); - try - { - Class.forName("com.mysql.jdbc.Driver"); - Connection conn = DriverManager.getConnection(dburl, dbuser, dbpass); - PreparedStatement stmt = conn.prepareStatement("select config_value from lams_configuration where config_key=\"Version\""); - //PreparedStatement stmt = conn.prepareStatement("show tables"); - ResultSet result = stmt.executeQuery(); - - if (result.first()) + try{ + this.version = version; + this.dbDriverClass = "com.mysql.jdbc.Driver"; + this.dbDriverUrl = url; + this.dbUsername = user; + this.dbPassword = pass; + + 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\""); + ResultSet results = stmt.executeQuery(); + + if (results.first() == false) { - String currVersion = result.getString("config_value"); - if (currVersion.equals(reqLamsVersion)) + throw new SQLException("Could not find LAMS database using url: " + dbDriverUrl); + } + else + { + String dbVersion = results.getString("config_value"); + if (dbVersion.equals(version) == false) { - System.out.println("Mysql databse check completed\n\nCurrent lams version: " + result.getString("config_value")); + throw new SQLException("Your current LAMS version: " +dbVersion+ " is not compatible with this upgrade. Required version: " +version); } else { - throw new SQLException("The current LAMS version (LAMS " +currVersion+ " is not compatible with this update, LAMS " + reqLamsVersion+ " is required"); - + System.out.println("LAMS version is compatible with this upgrade.\n"); } } - else - { - throw new SQLException("Result for test set was empty, your lams database is not valid"); - } - + conn.close(); } catch (SQLException e) { - System.out.println("Error detecting mysql: " + e.getMessage()); - System.exit(1); + System.out.println(e.getMessage()); + System.out.println("Upgrade failed. LAMS database check failed.\n"); + System.exit(1); } - catch (ClassNotFoundException c) - { - System.out.println("Error: " + c.getMessage()); - c.printStackTrace(); + catch (Exception e) + { + System.out.println(e.getMessage()); + System.out.println("Upgrade failed. Unknown failure checking LAMS database version.\n"); + e.printStackTrace(); System.exit(1); } - + } - - public void readProperties() - { - try - { - Properties lamsProperties = new Properties(); - lamsProperties.load(new FileInputStream("lams.properties")); - dbname = lamsProperties.getProperty("DB_NAME"); - dbuser = lamsProperties.getProperty("DB_USER"); - dbpass = lamsProperties.getProperty("DB_PASS"); - dburl = "jdbc:mysql://localhost/" +dbname+ "?characterEncoding=utf8"; - - } - catch (IOException e) - { - - System.out.println("Error: " + e.getMessage()); - System.exit(1); - - } - } - - + } Index: unix_installer/upgrader-package/bin/copyllid.java =================================================================== diff -u --- unix_installer/upgrader-package/bin/copyllid.java (revision 0) +++ unix_installer/upgrader-package/bin/copyllid.java (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -0,0 +1,152 @@ +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Properties; +import java.sql.SQLException; +import java.sql.DriverManager; +import java.io.*; +import java.lang.Runtime; + + + +public class copyllid +{ + public static void main(String args[]) + { + System.out.println("Copying combined task language files"); + new copyllid(); + } + + + private String dbname, dbuser, dbpass, dburl, dbdriver, lliddir; + + private String forumScribe, resourceForum, chatScribe; + + private Connection conn; + + public copyllid() + { + dbdriver = "com.mysql.jdbc.Driver"; + + try + { + Properties lamsProperties = new Properties(); + lamsProperties.load(new FileInputStream("../lams.properties")); + + lliddir = lamsProperties.getProperty("JBOSS_DIR") + "/server/default/deploy/lams.ear/lams-dictionary.jar/org/lamsfoundation/lams/library/"; + dbuser = lamsProperties.getProperty("DB_USER"); + dbpass = lamsProperties.getProperty("DB_PASS"); + dbname = lamsProperties.getProperty("DB_NAME"); + dburl= lamsProperties.getProperty("SQL_URL"); + + } + catch (IOException e) + { + System.out.println(e.getMessage()); + } + + + try + { + Class.forName(dbdriver); + conn = DriverManager.getConnection(dburl, dbuser, dbpass); + + PreparedStatement stmt = null; + ResultSet result = null; + + + stmt = conn.prepareStatement ("select learning_library_id from lams_learning_library where title = \"Chat and Scribe\""); + result = stmt.executeQuery(); + + if (result.first()) + { + chatScribe = "llid" + result.getString("learning_library_id"); + } + + stmt = conn.prepareStatement ("select learning_library_id from lams_learning_library where title = \"Resources and Forum\""); + result = stmt.executeQuery(); + + if (result.first()) + { + resourceForum = "llid" + result.getString("learning_library_id"); + } + + stmt = conn.prepareStatement ("select learning_library_id from lams_learning_library where title = \"Forum and Scribe\""); + result = stmt.executeQuery(); + + if (result.first()) + { + forumScribe = "llid" + result.getString("learning_library_id"); + } + + } + catch (SQLException se) + { + System.out.println(se.getMessage()); + se.printStackTrace(); + } + catch (Exception e) + { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + + + chatScribe = lliddir + chatScribe; + resourceForum = lliddir + resourceForum; + forumScribe = lliddir + forumScribe; + + try + { + Runtime run = Runtime.getRuntime(); + run.exec("mkdir " + chatScribe); + run.exec("mkdir " + resourceForum); + run.exec("mkdir " + forumScribe); + + + copyFiles("../language-pack/library/ChatAndScribe/", chatScribe); + copyFiles("../language-pack/library/ForumAndScribe/", forumScribe); + copyFiles("../language-pack/library/ResourcesAndForum/", resourceForum); + } + catch (IOException e) + { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + + System.out.println("Language files for combined tasks successfully updated"); + } + + // The method copyFiles being defined + public static void copyFiles(String strPath, String dstPath) throws IOException + { + + File src = new File(strPath); + File dest = new File(dstPath); + + if (src.isDirectory()) + { + //if(dest.exists()!=true) + dest.mkdirs(); + String list[] = src.list(); + + for (int i = 0; i < list.length; i++) + { + String dest1 = dest.getAbsolutePath() + "/" + list[i]; + String src1 = src.getAbsolutePath() + "/" + list[i]; + copyFiles(src1 , dest1); + } + } + else + { + FileInputStream fin = new FileInputStream(src); + FileOutputStream fout = new FileOutputStream (dest); + int c; + while ((c = fin.read()) >= 0) + fout.write(c); + fin.close(); + fout.close(); + } + } + +} Index: unix_installer/upgrader-package/bin/lamsdump.sql =================================================================== diff -u -r0965ee8a6bd49be2d53cad08225f707b32a61674 -r9fd5236dbae4577a841b5e4de5132768436954d5 --- unix_installer/upgrader-package/bin/lamsdump.sql (.../lamsdump.sql) (revision 0965ee8a6bd49be2d53cad08225f707b32a61674) +++ unix_installer/upgrader-package/bin/lamsdump.sql (.../lamsdump.sql) (revision 9fd5236dbae4577a841b5e4de5132768436954d5) @@ -1 +1 @@ -/usr/bin//mysqldump -ulams -plamsdemo lams > /home/lfoxton/backup/lams.dump \ No newline at end of file +/usr/bin//mysqldump -ulamsuser -plamsdemo lamstest > /home/lfoxton/backup/lams.dump \ No newline at end of file