#!/usr/bin/env bash set -e sudo -v # the horrors function banner() { local pos=$1 local w=50 local text=" $2 " local pad=$((w - ${#text})) local l=$((pad/2)) r=$((pad - pad/2)) local left=$(printf '%*s' "$l" ''); left=${left// /─} local right=$(printf '%*s' "$r" ''); right=${right// /─} if [[ "$pos" == "top" ]]; then printf "┌%s%s%s┐\n\n" "$left" "$text" "$right" else printf "\n└%s%s%s┘\n\n" "$left" "$text" "$right" fi } # https://patorjk.com/software/taag/#p=display&f=Small+Slant cat << 'EOF' __ __ _ / /_/ / (_)__ ___ ___ __ / __/ _ \/ / _ \/ _ `/ // / \__/_//_/_/_//_/\_, /\_, / /___//___/ ..... brought to you by futile EOF # check if on fedora if ! grep -q '^ID=fedora$' /etc/os-release 2>/dev/null; then echo "errrm... why aren't you on fedora" exit 1 fi # get preferences banner top "getting preferences" while [[ -z "$hostname" ]]; do read -rp "choose hostname: " hostname done while [[ -z "$pubkey" ]]; do read -rp "give ssh key: " pubkey done echo -e "using hostname \"$hostname\"" banner bottom "got preferences" # write ssh key banner top "writing ssh key" sudo mkdir -p ~/.ssh sudo chmod 700 ~/.ssh sudo touch ~/.ssh/authorized_keys sudo chmod 600 ~/.ssh/authorized_keys sudo chown -R admin ~/.ssh echo "$pubkey" >> ~/.ssh/authorized_keys banner bottom "wrote ssh key" # change hostname banner top "changing hostname" sudo hostnamectl hostname $hostname sudo hostnamectl banner bottom "changed hostname" # configure sshd banner top "configuring sshd" sudo tee /etc/ssh/sshd_config << 'EOF' Include /etc/ssh/sshd_config.d/*.conf PermitRootLogin no PasswordAuthentication no KbdInteractiveAuthentication no EOF sudo systemctl reload sshd banner bottom "configuring sshd" # configure dnf banner top "configuring dnf" sudo tee /etc/dnf/dnf.conf << 'EOF' [main] defaultyes = True max_parallel_downloads = 10 EOF banner bottom "configured dnf" # update system banner top "updating system" sudo dnf update -y banner bottom "updated system" # install (& configure) docker banner top "installing docker" sudo dnf config-manager addrepo --from-repofile https://download.docker.com/linux/fedora/docker-ce.repo --overwrite sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo usermod -aG docker $(id -un) sudo systemctl enable --now docker sudo docker run hello-world banner bottom "installed docker" # install (& configure) fish banner top "installing fish" sudo dnf install -y fish sudo chsh -s $(which fish) $(id -un) fish -c "set -U fish_greeting" fish -c "set -Ux EDITOR $(which micro)" banner bottom "installed fish" # install misc banner top "installing other packages" sudo dnf install -y micro btop fastfetch banner bottom "installed other packages" # finish echo -e "done! please log out and log back in\n"