e33c2417fd2222c625b62ab604c02d6e82ce3938 max Fri Aug 20 04:51:37 2021 -0700 making GBIC script work on centos8 again, refs #27795 diff --git src/product/installer/browserSetup.sh src/product/installer/browserSetup.sh index d34dd9a..7b2fd53d 100755 --- src/product/installer/browserSetup.sh +++ src/product/installer/browserSetup.sh @@ -492,46 +492,67 @@ $SEDINPLACE 's/^#slow-db\./slow-db\./g' $APACHEDIR/cgi-bin/hg.conf $SEDINPLACE 's/^#gbdbLoc1=/gbdbLoc1=/g' $APACHEDIR/cgi-bin/hg.conf $SEDINPLACE 's/^#gbdbLoc2=/gbdbLoc2=/g' $APACHEDIR/cgi-bin/hg.conf $SEDINPLACE 's/^#showTableCache=/showTableCache=/g' $APACHEDIR/cgi-bin/hg.conf } # wait for a key press function waitKey () { echo2 echo2 Press any key to continue or CTRL-C to abort. read -n 1 echo2 } +# set MYCNF to the path to my.cnf +function setMYCNF () +{ + if [ -f /etc/my.cnf ] ; then + # Centos 6-8 + MYCNF=/etc/my.cnf + elif [ -f /etc/mysql/my.cnf ] ; then + # Ubuntu 14 + MYCNF=/etc/mysql/my.cnf + elif [ -f /etc/mysql/mysql.conf.d/mysqld.cnf ] ; then + # Ubuntu 16, 18, 20 + MYCNF=/etc/mysql/mysql.conf.d/mysqld.cnf + else + echo Could not find my.cnf. Adapt 'setMYCNF()' in browserSetup.sh and/or contact us. + exit 1 + fi +} + function mysqlAllowOldPasswords # mysql >= 8 does not allow the old passwords anymore. But our client is still compiled # with the old, non-SHA256 encryption. So we must deactivate this new feature. # What will MariaDB do? { echo2 'Checking for Mysql version >= 8' + MYSQLMAJ=`mysql -e 'SHOW VARIABLES LIKE "version";' -NB | cut -f2 | cut -d. -f1` +setMYCNF if [ "$MYSQLMAJ" -ge 8 ] ; then echo2 'Mysql >= 8 found, checking if default-authentication allows native passwords' - if grep -q default-authentication /etc/mysql/my.cnf; then - echo2 'default-authentication already set in /etc/mysql/my.cnf' + if grep -q default-authentication $MYCNF; then + echo2 "default-authentication already set in $MYCNF" else - echo2 Changing /etc/mysql/my.cnf to allow native passwords and restarting Mysql - echo '[mysqld]' >> /etc/mysql/my.cnf - echo 'default-authentication-plugin=mysql_native_password' >> /etc/mysql/my.cnf - service mysql restart + echo2 Changing $MYCNF to allow native passwords and restarting Mysql + echo '[mysqld]' >> $MYCNF + echo 'default-authentication-plugin=mysql_native_password' >> $MYCNF + stopMysql + startMysql fi fi } # oracle's mysql install e.g. on redhat distros does not secure mysql by default, so do this now # this is copied from Oracle's original script, on centos /usr/bin/mysql_secure_installation function secureMysql () { echo2 echo2 Securing the Mysql install by removing the test user, restricting root echo2 logins to localhost and dropping the database named test. waitKey # do not parse .my.cnf for this, as we're sure that there is no root password yet # MYSQL2=`echo $MYSQL | sed -e 's/ / --no-defaults /'` @@ -638,56 +659,56 @@ #cd hg/htdocs #make doInstall destDir=$APACHDIR/htdocs FIND="find ." # dbTrash tool needed for trash cleaning } # redhat specific part of mysql and apache installation function installRedhat () { echo2 echo2 Installing EPEL, ghostscript, libpng waitKey # make sure we have and EPEL and ghostscript and rsync (not installed on vagrant boxes) # imagemagick is required for the session gallery yum -y update yum -y install epel-release - yum -y install ghostscript rsync ImageMagick R-core curl urw-fonts + yum -y install ghostscript rsync ImageMagick R-core curl # centos 7 and fedora 20 do not provide libpng by default if ldconfig -p | grep libpng12.so > /dev/null; then echo2 libpng12 found else yum -y install libpng12 fi # install apache if not installed yet if [ ! -f /usr/sbin/httpd ]; then echo2 echo2 Installing Apache and making it start on boot waitKey yum -y install httpd # start apache on boot chkconfig --level 2345 httpd on # there will be an error message that the apache # mkdir -p $APACHEDIR/htdocs service httpd start else echo2 Apache already installed fi - # download the apache config + # create the apache config if [ ! -f $APACHECONF ]; then echo2 echo2 Creating the Apache2 config file $APACHECONF waitKey echo "$APACHE_CONFIG_STR" > $APACHECONF fi service httpd restart # this triggers an error if rpmforge is not installed # but if rpmforge is installed, we need the option # psxy is not that important, we just skip it for now #yum -y install GMT hdf5 --disablerepo=rpmforge if [ -f /etc/init.d/iptables ]; then echo2 Opening port 80 for incoming connections to Apache @@ -957,37 +978,32 @@ fi if [[ ! -f /usr/sbin/mysqld ]]; then echo2 echo2 Now installing the Mysql server. echo2 The root password will be set to a random string and will be written echo2 to the file /root/.my.cnf so root does not have to provide a password on echo2 the command line. waitKey moveAwayMyCnf # do not prompt in apt-get, will set an empty mysql root password export DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install mysql-server # make sure that missing values do not trigger errors, #18368 - if [ -f /etc/mysql/mysql.conf.d/mysqld.cnf ]; then - # Ubuntu 16 - sed -i '/^.mysqld.$/a sql_mode=' /etc/mysql/mysql.conf.d/mysqld.cnf - else - # Ubuntu 14 - sed -i '/^.mysqld.$/a sql_mode=' /etc/mysql/my.cnf - fi + setMYCNF + sed -i '/^.mysqld.$/a sql_mode=' $MYCNF # flag so script will set mysql root password later to a random value SET_MYSQL_ROOT=1 fi } # download apache mysql libpng openssl into the current dir # and build them into $APACHEDIR/ext function buildApacheMysqlOpensslLibpng () { echo2 echo2 Now building cmake, openssl, pcre, apache and mysql into $APACHEDIR/ext echo2 This can take up to 20 minutes on slower machines waitKey # cmake - required by mysql @@ -1805,30 +1821,31 @@ ;; o) if [ ! -f $APACHEDIR/cgi-bin/hg.conf ]; then echo Please install a browser first, then switch the data loading mode. fi goOffline echo $APACHEDIR/cgi-bin/hg.conf was modified. echo Offline mode: data is loaded only from the local Mysql database and file system. echo Use the parameter -f to switch to on-the-fly mode. exit 0 ;; f) if [ ! -f $APACHEDIR/cgi-bin/hg.conf ]; then echo Please install a browser first, then switch the data loading mode. + exit 0 fi goOnline echo $APACHEDIR/cgi-bin/hg.conf was modified. echo On-the-fly mode activated: data is loaded from UCSC when not present locally. echo Use the parameter -o to switch to offline mode. exit 0 ;; \?) echo "Invalid option: -$OPTARG" >&2 ;; esac done # reset the $1, etc variables after getopts shift $(($OPTIND - 1))