LegacyTechops/slack/prod/tsys-base/scripts/postinstall

116 lines
3.7 KiB
Plaintext
Raw Normal View History

2018-02-02 04:14:37 +00:00
#!/bin/bash
2018-02-09 03:04:36 +00:00
ISUCS="$(hostname |grep ucs -c)"
if [ $ISUCS -ne 0 ]; then
echo "Do not run this on ucs host. Exiting..."
exit 1
fi
2019-04-21 16:14:47 +00:00
########################################
#Common to all systems
########################################
#Fix timezone
unlink /etc/localtime
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime
2019-02-25 03:07:14 +00:00
MGMT_INT=$(netstat -rn|grep 0.0.0.0|head -n1|awk '{print $NF}')
PFV_MGMT_IP=$(ifconfig $MGMT_INT|grep inet|grep 10.251 -c)
2020-03-01 22:10:07 +00:00
OVH_MGMT_IP=$(ifconfig $MGMT_INT|grep inet|grep 10.222 -c)
2019-02-25 03:07:14 +00:00
if [ $PFV_MGMT_IP -eq 1 ]; then
tsysSysLocation=pfv
fi
if [ $OVH_MGMT_IP -eq 1 ]; then
tsysSysLocation=ovh
fi
2019-04-21 17:39:40 +00:00
2019-04-21 19:29:05 +00:00
#######################################################################################################################################################
#Fixup the /etc/hosts file
#######################################################################################################################################################
if [ $PFV_MGMT_IP -eq 1 ]; then
#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).pfv.turnsys.net $(hostname -s)
HOSTFILEDYNAMIC
fi
if [ $OVH_MGMT_IP -eq 1 ]; then
#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).turnsys.net $(hostname -s)
HOSTFILEDYNAMIC
fi
2019-04-21 17:09:51 +00:00
#Step 1: Update the cache and apply all vendor patches
echo "Running apt-get update"
2019-04-21 18:39:18 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::="--force-confold" update
2019-04-21 17:09:51 +00:00
echo "Running apt-get dist-upgrade"
2019-04-21 18:39:18 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::="--force-confold" dist-upgrade
2019-04-21 17:09:51 +00:00
echo "Running apt-get upgrade"
2019-04-21 18:39:18 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::="--force-confold" upgrade
2019-04-21 17:09:51 +00:00
echo "Running apt-get purge"
2019-04-21 18:39:18 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --purge -o Dpkg::Options::="--force-confold" autoremove --yes
2019-04-21 17:09:51 +00:00
#Step 2: Cleanup default cruft
echo "removing evil from the world, one nano install at a time"
2019-04-21 19:18:29 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes --purge -o Dpkg::Options::="--force-confold" remove nano resolvconf openresolv
2019-04-21 17:09:51 +00:00
2019-04-21 18:37:06 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::="--force-confold" install git etckeeper
git config --global user.email "techops@turnsys.com"
git config --global user.name "Techops"
2019-04-21 19:29:05 +00:00
hostname -f > /etc/mailname
2019-04-21 17:09:51 +00:00
#Step 3: The usual suspects
2020-03-04 13:02:40 +00:00
export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::="--force-confold" install snmpd ncdu iftop nethogs screen acct tshark tcpdump glances dstat htop sysdig sysstat rsync clamav logwatch zsh sl postfix molly-guard mailutils lldpd auditd rkhunter rsyslog ngrep ntp nut-client lm-sensors zlib1g-dev uuid-dev libmnl-dev gcc make autoconf autoconf-archive autogen automake pkg-config curl python-dnspython python-mysqldb libssl-dev libuv1-dev
2019-04-22 04:02:43 +00:00
# download it - the directory 'netdata' will be created
cd /root
git clone https://github.com/netdata/netdata.git --depth=100
cd netdata
# run script with root privileges to build, install, start Netdata
2020-03-05 00:53:08 +00:00
./netdata-installer.sh --disable-cloud -u --dont-wait --stable-channel
2019-04-22 04:02:43 +00:00
2019-04-21 17:09:51 +00:00
#Turn on process accounting
echo "Turning on process accounting..."
accton on
2019-04-21 17:48:38 +00:00
newaliases
2019-02-25 03:07:14 +00:00
slack tsys-$tsysSysLocation