diff --git a/set-up-system.sh b/set-up-system.sh index 6e2cca2..9c1206e 100755 --- a/set-up-system.sh +++ b/set-up-system.sh @@ -2,12 +2,21 @@ set -e sudo -v -function banner_top() { - echo -e "────┤ $1 ├────\n" -} +# 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// /─} -function banner_bottom() { - echo -e "\n────┤ $1 ├────\n\n\n" + 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 @@ -19,49 +28,77 @@ cat << 'EOF' /___//___/ ..... brought to you by futile + EOF # check if on fedora if ! grep -q '^ID=fedora$' /etc/os-release 2>/dev/null; then - banner_top "errrm... why aren't you on fedora" + 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 dnf -banner_top "configuring dnf" +banner top "configuring dnf" sudo tee /etc/dnf/dnf.conf << 'EOF' [main] defaultyes = True max_parallel_downloads = 10 EOF -banner_bottom "configured dnf" +banner bottom "configured dnf" # update system -banner_top "updating system" +banner top "updating system" sudo dnf update -y -banner_bottom "updated system" +banner bottom "updated system" # install (& configure) docker -banner_top "installing 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" +banner bottom "installed docker" # install (& configure) fish -banner_top "installing 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" +banner bottom "installed fish" # install misc -banner_top "installing other packages" +banner top "installing other packages" sudo dnf install -y micro btop fastfetch -banner_bottom "installed other packages" +banner bottom "installed other packages" # finish -banner_top "done! please log out and log back in" +echo -e "done! please log out and log back in\n"