From 66c2440778830d0e7f55fadc6d5cdf8192522a6b Mon Sep 17 00:00:00 2001 From: Russell Maclean Date: Sat, 9 May 2015 17:58:40 +1000 Subject: [PATCH 1/2] Fixes broken installation script/Trovebox UI Setup issue which prevented installation/setup The current sciprt does not touch the DB. The UI setup fails, As it attempts to access a user table while at the same time instructing you to create a blank DB. https://github.com/photo/frontend/issues/1572 The SQL is taken from https://github.com/photo/frontend/blob/master/src/configs/upgrade/db/mysql/mysql-base.php#L294-L303. The script will give you 3 changes to get your password right before providing instructions and SQL to the user on how to manually resolve the db schema issue once they have the password. --- .../guides/InstallationUbuntuApache.sh | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/documentation/guides/InstallationUbuntuApache.sh b/documentation/guides/InstallationUbuntuApache.sh index 4e9044398..108af10d6 100755 --- a/documentation/guides/InstallationUbuntuApache.sh +++ b/documentation/guides/InstallationUbuntuApache.sh @@ -129,6 +129,66 @@ else IP=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` fi +echo "" +echo "" +echo "====================================================" +echo "Generating required database/User table" +echo "====================================================" +echo "" +echo "" + +echo "Enter your mysql database name" +read DATABASE_NAME +echo "Attempting to create" +DBFAIL=false +mysql -u root -t -p -e "CREATE DATABASE $DATABASE_NAME;" 2>&1 >/dev/null | grep -i error && \ +echo "Error try again." && \ +mysql -u root -t -p -e "CREATE DATABASE $DATABASE_NAME;" 2>&1 >/dev/null | grep -i error && \ +echo "Error try again." && \ +mysql -u root -t -p -e "CREATE DATABASE $DATABASE_NAME;" 2>&1 >/dev/null | grep -i error && DBFAIL=true + +if [ $DBFAIL == true ]; then +echo "" && \ +echo "" && \ +echo "Error if root password is incorrect Rerun script or manually configure DB with the below sql after you have configured your password, If db exists, rerun with new dbname" && \ +echo "" && \ +echo "" && \ +echo "CREATE TABLE IF NOT EXISTS user ( + id varchar(255) NOT NULL COMMENT 'Users email address', + password varchar(64) NOT NULL, + extra text NOT NULL, + timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" + +else + +echo "" +echo "" +echo "Created $DATABASE_NAME, Now creating user table" +echo "" +echo "" +echo "Generating user table" +echo "" +echo "" +mysql -u root -t -p $DATABASE_NAME << SQL + CREATE TABLE IF NOT EXISTS user ( + id varchar(255) NOT NULL COMMENT 'Users email address', + password varchar(64) NOT NULL, + extra text NOT NULL, + timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL +if [ $? -eq 0 ];then +echo "" +echo "" +echo "DB created, User table created" +fi +fi +echo "" +echo "" + echo "" echo "" echo "" From 11eaf59753d85b924e4a5b2404ed36ad5abefbc6 Mon Sep 17 00:00:00 2001 From: Russell Maclean Date: Sat, 9 May 2015 18:09:43 +1000 Subject: [PATCH 2/2] Removing uneeded iftrue's --- documentation/guides/InstallationUbuntuApache.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/guides/InstallationUbuntuApache.sh b/documentation/guides/InstallationUbuntuApache.sh index 108af10d6..77725631d 100755 --- a/documentation/guides/InstallationUbuntuApache.sh +++ b/documentation/guides/InstallationUbuntuApache.sh @@ -148,11 +148,11 @@ echo "Error try again." && \ mysql -u root -t -p -e "CREATE DATABASE $DATABASE_NAME;" 2>&1 >/dev/null | grep -i error && DBFAIL=true if [ $DBFAIL == true ]; then -echo "" && \ -echo "" && \ +echo "" +echo "" echo "Error if root password is incorrect Rerun script or manually configure DB with the below sql after you have configured your password, If db exists, rerun with new dbname" && \ -echo "" && \ -echo "" && \ +echo "" +echo "" echo "CREATE TABLE IF NOT EXISTS user ( id varchar(255) NOT NULL COMMENT 'Users email address', password varchar(64) NOT NULL,