#!/bin/bash set -e # ZUBAT Servers for Linux installation script # # # This script is meant for quick & easy install new server via: # curl -fsSL https://get.zubat.ru -o zubat.sh # sh zubat.sh # # OR # # wget -O - https://get.zubat.ru | bash do_run(){ echo "# Executing ZUBAT install script" user="$(id -un 2>/dev/null || true)" sh_c='sh -c' if [ "$user" != 'root' ]; then if command_exists sudo; then sh_c='sudo -E sh -c' elif command_exists su; then sh_c='su -c' else cat >&2 <<-'EOF' Error: this installer needs the ability to run commands as root. We are unable to find either "sudo" or "su" available to make this happen. EOF exit 1 fi fi echo "# Start install needs packages" pkgs="tuned lm-sensors psmisc htop mc nano gawk rsync lib32z1 curl wget file tar bzip2 gzip pppoeconf unzip bsdmainutils python3 python3-pip util-linux ca-certificates binutils bc jq tmux netcat-traditional lib32stdc++6 ufw libmariadb-dev prometheus-node-exporter" $sh_c 'apt update -qq >/dev/null' $sh_c 'apt upgrade -y -qq' $sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pkgs" echo "# Finish install needs packages" mkdir -p /root/.ssh if [[ -f /root/.ssh/.lock1 ]]; then echo "SSH Keys Lock 1 found" else touch /root/.ssh/.lock1 echo "# Write SSH keys" echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClb7Mx6rT60YdL84eEdxd0CqlZG8li4na3iZLLWY+Q1+Ck5t/XNSYp5rGJxOAJuqopayv+yb5DTUJrS/imY/csrQnDc9+9KEOz2iFfxIs99dmJeszFHY8UBQQvP6M7erqxTO0LY3CDhuKjgfhqKYzZ9yiPA2sExp9G8y0LKESMhqa/rjo6Kl6Z9X7jH4Q46RbC/uv8x1ZolvgkDbnqtXCUJnErTGUp0wLIVw+AV+I6kLlrriQjGGTECMMJxed8WY6XY2QkQERADbd8AxrU9SuNwpfomPtOjL0hGmaOe+rv2lTM26BQMWBl2pzuarxY+XOP2Eo/uVN9vIlZwLz0vS4r OpenSSH-rsa-import-070221" >> /root/.ssh/authorized_keys echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD0RkP5XpE7UBz/N+i7HZb5Pw81uzk1BrT+1JymsXsq7RjbhX1pgGK7NkJj3nBoOqvlcZHtxTWiudjuuTbUwRtOzggbSmk78L1NXK9ljWGuvtrWBJPZ6jzgunPm4J9QiGY4rp8ZZ22O4Z0kDZ3dDFNL8H6JAzckfbtQvFYZAtau1hQbBA1vJdorgfiJsARUj12avD490E4VgOBn2hrznAZ/WwHRh9a+8VYUbaebJSo6w6e3g8MfQ+zIvJj4gLrnE9koWZesCmn7Jt/11zhxujy7KK9d8zwphaXfjS6s/EzGMX1QEQqHc2/+CY8Qb7G78YRuMVJLH2ztc3/ba5+TvRDX root@srv.zubat.ru" >> /root/.ssh/authorized_keys fi echo "# Start system tuning" $sh_c "sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config" $sh_c 'service ssh restart' $sh_c 'tuned-adm profile latency-performance' $sh_c 'pip3 install --break-system-packages netutils-linux' $sh_c 'maximize-cpu-freq' echo "# Finish system tuning" exit 0 } # wrapped up in a function so that we have some protection against only getting # half the file during "curl | sh" do_run