Skip to content
Snippets Groups Projects
sprint_install.sh 3.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/bash
    # Performs the sprint components installation.
    # This script assumes that you already are on the sprint server and must be run from that place
    # in the home directory.
    
    #
    # If the file ~/.keystore exists it will replace openBIS.keystore of the distribution and
    # the Java option -Djavax.net.ssl.trustStore=openBIS.keystore in the start up scripts will
    # be removed assuming that ~/.keystore does not contains a self-signed certificate.
    
    kohleman's avatar
    kohleman committed
    CONFIG_DIR=~openbis/config
    KEYSTORE=~openbis/.keystore
    
    SERVERS_DIR_ALIAS=sprint
    
    DATE=`/bin/date +%Y-%m-%d_%H%M`
    
    DB_NAME=openbis_productive
    
    kohleman's avatar
    kohleman committed
    DB_SNAPSHOT=~openbis/db_backups
    
    kohleman's avatar
    kohleman committed
    TOMCAT_DIR=~openbis/sprint/openBIS-server/apache-tomcat
    
    SERVERS_VER=$SERVERS_DIR_ALIAS-$VER
    
    if [ -d $SERVERS_DIR_ALIAS-* ]; then
    
    kohleman's avatar
    kohleman committed
            cd $SERVERS_DIR_ALIAS-*
            PREV_VER=${PWD#*-}
            SERVERS_PREV_VER=$SERVERS_DIR_ALIAS-$PREV_VER
            cd ..
    
    kohleman's avatar
    kohleman committed
            echo Warning: no previous servers installation found. Initial installation?
            SERVERS_PREV_VER=unknown
    
    # Unalias rm and cp commands
    
    if [ -e $SERVERS_PREV_VER ]; then
    
    kohleman's avatar
    kohleman committed
            echo Stopping the components...
            ./$SERVERS_PREV_VER/openBIS-server/apache-tomcat/bin/shutdown.sh
            ./$SERVERS_PREV_VER/datastore_server/datastore_server.sh stop
    
    
    echo Making a database dump...
    
    # A custom-format dump (-Fc flag) is not a script for psql, but instead must be
    # restored with pg_restore, for example:
    # pg_restore -d dbname filename
    
    kohleman's avatar
    kohleman committed
    pg_dump -Uopenbis -Fc $DB_NAME > $DB_SNAPSHOT/$SERVERS_PREV_VER-$DB_NAMEi_${DATE}.dmp
    
    # we actually need to clean that up from time to time
    
    kohleman's avatar
    kohleman committed
    /usr/bin/find $DB_SNAPSHOT -type f -mtime +$DAYS_TO_RETAIN -exec rm {} \;
    
    
    echo Installing openBIS server...
    
    rm -rf old/$SERVERS_PREV_VER
    mv $SERVERS_PREV_VER old
    rm -f $SERVERS_DIR_ALIAS
    mkdir $SERVERS_VER
    ln -s $SERVERS_VER $SERVERS_DIR_ALIAS
    cd $SERVERS_DIR_ALIAS
    
    unzip -q ../openBIS-server*$VER*
    
    cd openBIS-server
    
    ./install.sh --nostartup $PWD $CONFIG_DIR/service.properties $CONFIG_DIR/openbis.conf
    
    if [ -f $KEYSTORE ]; then
      cp -p $KEYSTORE apache-tomcat/openBIS.keystore
      sed 's/-Djavax.net.ssl.trustStore=openBIS.keystore //g' apache-tomcat/bin/startup.sh > new-startup.sh
      mv -f new-startup.sh apache-tomcat/bin/startup.sh
      chmod 744 apache-tomcat/bin/startup.sh
    fi
    
    cp ~openbis/$SERVERS_PREV_VER/openBIS-server/apache-tomcat/conf/server.xml ~openbis/$SERVERS_VER/openBIS-server/apache-tomcat/conf/server.xml
    
    #apache-tomcat/bin/startup.sh
    
    tpylak's avatar
    tpylak committed
    echo Installing datastore server...
    
    unzip -q ../datastore_server*$VER*
    
    tpylak's avatar
    tpylak committed
    cd datastore_server
    
    cp -p $CONFIG_DIR/datastore_server-service.properties etc/service.properties
    
    if [ -f $KEYSTORE ]; then
      cp -p $KEYSTORE etc/openBIS.keystore
    
      #cp -Rf ~openbis/old/$SERVERS_PREV_VER/datastore_server/data/store/* data/store
    
      sed 's/-Djavax.net.ssl.trustStore=etc\/openBIS.keystore //g' datastore_server.sh > xxx
      mv -f xxx datastore_server.sh
    fi
    
    chmod 744 datastore_server.sh
    
    export JAVA_HOME=/usr
    
    #./datastore_server.sh start
    
    #echo Doing some cleaning...
    
    kohleman's avatar
    kohleman committed
    cd ~openbis/sprint/openBIS-server
    
    kohleman's avatar
    kohleman committed
    rm apache-tomcat.zip install.sh openbis.conf openBIS.keystore openBIS.war passwd.sh server.xml service.properties tomcat-version.txt
    
    
    # Reset the rm command alias
    alias 'rm=rm -i'
    
    alias 'cp=cp -ipR'
    
    kohleman's avatar
    kohleman committed
    echo Running ~openbis/bin/sprint_post_install.sh
    ~openbis/bin/sprint_post_install.sh
    
    tpylak's avatar
    tpylak committed
    echo "Done, now start the servers using all-up.sh"