45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# -e = stop on exception, -x = debug, -a = export all variables
|
|
set -e -x -a
|
|
|
|
# Include config
|
|
. all_vars
|
|
|
|
### 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/sources.list root@$play_host:/etc/apt/sources.list
|
|
scp ./etc/locale.gen root@$play_host:/etc/locale.gen
|
|
ssh root@$play_host <<EOF
|
|
set -e -x
|
|
|
|
echo $node_name > /etc/hostname
|
|
|
|
hostname `cat /etc/hostname`
|
|
|
|
apt-get update
|
|
|
|
# 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
|
|
|
|
echo Europe/Moscow > /etc/timezone
|
|
ln -fs /usr/share/zoneinfo/Europe/Moscow /etc/timezone
|
|
|
|
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
|