66 lines
1.9 KiB
Bash
66 lines
1.9 KiB
Bash
#!/bin/sh
|
|
# preinst script for #PACKAGE#
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
# summary of how this script can be called:
|
|
# * <new-preinst> `install'
|
|
# * <new-preinst> `install' <old-version>
|
|
# * <new-preinst> `upgrade' <old-version>
|
|
# * <old-preinst> `abort-upgrade' <new-version>
|
|
# for details, see https://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
|
|
case "$1" in
|
|
install|upgrade)
|
|
|
|
[ -z "$NODE_ID" ] && export NODE_ID=$(ip -4 -br addr | grep 10.0. | awk '{ print $3 }' | awk 'BEGIN{FS="[./]"} { print $4 }')
|
|
|
|
MGMT_ID=$(ip -4 -br addr | grep 10.0. | awk '{ print $3 }' | awk 'BEGIN{FS="[./]"} { print $3 }')
|
|
|
|
|
|
[ "$MGMT_ID" -ge 0 -a "$MGMT_ID" -lt 16 ] && export DOMAINNAME=.usw1.wit.com
|
|
[ "$MGMT_ID" -ge 16 -a "$MGMT_ID" -lt 32 ] && export DOMAINNAME=.usw2.wit.com
|
|
|
|
|
|
[ ${HOSTNAME:0:1} = h ] && export HOSTTYPE=hypervisor
|
|
[ ${HOSTNAME:0:1} = d ] && export HOSTTYPE=datanode
|
|
|
|
|
|
[ $HOSTTYPE = hypervisor -a $DOMAINNAME = .usw1.wit.com ] && export TIER_ID=2
|
|
[ $HOSTTYPE = datanode -a $DOMAINNAME = .usw1.wit.com ] && export TIER_ID=4
|
|
[ $HOSTTYPE = hypervisor -a $DOMAINNAME = .usw2.wit.com ] && export TIER_ID=18
|
|
[ $HOSTTYPE = datanode -a $DOMAINNAME = .usw2.wit.com ] && export TIER_ID=20
|
|
|
|
|
|
if [ -z "$TIER_ID" ]; then
|
|
echo "Unable to autodetect TIER_ID, looks like we deal with a special node, please set in environment"
|
|
exit 2
|
|
fi
|
|
if [ -z "$DOMAINNAME" ]; then
|
|
echo "Unable to autodetect DOMAINNAME, looks like we deal with a special case, please set in environment and/or update the code"
|
|
exit 2
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
abort-upgrade)
|
|
;;
|
|
|
|
*)
|
|
echo "preinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
# generated by other debhelper scripts.
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|