|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
|
|
# Unofficial Bash Strict Mode |
|
|
|
|
# Bash Strict Mode |
|
|
|
|
set -euo pipefail |
|
|
|
|
IFS=' |
|
|
|
|
' |
|
|
|
|
cd -P "$(dirname "$0")" |
|
|
|
|
PS4='-\D{%F %T} ' |
|
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive |
|
|
|
|
export DEBIAN_PRIORITY=critical |
|
|
|
@ -11,6 +13,10 @@ export DEBIAN_PRIORITY=critical
|
|
|
|
|
# Fix Debian 10 bug (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=905409) |
|
|
|
|
PATH=/sbin:/usr/sbin:$PATH |
|
|
|
|
|
|
|
|
|
function sysConfig() { |
|
|
|
|
# Navigate to tmp |
|
|
|
|
cd /tmp |
|
|
|
|
|
|
|
|
|
# Debian stable OS |
|
|
|
|
apt-get update |
|
|
|
|
apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade |
|
|
|
@ -61,7 +67,7 @@ fi
|
|
|
|
|
EOF |
|
|
|
|
|
|
|
|
|
# Basic packages |
|
|
|
|
apt-get -y install man bash-completion git ufw jq curl build-essential netcat wget psmisc lz4 file net-tools brotli unzip zip moreutils dnsutils fail2ban xauth sysfsutils rsync iperf pv tree mc screen ssh iotop whois sudo |
|
|
|
|
apt-get -y install man bash-completion git ufw jq curl build-essential netcat wget psmisc lz4 file net-tools brotli unzip zip moreutils dnsutils fail2ban xauth sysfsutils rsync iperf pv tree mc screen ssh iotop htop awscli whois sudo |
|
|
|
|
|
|
|
|
|
# Enable time synchronization |
|
|
|
|
timedatectl set-ntp true |
|
|
|
@ -135,6 +141,13 @@ curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compo
|
|
|
|
|
chmod +x /usr/local/bin/docker-compose |
|
|
|
|
curl -L https://raw.githubusercontent.com/docker/compose/1.29.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose |
|
|
|
|
|
|
|
|
|
# NodeJS |
|
|
|
|
curl -fsSL https://deb.nodesource.com/setup_18.x | bash && apt-get install -y nodejs |
|
|
|
|
|
|
|
|
|
# Git |
|
|
|
|
echo deb http://deb.debian.org/debian buster-backports main | tee /etc/apt/sources.list.d/buster-backports.list |
|
|
|
|
apt-get update && apt-get -y install -t buster-backports git |
|
|
|
|
|
|
|
|
|
# Generate SSH key |
|
|
|
|
ssh-keygen -ted25519 -f ~/.ssh/id_ed25519 -N '' |
|
|
|
|
|
|
|
|
@ -148,5 +161,74 @@ apt-get -y purge unattended-upgrades
|
|
|
|
|
apt-get -y autoremove --purge |
|
|
|
|
apt-get clean |
|
|
|
|
|
|
|
|
|
# The end |
|
|
|
|
# SSH Keys Infra Team |
|
|
|
|
curl https://github.com/{harryvasanth,frenchris,kigiri}.keys >>~/.ssh/authorized_keys |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Check Config |
|
|
|
|
function checkConfig() { |
|
|
|
|
test "$(command -v "${1:-}")" && echo -n ✅ || echo -n ❌ |
|
|
|
|
echo " $@" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Check configs in the List |
|
|
|
|
function checkList() { |
|
|
|
|
checkConfig docker-compose |
|
|
|
|
checkConfig docker |
|
|
|
|
checkConfig node |
|
|
|
|
checkConfig git |
|
|
|
|
checkConfig man |
|
|
|
|
checkConfig ufw |
|
|
|
|
checkConfig jq |
|
|
|
|
checkConfig curl |
|
|
|
|
checkConfig netcat |
|
|
|
|
checkConfig wget |
|
|
|
|
checkConfig lz4 |
|
|
|
|
checkConfig file |
|
|
|
|
checkConfig brotli |
|
|
|
|
checkConfig unzip |
|
|
|
|
checkConfig zip |
|
|
|
|
checkConfig fail2ban-server |
|
|
|
|
checkConfig xauth |
|
|
|
|
checkConfig rsync |
|
|
|
|
checkConfig iperf |
|
|
|
|
checkConfig pv |
|
|
|
|
checkConfig tree |
|
|
|
|
checkConfig mc |
|
|
|
|
checkConfig screen |
|
|
|
|
checkConfig ssh |
|
|
|
|
checkConfig iotop |
|
|
|
|
checkConfig htop |
|
|
|
|
checkConfig aws |
|
|
|
|
checkConfig whois |
|
|
|
|
checkConfig sudo |
|
|
|
|
|
|
|
|
|
test "$(ls ~/.ssh/*.pub 2>/dev/null)" && echo -n ✅ || echo -n ❌ |
|
|
|
|
echo " SSH private/public key pair generated" |
|
|
|
|
} |
|
|
|
|
if [[ ! -n ${1:-} ]] || [[ "--check" = $1 ]]; then |
|
|
|
|
echo -e "$(tput setaf 2)$(tput bold)\nCommencing configuration check: $(tput sgr0)\n" |
|
|
|
|
checkList |
|
|
|
|
echo -e "$(tput setaf 2)\nSystem configuration check complete! $(tput sgr0)" |
|
|
|
|
exit 0 |
|
|
|
|
elif [[ "--help" = $1 ]]; then |
|
|
|
|
echo "$(tput setaf 2) --check : to check the current configuration. $(tput sgr0)" |
|
|
|
|
echo "$(tput setaf 3) --run : to configure the system. $(tput sgr0)" |
|
|
|
|
echo "$(tput setaf 1) --reboot : to configure the system and reboot. $(tput sgr0)" |
|
|
|
|
echo "$(tput setaf 7) --help : to display this message. $(tput sgr0)" |
|
|
|
|
elif [[ "--reboot" = $1 ]]; then |
|
|
|
|
echo -e "$(tput setaf 1)$(tput bold)\nSystem will be configured and rebooted. $(tput sgr0)\n" |
|
|
|
|
sysConfig |
|
|
|
|
echo -e "$(tput setaf 1)\nSystem configuration complete. Rebooting now... $(tput sgr0)" |
|
|
|
|
reboot |
|
|
|
|
elif [[ "--run" = $1 ]]; then |
|
|
|
|
echo -e "$(tput setaf 3)$(tput bold)\nSystem will be configured without rebooting. $(tput sgr0)\n" |
|
|
|
|
sysConfig |
|
|
|
|
echo -e "$(tput setaf 3)\nSystem configuration complete! $(tput sgr0)" |
|
|
|
|
exit 0 |
|
|
|
|
else |
|
|
|
|
echo "$(tput setaf 1)$(tput bold) Unknown configuration option: $1 $(tput sgr0)" |
|
|
|
|
echo "$(tput setaf 1)Please use --help for all available options. $(tput sgr0)" |
|
|
|
|
echo "$(tput setaf 1)No changes are made $(tput sgr0)" |
|
|
|
|
exit 0 |
|
|
|
|
fi |
|
|
|
|