#!/bin/bash # -e = stop on exception, -x = debug, -a = export all variables set -e -x -a # Include config . ./load-config.sh ### Check host variables if [ -z "$play_host" -o -z "$node_name" -o -z "$int_ip" ]; then echo "play_host/node_name/int_ip not specified" exit 1 fi scp ./etc/apt/apt.conf root@$play_host:/etc/apt/apt.conf scp ./etc/apt/preferences root@$play_host:/etc/apt/preferences scp ./etc/apt/sources.list root@$play_host:/etc/apt/sources.list scp ./etc/locale.gen root@$play_host:/etc/locale.gen # Set time sync envsubst < ./etc/systemd/timesyncd.conf.env | \ ssh root@$play_host 'cat > /etc/systemd/timesyncd.conf' ssh root@$play_host < /etc/hostname hostname \`cat /etc/hostname\` systemctl enable systemd-timesyncd && systemctl restart systemd-timesyncd systemctl mask emergency.service systemctl mask emergency.target apt-get update || true # gpg and friends for apt-key to work correctly DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" \ -o Dpkg::Options::="--force-confold" install -y \ mc wget less locales telnet atop sysstat tmux \ gpg gpg-agent dirmngr apt-transport-https \ prometheus-node-exporter grep -q -P '127.0.1.1\s+$node_name' /etc/hosts || (echo "127.0.1.1 $node_name" >> /etc/hosts) wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add - apt-get update || true rm /etc/timezone echo Europe/Moscow > /etc/timezone ln -fs /usr/share/zoneinfo/Europe/Moscow /etc/localtime if ! grep -q '^PermitRootLogin' /etc/ssh/sshd_config; then echo PermitRootLogin without-password >> /etc/ssh/sshd_config service ssh restart elif ! grep -q '^PermitRootLogin without-password' /etc/ssh/sshd_config; then perl -i -pe 's/^PermitRootLogin.*/PermitRootLogin without-password/' /etc/ssh/sshd_config service ssh restart fi EOF