#!/bin/bash set -e NAME="SP" function stop { echo "Stopping ${NAME}" kill $(pgrep dsmserv) echo "You should really connect with a client and issue HALT" && sleep 60 } trap 'stop' SIGTERM [ -z "${USER}" ] && echo "The USER environment variable is not set - this script wont work without it." && exit 1 if [ "$1" == "start" ]; then # @TODO: this assumes -v is used, but we have exposed the VOLUMES, so -v doesnt have to be used. [ ! -f /tsm/.INIT -o ! -f /database/.INIT ] && echo "Please use -v :/tsm.init and :/database.init and run init1" && exit 1 [ -x /opt/tivoli/tsm/server/bin/dsmserv ] && su ${USER} -lc /opt/tivoli/tsm/server/bin/dsmserv & # **NOTE**: ln /opt/tivoli/tsm/server/bin/dbbkapi/dsm.sys to /tsm/dbbkapi/dsm.sys, otherwise backups will fail ln -sf /tsm/dbbkapi/dsm.sys /opt/tivoli/tsm/server/bin/dbbkapi/dsm.sys wait # Init one needs to copy some data from the install /tsm directory to our persistent storage volume - so that volume should be mounted under /tsm.init elif [ "$1" == "init1" ]; then [ ! -d /tsm.init -o ! -d /database.init ] && echo "ERROR: /tsm.init or /database.init doesnt exist" && exit 1 cp -a /tsm/.[a-z]* /tsm/* /tsm.init/ mkdir /database.init/tsmdb /database.init/activelog /database.init/archlog /database.init/archfaillog /database.init/mirrorlog chown -R ${USER}:servers /database.init /tsm.init # Init two creates our database, and runs our admin marco. elif [ "$1" == "init2" ]; then su ${USER} -lc "sed -i \"s/\$(cat sqllib/db2nodes.cfg |awk '{print \$2}')/$(hostname)/\" sqllib/db2nodes.cfg" su ${USER} -lc "dsmserv format dbdir=/database/tsmdb activelogsize=2048 activelogdirectory=/database/activelog archlogdirectory=/database/archlog archfailoverlogdirectory=/database/archfaillog mirrorlogdirectory=/database/mirrorlog" [ -f $(eval echo ~${USER}/admin.macro) ] && su ${USER} -lc "dsmserv runfile admin.macro" touch /database/.INIT touch /tsm/.INIT elif [ "$1" == "upgrade" ]; then [ ! -f /tsm/.INIT -o ! -f /database/.INIT ] && echo "Please use -v :/tsm.init and :/database.init and re-run upgrade" && exit 1 /opt/tivoli/tsm/db2/instance/db2iupdt -d ${USER} elif [ "$1" == "restoredb" ]; then su ${USER} -lc "dsmserv restore db ${2:+password=$2} restorekeys=yes on=DBDIRS.TXT" elif [ "$1" == "restore" ]; then echo "! Running [dsmserv $@]" su ${USER} -lc "dsmserv $@" else exec $@ fi