#!/bin/bash -x set -e ##### ##### Read the commandline options ##### ACTION=${1} NEW_VERSION=${2} ##### ##### Source the debconf library ##### if [ -e "/usr/share/debconf/confmodule" ]; then . /usr/share/debconf/confmodule else echo "debconf must be installed. Exiting." exit 1 fi # Use as suffix to backedup files LONG_DATE=$(date +%Y%m%d%H%M%S) ##### ##### GLOBAL VARIABLES ##### D1_LOG_DIR=/var/log/dataone D1_LOG_FILE=dataone-cn-os-core.install.log ##### ##### FUNCTION DEFINITIONS ##### ##### ##### logError() ##### redirect stdout to stderr ##### functions to echo to STDERR or the install log instead of STDOUT ##### function logError() { echo -e "$@" 1>&2 } ##### ##### log() ##### append stdout to a logfile ##### function log() { # # Set Up logging # Reminder: don't echo to stdout, it messes up debconf # if [ ! -e ${D1_LOG_DIR} ]; then mkdir -p ${D1_LOG_DIR} chown tomcat:tomcat ${D1_LOG_DIR} fi now=$(date "+%Y-%m-%d %H:%M:%S %Z: ") echo -e "${now} preinst $@" >> ${D1_LOG_DIR}/${D1_LOG_FILE} } if ! (sed -i.bak --regexp-extended "s/(^.*db_purge.*$)/#\1/;" /var/lib/dpkg/info/dataone-cn-os-core.postrm >> ${D1_LOG_DIR}/${D1_LOG_FILE} 2>&1); then log "commenting out db_purge failed" else cat /var/lib/dpkg/info/dataone-cn-os-core.postrm >> ${D1_LOG_DIR}/${D1_LOG_FILE} 2>&1 fi if (db_get dataone-cn-os-core/cn.context.label); then db_get dataone-cn-os-core/cn.context.label RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.context.label seen SEEN=$RET log "dataone-cn-os-core/cn.context.label value: $RTN_VALUE seen: $SEEN" fi if (db_get dataone-cn-os-core/cn.hostname); then db_get dataone-cn-os-core/cn.hostname RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.hostname seen SEEN=$RET log "dataone-cn-os-core/cn.hostname value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.nodeid); then db_get dataone-cn-os-core/cn.nodeid RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.nodeid seen SEEN=$RET log "dataone-cn-os-core/cn.nodeid value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.iplist); then db_get dataone-cn-os-core/cn.iplist RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.iplist seen SEEN=$RET log "dataone-cn-os-core/cn.iplist value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.hostnamelist); then db_get dataone-cn-os-core/cn.hostnamelist RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.hostnamelist seen SEEN=$RET log "dataone-cn-os-core/cn.hostnamelist value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.nodeids); then db_get dataone-cn-os-core/cn.nodeids RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.nodeids seen SEEN=$RET log "dataone-cn-os-core/cn.nodeids value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.router.hostname); then db_get dataone-cn-os-core/cn.router.hostname RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.router.hostname seen SEEN=$RET log "dataone-cn-os-core/cn.router.hostname value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.router.nodeId); then db_get dataone-cn-os-core/cn.router.nodeId RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.router.nodeId seen SEEN=$RET log "dataone-cn-os-core/cn.router.nodeId value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.search.hostname); then db_get dataone-cn-os-core/cn.search.hostname RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.search.hostname seen SEEN=$RET log "dataone-cn-os-core/cn.search.hostname value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.dataone.ca.filename); then db_get dataone-cn-os-core/cn.dataone.ca.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.dataone.ca.filename seen SEEN=$RET log "dataone-cn-os-core/cn.dataone.ca.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.server.publiccert.filename); then db_get dataone-cn-os-core/cn.server.publiccert.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.server.publiccert.filename seen SEEN=$RET log "dataone-cn-os-core/cn.server.publiccert.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.server.privatekey.filename); then db_get dataone-cn-os-core/cn.server.privatekey.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.server.privatekey.filename seen SEEN=$RET log "dataone-cn-os-core/cn.server.privatekey.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.client.certificate.dir); then db_get dataone-cn-os-core/cn.client.certificate.dir RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.client.certificate.dir seen SEEN=$RET log "dataone-cn-os-core/cn.client.certificate.dir value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.client.key.dir); then db_get dataone-cn-os-core/cn.client.key.dir RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.client.key.dir seen SEEN=$RET log "dataone-cn-os-core/cn.client.key.dir value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.client.certificate.filename); then db_get dataone-cn-os-core/cn.client.certificate.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.client.certificate.filename seen SEEN=$RET log "dataone-cn-os-core/cn.client.certificate.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.replication.certificate.filename); then db_get dataone-cn-os-core/cn.replication.certificate.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.replication.certificate.filename seen SEEN=$RET log "dataone-cn-os-core/cn.replication.certificate.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.replication.privatekey.filename); then db_get dataone-cn-os-core/cn.replication.privatekey.filename RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.replication.privatekey.filename seen SEEN=$RET log "dataone-cn-os-core/cn.replication.privatekey.filename value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.keystore.password); then db_get dataone-cn-os-core/cn.keystore.password RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.keystore.password seen SEEN=$RET log "dataone-cn-os-core/cn.keystore.password value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.openldap.password); then db_get dataone-cn-os-core/cn.openldap.password RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.openldap.password seen SEEN=$RET log "dataone-cn-os-core/cn.openldap.password value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.openldap.synchronized); then db_get dataone-cn-os-core/cn.openldap.synchronized RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.openldap.synchronized seen SEEN=$RET log "dataone-cn-os-core/cn.openldap.synchronized value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.openldap.serverID); then db_get dataone-cn-os-core/cn.openldap.serverID RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.openldap.serverID seen SEEN=$RET log "dataone-cn-os-core/cn.openldap.serverID value:$RTN_VALUE seen:$SEEN" fi if (db_get dataone-cn-os-core/cn.openldap.firstcn); then db_get dataone-cn-os-core/cn.openldap.firstcn RTN_VALUE=$RET db_fget dataone-cn-os-core/cn.openldap.firstcn seen SEEN=$RET log "dataone-cn-os-core/cn.openldap.firstcn value:$RTN_VALUE seen:$SEEN" fi if (debconf-show dataone-cn-os-core >> ${D1_LOG_DIR}/${D1_LOG_FILE} 2>&1); then log "ending pre-install" fi