From ec7501ae2a45abe12275b397079a5e7165a1461f Mon Sep 17 00:00:00 2001 From: Jkat Date: Thu, 13 Mar 2014 16:05:13 -0400 Subject: [PATCH 01/14] Handling data path and imagepath --- docs/config/config.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/config/config.xml b/docs/config/config.xml index a9b80eea662..97aa286a7c6 100644 --- a/docs/config/config.xml +++ b/docs/config/config.xml @@ -21,9 +21,9 @@ - /PATH/TO/MINC/DATA/ROOT/mri-data/minc/ + /data/%PROJECT%/data/ %LORISROOT% - SAME AS imagePath + /data/%PROJECT%/data/ /PATH/TO/SMARTY/libs /data/%PROJECT%/data/ tools/logs/ From 16322fe7ed28553a5a80fb24d81cdbdd77308783 Mon Sep 17 00:00:00 2001 From: Jkat Date: Thu, 13 Mar 2014 16:11:11 -0400 Subject: [PATCH 02/14] Creating ../project/libraries and ../project/instruments by default --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index 748ca3253d7..9264f335096 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -38,7 +38,7 @@ if ! test -t 0 -a -t 1 -a -t 2 ; then fi # Create some subdirectories, if needed. -mkdir -p logs ../project ../project/tables_sql ../smarty/templates_c +mkdir -p logs ../project ../project/libraries ../project/instruments ../project/tables_sql ../smarty/templates_c # Setting 777 permissions for templates_c chmod 777 ../smarty/templates_c From 927d88f1e405efeea6497fc84914a7b84901b64f Mon Sep 17 00:00:00 2001 From: Jkat Date: Thu, 13 Mar 2014 16:19:15 -0400 Subject: [PATCH 03/14] Adding some consistency and fixing a bug where the sed would fail because $projectname wouldn't have been set yet --- tools/install.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 9264f335096..ee20fa74a6a 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -125,9 +125,9 @@ Please answer the following questions. You'll be asked: newly created MySQL user in part c). e) Your project name. This should be an alphanumeric name. - It will be used to automatically create/install apache config files. - It will also be used to modify the paths for MRI in the generated - config.xml file for LORIS. + It will be used to modify the paths for MRI in the generated + config.xml file for LORIS. It may also be used to automatically + create/install apache config files. QUESTIONS @@ -231,6 +231,18 @@ done; stty echo +while true; do + read -p "Enter project name: " projectname + case $projectname in + "" ) + read -p "Enter project name: " projectname + continue;; + * ) + break;; + esac +done; + + echo "" echo "Attempting to create the MySQL database '$mysqldb' ..." @@ -288,7 +300,7 @@ sed -e "s/%HOSTNAME%/$mysqlhost/g" \ -e "s/%PASSWORD%/$mysqlpass/g" \ -e "s/%DATABASE%/$mysqldb/g" \ -e "s#%LORISROOT%#$RootDir/#g" \ - -e "s#%PROJECT%#$projectname/#g" \ + -e "s#%PROJECTNAME%#$projectname/#g" \ < ../docs/config/config.xml > ../project/config.xml @@ -348,7 +360,6 @@ while true; do read -p "Would you like to automatically create/install apache config files? [yn] " yn case $yn in [Yy]* ) - read -p "Enter project name: " projectname if [ -f /etc/apache2/sites-available/$projectname ]; then echo "Apache appears to already be configured for $projectname. Aborting\n" exit 1 From 231c2c9ab76e4ac782243c30d7ba5292b3f7a8d8 Mon Sep 17 00:00:00 2001 From: Jkat Date: Thu, 13 Mar 2014 16:40:49 -0400 Subject: [PATCH 04/14] Renaming PROJECT to PROJECTNAME for docs config.xml placeholder --- docs/config/config.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/config/config.xml b/docs/config/config.xml index 97aa286a7c6..bd87c17f495 100644 --- a/docs/config/config.xml +++ b/docs/config/config.xml @@ -21,11 +21,11 @@ - /data/%PROJECT%/data/ + /data/%PROJECTNAME%/data/ %LORISROOT% - /data/%PROJECT%/data/ + /data/%PROJECTNAME%/data/ /PATH/TO/SMARTY/libs - /data/%PROJECT%/data/ + /data/%PROJECTNAME%/data/ tools/logs/ From 5b9d5583d70e698806e25291ecf4dc6b46641db6 Mon Sep 17 00:00:00 2001 From: Jkat Date: Fri, 14 Mar 2014 15:56:18 -0400 Subject: [PATCH 05/14] Changing items asked in question from alphabets to numbers --- tools/install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index ee20fa74a6a..e9540d178ff 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -103,28 +103,28 @@ cat < Date: Tue, 18 Mar 2014 16:06:33 -0400 Subject: [PATCH 06/14] Now creating project/templates by default --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index e9540d178ff..aa741949730 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -38,7 +38,7 @@ if ! test -t 0 -a -t 1 -a -t 2 ; then fi # Create some subdirectories, if needed. -mkdir -p logs ../project ../project/libraries ../project/instruments ../project/tables_sql ../smarty/templates_c +mkdir -p logs ../project ../project/libraries ../project/instruments ../project/templates ../project/tables_sql ../smarty/templates_c # Setting 777 permissions for templates_c chmod 777 ../smarty/templates_c From 1348cc26aabf2798f68e6af82f17d40a8952cac2 Mon Sep 17 00:00:00 2001 From: Jkat Date: Fri, 21 Mar 2014 10:56:40 -0400 Subject: [PATCH 07/14] Added logging, untested though --- tools/install.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index aa741949730..f7a11a6c278 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -7,6 +7,12 @@ # This will only install the database components and Loris config file. # +START=`date "+%Y-%m-%dT%H:%M:%S"` +LOGDIR="logs" +LOGFILE="logs/install-$START.log" +exec > >(tee $LOGFILE) + + CWD=`pwd` RootDir=`dirname $CWD` @@ -48,14 +54,14 @@ chmod 777 ../smarty/templates_c # Configure logging. # From now on, STDOUT and STDERR are sent to both the terminal AND a logfile in logs/ # -START=`date "+%Y-%m-%dT%H:%M:%S"` -LOGDIR="logs" -LOGFILE="logs/install-$START.log" -LOGPIPE=/tmp/pipe.$$ -mkfifo -m 700 $LOGPIPE -trap "rm -f $LOGPIPE" EXIT -tee <$LOGPIPE capt & -exec 1>$LOGPIPE 2>&1 +#START=`date "+%Y-%m-%dT%H:%M:%S"` +#LOGDIR="logs" +#LOGFILE="logs/install-$START.log" +#LOGPIPE=/tmp/pipe.$$ +#mkfifo -m 700 $LOGPIPE +#trap "rm -f $LOGPIPE" EXIT +#tee <$LOGPIPE capt & +#exec 1>$LOGPIPE 2>&1 if [ ! -w $LOGDIR ] ; then @@ -381,3 +387,4 @@ done; echo "Installation complete." + From 0b2ecc45c6750ea9a62a7b62a283151818d7ce58 Mon Sep 17 00:00:00 2001 From: Jkat Date: Fri, 21 Mar 2014 17:21:11 -0400 Subject: [PATCH 08/14] Adding DownloadPath element to default config file --- docs/config/config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/config/config.xml b/docs/config/config.xml index bd87c17f495..b19faf4b92a 100644 --- a/docs/config/config.xml +++ b/docs/config/config.xml @@ -26,6 +26,7 @@ /data/%PROJECTNAME%/data/ /PATH/TO/SMARTY/libs /data/%PROJECTNAME%/data/ + %LORISROOT% tools/logs/ From d85e6332d4fc967579424c05a8e50b5f67f545f0 Mon Sep 17 00:00:00 2001 From: Jkat Date: Fri, 21 Mar 2014 18:26:14 -0400 Subject: [PATCH 09/14] Improving robustness and prompt displays for user --- tools/install.sh | 78 ++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index f7a11a6c278..2687459167b 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -7,10 +7,17 @@ # This will only install the database components and Loris config file. # +# Must be run interactively. +if ! test -t 0 -a -t 1 -a -t 2 ; then + echo "This installation program should be run interactively." + exit 2 +fi + START=`date "+%Y-%m-%dT%H:%M:%S"` LOGDIR="logs" LOGFILE="logs/install-$START.log" exec > >(tee $LOGFILE) +exec 2>&1 CWD=`pwd` @@ -38,10 +45,10 @@ if [ ! -f ../SQL/0000-00-00-schema.sql ] ; then fi # Must be run interactively. -if ! test -t 0 -a -t 1 -a -t 2 ; then - echo "This installation program should be run interactively." - exit 2 -fi +#if ! test -t 0 -a -t 1 -a -t 2 ; then +# echo "This installation program should be run interactively." +# exit 2 +#fi # Create some subdirectories, if needed. mkdir -p logs ../project ../project/libraries ../project/instruments ../project/templates ../project/tables_sql ../smarty/templates_c @@ -152,7 +159,7 @@ done; echo "" -while true; do +while [ "$mysqldb" == "" ]; do read -p "What is the database name? " mysqldb case $mysqldb in "" ) @@ -163,26 +170,26 @@ while true; do esac done; -while true; do +while [ "$mysqlhost" == "" ]; do read -p "Database host? " mysqlhost - case $mysqlhost in - "" ) - read -p "Database host? " mysqlhost - continue;; + case $mysqlhost in + "" ) + read -p "Database host? " mysqlhost + continue;; * ) - break;; + break;; esac done; -while true; do +while [ "$mysqluser" == "" ]; do read -p "What MySQL user will Loris connect as? " mysqluser - case $mysqluser in - "" ) - read -p "What MySQL user will Loris connect as? " mysqluser - continue;; + case $mysqluser in + "" ) + read -p "What MySQL user will Loris connect as? " mysqluser + continue;; * ) - break;; - esac + break;; + esac done; stty -echo @@ -194,6 +201,7 @@ while true; do if [[ $mysqlpass == $mysqlpass2 ]] ; then break; fi + echo "" echo "Passwords did not match. Please try again."; done; @@ -207,20 +215,21 @@ while true; do if [[ $lorispass == $lorispass2 ]] ; then break; fi + echo "" echo "Passwords did not match. Please try again."; done; stty echo ; echo "" -while true; do - read -p "Existing root MySQL username: " mysqlrootuser - case $mysqlrootuser in - "" ) - read -p "Existing root MySQL username: " mysqlrootuser - continue;; +while [ "$mysqlrootuser" == "" ]; do + read -p "Existing root MySQL username: " mysqlrootuser + case $mysqlrootuser in + "" ) + read -p "Existing root MySQL username: " mysqlrootuser + continue;; * ) - break;; - esac + break;; + esac done; stty -echo @@ -232,20 +241,22 @@ while true; do if [[ $mysqlrootpass == $mysqlrootpass2 ]] ; then break; fi + echo "" echo "Passwords did not match. Please try again."; done; stty echo +echo "" -while true; do +while [ "$projectname" == "" ]; do read -p "Enter project name: " projectname - case $projectname in - "" ) - read -p "Enter project name: " projectname - continue;; + case $projectname in + "" ) + read -p "Enter project name: " projectname + continue;; * ) - break;; - esac + break;; + esac done; @@ -265,6 +276,7 @@ if [ $MySQLError -ne 0 ] ; then if [[ $mysqlrootpass == $mysqlrootpass2 ]] ; then break; fi + echo "" echo "Passwords did not match. Please try again."; done; stty echo From 4e184ed184b02e555c64c701af16c127800cc756 Mon Sep 17 00:00:00 2001 From: Jkat Date: Fri, 21 Mar 2014 18:30:31 -0400 Subject: [PATCH 10/14] Logging has been tested, though STDIN is not being recorded at the moment --- tools/install.sh | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 2687459167b..76abd8269ee 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -4,6 +4,7 @@ # This will: # 1. Install PEAR libraries # 2. Set up the Loris DB schema +# 3. Log the installation in the logs directory # This will only install the database components and Loris config file. # @@ -44,12 +45,6 @@ if [ ! -f ../SQL/0000-00-00-schema.sql ] ; then exit 2 fi -# Must be run interactively. -#if ! test -t 0 -a -t 1 -a -t 2 ; then -# echo "This installation program should be run interactively." -# exit 2 -#fi - # Create some subdirectories, if needed. mkdir -p logs ../project ../project/libraries ../project/instruments ../project/templates ../project/tables_sql ../smarty/templates_c @@ -57,20 +52,6 @@ mkdir -p logs ../project ../project/libraries ../project/instruments ../project/ chmod 777 ../smarty/templates_c -# -# Configure logging. -# From now on, STDOUT and STDERR are sent to both the terminal AND a logfile in logs/ -# -#START=`date "+%Y-%m-%dT%H:%M:%S"` -#LOGDIR="logs" -#LOGFILE="logs/install-$START.log" -#LOGPIPE=/tmp/pipe.$$ -#mkfifo -m 700 $LOGPIPE -#trap "rm -f $LOGPIPE" EXIT -#tee <$LOGPIPE capt & -#exec 1>$LOGPIPE 2>&1 - - if [ ! -w $LOGDIR ] ; then echo "The logs directory is not writeable. You will not have an automatically generated report of your installation." while true; do From 3830063d391cd9edbf3a00b4fc3571df4e976be7 Mon Sep 17 00:00:00 2001 From: Jkat Date: Mon, 24 Mar 2014 11:21:45 -0400 Subject: [PATCH 11/14] Reshuffling more items around, making more sense/technically more precise --- tools/install.sh | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 76abd8269ee..f613916f3d4 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -20,10 +20,30 @@ LOGFILE="logs/install-$START.log" exec > >(tee $LOGFILE) exec 2>&1 - CWD=`pwd` RootDir=`dirname $CWD` + +echo "LORIS Installation Script starting at $START" + +if [ ! -w $LOGDIR ] ; then + echo "The logs directory is not writeable. You will not have an automatically generated report of your installation." + while true; do + read -p "Do you still want to continue? [yn] " yn + case $yn in + [Yy]* ) + break;; + [Nn]* ) + echo "Aborting installation." + exit 2;; + * ) echo "Please enter 'y' or 'n'." + esac + done; +else + echo "The log for this session will be stored in file $CWD/$LOGFILE" +fi + + # Banner cat < Date: Mon, 24 Mar 2014 11:36:08 -0400 Subject: [PATCH 12/14] More shuffling --- tools/install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index f613916f3d4..de2126abc94 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -14,6 +14,9 @@ if ! test -t 0 -a -t 1 -a -t 2 ; then exit 2 fi +# Create logs directory, if needed. +mkdir -p logs + START=`date "+%Y-%m-%dT%H:%M:%S"` LOGDIR="logs" LOGFILE="logs/install-$START.log" @@ -66,7 +69,7 @@ if [ ! -f ../SQL/0000-00-00-schema.sql ] ; then fi # Create some subdirectories, if needed. -mkdir -p logs ../project ../project/libraries ../project/instruments ../project/templates ../project/tables_sql ../smarty/templates_c +mkdir -p ../project ../project/libraries ../project/instruments ../project/templates ../project/tables_sql ../smarty/templates_c # Setting 777 permissions for templates_c chmod 777 ../smarty/templates_c From aacb3623e69888a8d35036f8fc158b788fb634e8 Mon Sep 17 00:00:00 2001 From: Jkat Date: Mon, 24 Mar 2014 12:56:48 -0400 Subject: [PATCH 13/14] Fixing path setting (extra '/' was being appended) --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index de2126abc94..ddaac1534af 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -304,7 +304,7 @@ sed -e "s/%HOSTNAME%/$mysqlhost/g" \ -e "s/%PASSWORD%/$mysqlpass/g" \ -e "s/%DATABASE%/$mysqldb/g" \ -e "s#%LORISROOT%#$RootDir/#g" \ - -e "s#%PROJECTNAME%#$projectname/#g" \ + -e "s#%PROJECTNAME%#$projectname#g" \ < ../docs/config/config.xml > ../project/config.xml From ac2563dd93b784018ec1806db20badc97e05c7c8 Mon Sep 17 00:00:00 2001 From: Jkat Date: Tue, 25 Mar 2014 13:33:58 -0400 Subject: [PATCH 14/14] Now logging user input --- tools/install.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index ddaac1534af..087d0b83696 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -20,8 +20,11 @@ mkdir -p logs START=`date "+%Y-%m-%dT%H:%M:%S"` LOGDIR="logs" LOGFILE="logs/install-$START.log" -exec > >(tee $LOGFILE) -exec 2>&1 +LOGPIPE=/tmp/pipe.$$ +mkfifo -m 700 $LOGPIPE +trap "rm -f $LOGPIPE" EXIT +tee -a <$LOGPIPE $LOGFILE & +exec 1>$LOGPIPE 2>&1 CWD=`pwd` RootDir=`dirname $CWD` @@ -33,6 +36,7 @@ if [ ! -w $LOGDIR ] ; then echo "The logs directory is not writeable. You will not have an automatically generated report of your installation." while true; do read -p "Do you still want to continue? [yn] " yn + echo $yn | tee -a $LOGFILE > /dev/null case $yn in [Yy]* ) break;; @@ -133,6 +137,7 @@ QUESTIONS while true; do read -p "Ready to continue? [yn] " yn + echo $yn | tee -a $LOGFILE > /dev/null case $yn in [Yy]* ) break;; @@ -147,6 +152,7 @@ echo "" while [ "$mysqldb" == "" ]; do read -p "What is the database name? " mysqldb + echo $mysqldb | tee -a $LOGFILE > /dev/null case $mysqldb in "" ) read -p "What is the database name? " mysqldb @@ -158,6 +164,7 @@ done; while [ "$mysqlhost" == "" ]; do read -p "Database host? " mysqlhost + echo $mysqlhost | tee -a $LOGFILE > /dev/null case $mysqlhost in "" ) read -p "Database host? " mysqlhost @@ -169,6 +176,7 @@ done; while [ "$mysqluser" == "" ]; do read -p "What MySQL user will Loris connect as? " mysqluser + echo $mysqluser | tee -a $LOGFILE > /dev/null case $mysqluser in "" ) read -p "What MySQL user will Loris connect as? " mysqluser @@ -209,6 +217,7 @@ stty echo ; echo "" while [ "$mysqlrootuser" == "" ]; do read -p "Existing root MySQL username: " mysqlrootuser + echo $mysqlrootuser | tee -a $LOGFILE > /dev/null case $mysqlrootuser in "" ) read -p "Existing root MySQL username: " mysqlrootuser @@ -236,6 +245,7 @@ echo "" while [ "$projectname" == "" ]; do read -p "Enter project name: " projectname + echo $projectname | tee -a $LOGFILE > /dev/null case $projectname in "" ) read -p "Enter project name: " projectname @@ -255,6 +265,7 @@ if [ $MySQLError -ne 0 ] ; then while true; do echo "Could not connect to database with the root user provided. Please try again."; read -p "Existing root MySQL username: " mysqlrootuser + echo $mysqlrootuser | tee -a $LOGFILE > /dev/null stty -echo while true; do read -p "MySQL password for user '$mysqlrootuser': " mysqlrootpass @@ -311,6 +322,7 @@ sed -e "s/%HOSTNAME%/$mysqlhost/g" \ while true; do read -p "Would you like to install PEAR libraries (affects system files)? [yn] " yn + echo $yn | tee -a $LOGFILE > /dev/null case $yn in [Yy]* ) echo "Installing PEAR libraries (may prompt for sudo password)." @@ -362,6 +374,7 @@ done; while true; do read -p "Would you like to automatically create/install apache config files? [yn] " yn + echo $yn | tee -a $LOGFILE > /dev/null case $yn in [Yy]* ) if [ -f /etc/apache2/sites-available/$projectname ]; then