This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
spdocker/init

57 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2018-03-07 23:38:02 +00:00
#!/bin/bash
set -e
NAME="SP"
function stop {
echo "Stopping ${NAME}"
2024-02-24 11:28:31 +00:00
kill $(pgrep dsmserv)
echo "You should really connect with a client and issue HALT" && sleep 60
2018-03-07 23:38:02 +00:00
}
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 &
2024-02-24 11:28:31 +00:00
# **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
2018-03-07 23:38:02 +00:00
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/
2018-03-11 00:24:07 +00:00
mkdir /database.init/tsmdb /database.init/activelog /database.init/archlog /database.init/archfaillog /database.init/mirrorlog
chown -R ${USER}:servers /database.init /tsm.init
2018-03-07 23:38:02 +00:00
# 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}
2024-02-24 11:28:31 +00:00
elif [ "$1" == "restoredb" ]; then
2018-03-07 23:38:02 +00:00
su ${USER} -lc "dsmserv restore db ${2:+password=$2} restorekeys=yes on=DBDIRS.TXT"
2024-02-24 11:28:31 +00:00
elif [ "$1" == "restore" ]; then
echo "! Running [dsmserv $@]"
su ${USER} -lc "dsmserv $@"
2018-03-07 23:38:02 +00:00
else
exec $@
fi