50 lines
2.1 KiB
Bash
Executable File
50 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
NAME="SP"
|
|
|
|
function stop {
|
|
echo "Stopping ${NAME}"
|
|
echo "PLEASE 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 <USER>:/tsm.init and <DATABASE>:/database.init and run init1" && exit 1
|
|
|
|
[ -x /opt/tivoli/tsm/server/bin/dsmserv ] && su ${USER} -lc /opt/tivoli/tsm/server/bin/dsmserv &
|
|
|
|
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
|
|
|
|
chown ${USER}:servers /database.init /tsm.init
|
|
cp -a /tsm/.[a-z]* /tsm/* /tsm.init/
|
|
su ${USER} -lc "mkdir /database.init/tsmdb /database.init/activelog /database.init/archlog /database.init/archfaillog /database.init/mirrorlog"
|
|
|
|
# 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 <USER>:/tsm.init and <DATABASE>:/database.init and re-run upgrade" && exit 1
|
|
/opt/tivoli/tsm/db2/instance/db2iupdt -d ${USER}
|
|
|
|
elif [ "$1" == "restore" ]; then
|
|
su ${USER} -lc "dsmserv restore db ${2:+password=$2} restorekeys=yes on=DBDIRS.TXT"
|
|
|
|
else
|
|
exec $@
|
|
fi
|