140 lines
3.2 KiB
Bash
140 lines
3.2 KiB
Bash
#!/bin/sh
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
export PATH
|
|
|
|
LANG="en_US.UTF-8"
|
|
export LANG
|
|
|
|
if [ -s "/etc/os-release" ]; then
|
|
. /etc/os-release
|
|
if [ "${ID}" != "debian" ]; then
|
|
echo "*** NOT DEBIAN ***"
|
|
echo "*** ABORTING *****"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "*** UNKNOWN DIST ***"
|
|
echo "*** ABORTING *******"
|
|
exit 1
|
|
fi
|
|
|
|
MYUSER=$(whoami)
|
|
if [ "${MYUSER}" != "root" ]; then
|
|
echo "*** USER NOT ROOT ***"
|
|
echo "*** ABORTING ********"
|
|
exit 1
|
|
fi
|
|
|
|
echo "*** START ***"
|
|
|
|
echo "## cleaning sources.list"
|
|
sed -i '/^deb cdrom:/d' /etc/apt/sources.list
|
|
|
|
DEBIAN_FRONTEND=noninteractive
|
|
export DEBIAN_FRONTEND
|
|
|
|
trap "dpkg --configure -a" 1 2 3 9 11 15
|
|
|
|
echo "## updating repos"
|
|
apt-get -y update | grep -v -e "^Hit:" -e "^Get:"
|
|
|
|
echo "## upgrading system"
|
|
apt-get -y dist-upgrade
|
|
|
|
echo "## updating locales"
|
|
apt-get -q -y install locales | grep -v -e "is already the newest version"
|
|
|
|
LOC1=$(md5sum /etc/locale.gen | cut -b 1-32)
|
|
|
|
sed -i 's/^# *de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
|
sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
|
|
|
LOC2=$(md5sum /etc/locale.gen | cut -b 1-32)
|
|
|
|
if [ "${LOC1}" != "${LOC2}" ]; then
|
|
locale-gen | grep -v -e "^ "
|
|
fi
|
|
|
|
cat >/etc/default/locale <<EOF
|
|
LANG=en_US.UTF-8
|
|
LANGUAGE=en_US:en
|
|
LC_CTYPE=en_US.UTF-8
|
|
LC_NUMERIC=de_DE.UTF-8
|
|
LC_TIME=de_DE.UTF-8
|
|
LC_COLLATE=en_US.UTF-8
|
|
LC_MONETARY=de_DE.UTF-8
|
|
LC_MESSAGES=en_US.UTF-8
|
|
LC_PAPER=de_DE.UTF-8
|
|
LC_NAME=de_DE.UTF-8
|
|
LC_ADDRESS=de_DE.UTF-8
|
|
LC_TELEPHONE=de_DE.UTF-8
|
|
LC_MEASUREMENT=de_DE.UTF-8
|
|
LC_IDENTIFICATION=de_DE.UTF-8
|
|
EOF
|
|
|
|
echo "## setting options"
|
|
sed -i 's/^#precedence ::ffff:0:0\/96 100/precedence ::ffff:0:0\/96 100/g' /etc/gai.conf
|
|
|
|
echo "## services mgmt"
|
|
MPT=$(dpkg -l | grep -c multipath-tools)
|
|
if [ "${MPT}" -gt 0 ]; then
|
|
for service in multipathd.service multipathd.socket multipath-tools-boot.service multipath-tools.service
|
|
do
|
|
systemctl stop "$service" 2>/dev/null || true
|
|
systemctl disable "$service" 2>/dev/null || true
|
|
done
|
|
fi
|
|
|
|
echo "## installing tools"
|
|
dpkg --configure -a
|
|
apt-get -q -y install \
|
|
net-tools \
|
|
uptimed \
|
|
unattended-upgrades \
|
|
curl \
|
|
ntpsec-ntpdate \
|
|
wget \
|
|
rsyslog \
|
|
vim \
|
|
psmisc \
|
|
rsync \
|
|
bmon \
|
|
tcpdump \
|
|
mtr-tiny \
|
|
moreutils \
|
|
ifenslave \
|
|
pigz \
|
|
git | grep -v -e "is already the newest version"
|
|
|
|
echo "## enabling unattended-upgrades"
|
|
echo unattended-upgrades unattended-upgrades/enable_auto_updates boolean true | debconf-set-selections
|
|
dpkg-reconfigure -f noninteractive unattended-upgrades
|
|
|
|
echo "## setting vim config"
|
|
if [ ! -f "/root/.vimrc" ]; then
|
|
truncate -s0 /root/.vimrc
|
|
echo "set mouse=" >>/root/.vimrc
|
|
echo "syntax on" >>/root/.vimrc
|
|
fi
|
|
|
|
echo "## setting ssh keys"
|
|
mkdir -p /root/.ssh/
|
|
chmod 700 /root/ /root/.ssh/
|
|
truncate -s0 /root/.ssh/authorized_keys
|
|
|
|
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICFP1rThjJUx618ao9fmvLCTAvMdIyPLz5DTFZsfo6fo jenni@jenni-Latitude-5420" >>/root/.ssh/authorized_keys
|
|
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEXgwNeuzCW6NG5gLDcq/YIsy3LifxtuesAUkYHNNKV root@backup" >>/root/.ssh/authorized_keys
|
|
|
|
chmod 600 /root/.ssh/authorized_keys
|
|
chown -R root:root /root/.ssh
|
|
if [ -f "/root/.vimrc" ]; then
|
|
chown root:root /root/.vimrc
|
|
fi
|
|
|
|
echo "## syncing time"
|
|
ntpdate pool.ntp.org || true
|
|
hwclock --systohc || true
|
|
|
|
echo "*** DONE ***"
|