4b11c0d2ac51d9055146f415ff9431a9f8d6f026 max Tue Jan 4 06:52:03 2022 -0800 fixing obscure bug in GBIC only visible when re-running the script during debuggin, refs #28585 diff --git src/product/installer/browserSetup.sh src/product/installer/browserSetup.sh index 4890c66..af39aa2 100755 --- src/product/installer/browserSetup.sh +++ src/product/installer/browserSetup.sh @@ -1,28 +1,30 @@ #!/bin/bash # script to install/setup dependencies for the UCSC genome browser CGIs # call it like this as root from a command line: bash browserInstall.sh # you can easily debug this script with 'bash -x browserInstall.sh', it # will show all commands then +exec > >(tee -a "${HOME}/browserInstall.log") 2>&1 + set -u -e -o pipefail # fail on unset vars and all errors, also in pipes exitHandler() { if [ "$1" == "100" -o "$1" == "0" ] ; then - exit 1 # all fine, a specific error message has already been output + exit $1 # all fine, a specific error message has already been output fi # somehow this script exited with an unknown type of error code echo Exit error $1 occurred on line $2 echo The UCSC Genome Browser installation script exited with an error. echo Please contact us at genome-mirror@soe.ucsc.edu and send us an output log echo of the command prefixed with '"bash -x"', e.g. echo 'bash -x browserSetup.sh install 2>&1 > install.log' } # only trap the exit, not the errors # see https://medium.com/@dirk.avery/the-bash-trap-trap-ce6083f36700 trap 'exitHandler $? $LINENO' EXIT # ---- GLOBAL DEFAULT SETTINGS ---- @@ -1188,30 +1190,32 @@ echo user=root >> ~/.my.cnf echo password=YOURMYSQLPASSWORD >> ~/.my.cnf chmod 600 ~/.my.cnf echo2 echo2 A file ${HOME}/.my.cnf was created with default values echo2 Edit the file ${HOME}/.my.cnf and replace YOURMYSQLPASSWORD with the mysql root password that you echo2 defined during the mysql installation. else echo2 echo2 A file ${HOME}/.my.cnf already exists echo2 Edit the file ${HOME}/.my.cnf and make sure there is a '[client]' section echo2 and under it at least two lines with 'user=root' and 'password=YOURMYSQLPASSWORD'. fi echo2 "Then run this script again." + echo2 'If this is a fresh docker image or blank VM, you can also remove Mariadb entirely, run "rm -rf /var/lib/mysql/*"' + echo2 "and rm -f ${HOME}/.my.cnf and then rerun this script. It will then reinstall Mariadb and define new passwords." exit 100 fi } # check if a program exists in the PATH function commandExists () { type "$1" &> /dev/null ; } # DETECT AND DEACTIVATE SELINUX: if it exists and is active function disableSelinux () { # first check if the command exists on this system # then check if it comes back with a non-zero error code, which means it is enabled if commandExists selinuxenabled; then @@ -1256,35 +1260,42 @@ $MYSQL -e 'CREATE DATABASE IF NOT EXISTS hgTemp;' $MYSQL -e 'CREATE DATABASE IF NOT EXISTS hgFixed;' # empty db needed for gencode tracks updateBlatServers echo2 echo2 "Will now grant permissions to browser database access users:" echo2 "User: 'browser', password: 'genome' - full database access permissions" echo2 "User: 'readonly', password: 'access' - read only access for CGI binaries" echo2 "User: 'readwrite', password: 'update' - readwrite access for hgcentral DB" waitKey # Full access to all databases for the user 'browser' # This would be for browser developers that need read/write access # to all database tables. - # $MYSQL -e "DROP USER IF EXISTS browser@localhost" # centos7 uses mysql 5.6 which doesn't have IF EXISTS so work around that here - # $MYSQL -e "DROP USER IF EXISTS readonly@localhost" - # $MYSQL -e "DROP USER IF EXISTS ctdbuser@localhost" - # $MYSQL -e "DROP USER IF EXISTS readwrite@localhost" - $MYSQL -e 'DELETE from mysql.user where User="browser" or User="readonly" or User="readwrite" or User="ctdbuser"' + + mysqlVer=`mysql -e 'SHOW VARIABLES LIKE "version";' -NB | cut -f2 | cut -d- -f1 | cut -d. -f-2` + if [[ $mysqlVer == "5.6" ]] ; then + # centos7 uses mysql 5.6 which doesn't have IF EXISTS so work around that here + $MYSQL -e 'DELETE from mysql.user where user="browser" or user="readonly" or user="readwrite" or user="ctdbuser"' + else + $MYSQL -e "DROP USER IF EXISTS browser@localhost" + $MYSQL -e "DROP USER IF EXISTS readonly@localhost" + $MYSQL -e "DROP USER IF EXISTS ctdbuser@localhost" + $MYSQL -e "DROP USER IF EXISTS readwrite@localhost" + fi + $MYSQL -e "FLUSH PRIVILEGES;" $MYSQL -e "CREATE USER browser@localhost IDENTIFIED BY 'genome'" $MYSQL -e "GRANT SELECT, INSERT, UPDATE, DELETE, FILE, "\ "CREATE, DROP, ALTER, CREATE TEMPORARY TABLES on *.* TO browser@localhost" # FILE permission for this user to all databases to allow DB table loading with # statements such as: "LOAD DATA INFILE file.tab" # For security details please read: # http://dev.mysql.com/doc/refman/5.1/en/load-data.html # http://dev.mysql.com/doc/refman/5.1/en/load-data-local.html $MYSQL -e "GRANT FILE on *.* TO browser@localhost;" # Read only access to genome databases for the browser CGI binaries $MYSQL -e "CREATE USER readonly@localhost IDENTIFIED BY 'access';"