This commit is contained in:
2018-01-24 20:52:43 -06:00
parent cc9fb4986a
commit 43d232aa75
36 changed files with 2802 additions and 0 deletions

114
slack-dist/bin/distro Executable file
View File

@@ -0,0 +1,114 @@
#!/bin/bash
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
if [ -f /etc/fedora-release ]; then
DIST=$(cat /etc/fedora-release | awk '{print $1}')
REV=`cat /etc/fedora-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/redhat-release ] ; then
DIST=$(cat /etc/redhat-release | awk '{print $1}')
if [ "${DIST}" = "CentOS" ]; then
DIST="CentOS"
elif [ "${DIST}" = "Mandriva" ]; then
DIST="Mandriva"
PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/oracle-release ]; then
DIST="Oracle"
else
DIST="RedHat"
fi
PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/mandrake-release ] ; then
DIST='Mandrake'
PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/devuan_version ] ; then
DIST="Devuan `cat /etc/devuan_version`"
REV=""
elif [ -f /etc/debian_version ] ; then
DIST="Debian `cat /etc/debian_version`"
REV=""
ID=`lsb_release -i | awk -F ':' '{print $2}' | sed 's/ //g'`
if [ "${ID}" = "Raspbian" ] ; then
DIST="Raspbian `cat /etc/debian_version`"
fi
elif [ -f /etc/gentoo-release ] ; then
DIST="Gentoo"
REV=$(tr -d '[[:alpha:]]' </etc/gentoo-release | tr -d " ")
elif [ -f /etc/arch-release ] ; then
DIST="Arch Linux"
REV="" # Omit version since Arch Linux uses rolling releases
IGNORE_LSB=1 # /etc/lsb-release would overwrite $REV with "rolling"
elif [ -f /etc/os-release ] ; then
DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"')
REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"')
elif [ -f /etc/openwrt_version ] ; then
DIST="OpenWrt"
REV=$(cat /etc/openwrt_version)
elif [ -f /etc/pld-release ] ; then
DIST=$(cat /etc/pld-release)
REV=""
elif [ -f /etc/SuSE-release ] ; then
DIST=$(echo SLES $(grep VERSION /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
REV=$(echo SP$(grep PATCHLEVEL /etc/SuSE-release | cut -d = -f 2 | tr -d " "))
fi
if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then
LSB_DIST=$(lsb_release -si)
LSB_REV=$(lsb_release -sr)
if [ "$LSB_DIST" != "" ] ; then
DIST=$LSB_DIST
fi
if [ "$LSB_REV" != "" ] ; then
REV=$LSB_REV
fi
fi
if [ "`uname -a | awk '{print $(NF)}'`" = "DD-WRT" ] ; then
DIST="dd-wrt"
fi
if [ -n "${REV}" ]
then
OSSTR="${DIST} ${REV}"
else
OSSTR="${DIST}"
fi
elif [ "${OS}" = "Darwin" ] ; then
if [ -f /usr/bin/sw_vers ] ; then
OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
fi
elif [ "${OS}" = "FreeBSD" ] ; then
OSSTR=`/usr/bin/uname -mior`
fi
echo ${OSSTR}

View File

@@ -0,0 +1,103 @@
#!/bin/bash
#TSYS Slack installer
#Use as a reference for other TSYS scripts
#######################################################################################################################################################
#Global variables
#######################################################################################################################################################
export MGMT_INT="$(netstat -rn |grep 0.0.0.0|awk '{print $NF}' |head -n1 )"
export ENVIP="$(echo $MGMT_IP|awk -F '.' '{print $2}')"
export DIST_SERVER="http://tsys-techops.turnsys.net/"
export DIST_ROOT_PATH="slack-dist"
#######################################################################################################################################################
#Execution begins
#######################################################################################################################################################
#######################################################################################################################################################
#Step 1. determine server type and site
#######################################################################################################################################################
#Will be useful later when we have fleets of kvm/lxc etc machines, commented out for now.
#if [ $(hostname -s|egrep -i -c -E 'ts|ts[0-9]|ts[0-9][0-9]|ts[0-9][0-9][0-9]|linux') -eq 1 ]; then
#export server_type=ts
#fi
#if [ $(hostname -s|egrep -c -E 'cvm') -eq 1 ]; then
#export server_type=cvm
#fi
case $server_type in
ts)
export SERVER_TYPE="ts"
;;
cvm)
export SERVER_TYPE="cvm"
;;
bvm)
export SERVER_TYPE="bvm"
;;
*)
export SERVER_TYPE="prod"
;;
esac
case $ENVIP in
253)
export SITE="ovh"
;;
251)
export SITE="aus"
;;
40)
export SITE="satx"
;;
*)
esac
#######################################################################################################################################################
#Step 2: Fixup the /etc/hosts file
#######################################################################################################################################################
#Static /etc/hosts bits
cat > /etc/hosts << HOSTFILESTATIC
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
HOSTFILESTATIC
#Dynamic /etc/hosts bits
cat >> /etc/hosts <<HOSTFILEDYNAMIC
127.0.1.1 $(hostname) $(hostname -s)
$MGMT_IP $(hostname) $(hostname -s)
HOSTFILEDYNAMIC
#######################################################################################################################################################
#Step 3: Grab slack runtime bits and deploy slack
#######################################################################################################################################################
curl $DIST_SERVER/$DIST_ROOT_PATH/distro > /usr/bin/distro
chmod +x /usr/bin/distro
apt-get -y install make perl rsync
mkdir /tmp/slackDist
wget $DIST_SERVER/$DIST_ROOT_PATH/slackDist.tar.gz -O /tmp/slackDist/slackDist.tar.gz
cd /tmp/slackDist
tar xvfz slackDist.tar.gz
make install
cd /tmp
rm -rf slackDist
mkdir /root/.ssh
chmod 700 /root/.ssh
chown -R root:root /root/.ssh
wget $DIST_SERVER/$DIST_ROOT_PATH/env/$SITE/SlackConfig-$LR-$SERVER_TYPE.config -O /etc/slack.conf
wget $DIST_SERVER/$DIST_ROOT_PATH/env/$SITE/SlackSSH-$SITE-$SERVER_TYPE.config -O /root/.ssh/config
wget $DIST_SERVER/$DIST_ROOT_PATH/env/$SITE/SlackSSH-$SITE-$SERVER_TYPE.key -O /root/.ssh/SlackSSH-$SITE-$SERVER_TYPE.key
chmod 400 /root/.ssh/SlackSSH-$LR-$SERVER_TYPE.key
chmod 400 /root/.ssh/config