Server-Init-Script

Skip the fairy-tale, just give me the code already --> Click Here

This is a little script I whipped up that I can curl during a fresh server setup—it handles installing the usual set of tools I use across most of my machines.

WARNING:

Copying code from the internet without reading it is like eating a mysterious burrito you found on a park bench. Sure, it might work... but there's a 404% chance of regret.

def download_and_execute_random_code_from_the_internet():
    import os
    import sys

    print("Downloading code from shadyforum.biz/mystery_script.py...")
    # 🚨 DO NOT DO THIS 🚨
    # os.system("curl http://shadyforum.biz/mystery_script.py | python3")

    print("Just kidding! Let's be smarter than that.")
    print("✨ Always read and understand code before you run it!")
    print("Malicious code can delete files, steal data, or worse—")
    print("...make you start using tabs instead of spaces 🫢")

download_and_execute_random_code_from_the_internet()

I host this on one of my domains so it is accessible at something akin to https://somewebsite.com/bootstrap.sh When I set up a new server I can run:

curl https://somewebsite.com/bootstrap.sh && sudo chmod +x ./bootstrap.sh && sudo ./bootstrap.sh

There is also this version that will download and run the script all in one command, this is an even worse idea than the above if you don't trust the source.

One-shot

curl -sSL https://somewebsite.com/bootstrap.sh | sudo bash

Bootstrap Script

Copy-Pasta below, don't forget to modify the URL for pastey if you use it or eliminate that section from the below to the above comment in the block below.

echo "Check if running as root..."
if [[ $EUID -ne 0 ]]; then
  echo "This script must be run as root." 1>&2
  exit 1
fi
This script segment first prints the message "Check if running as root""
echo "Update First..." read answer
sudo apt update && sudo apt upgrade -y
echo "Install common packages?"
if [[ "$answer" ==  "yes" ]] || [[ "$answer" ==  "y" ]]; then
  echo "Instaling known needed packages."
  sudo apt install nano curl git wget ufw mc -y 1>&2
  exit 1
fi
echo "Install tailscale?" read answer
if [[ "$answer" ==  "yes" ]] || [[ "$answer" ==  "y" ]]; then
  echo "Installing tailscale."
  curl -fsSL https://tailscale.com/install.sh | sh
  sudo tailscale up
fi
echo "Install talosctl?" read answer
if [[ "$answer" ==  "yes" ]] || [[ "$answer" ==  "y" ]]; then
  echo "Installing talosctl."
  curl -sL https://talos.dev/install | sh 1>&2
  exit 1
fi
echo "Install kubectl?" read answer
if [[ "$answer" ==  "yes" ]] || [[ "$answer" ==  "y" ]]; then
  echo "Installing kubectl."
  curl -LO "https://dl.k8s.io/release/$(curl -L -s \
  https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  sudo cp ./kubectl /usr/local/bin/kubectl
  chmod +x /usr/local/bin/kubectl
fi
echo "Install fish console?" read answer  
if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then
  echo "Installing fish."
  sudo apt install fish
  chsh -s $(which fish)
fi
########################################################################
# Pastey is below
echo "Install pastey?"
if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then
  curl https://somewebsite.com/pastey
  sudo cp ./pastey /usr/local/bin/pastey
  sudo chmod +x /usr/local/bin/pastey
fi
# Pastey is above
########################################################################
echo "Do you want to reboot now?" read answer
if [[ "$answer" ==  "yes" ]] || [[ "$answer" ==  "y" ]]; then
  echo "Rebooting now..."
  sudo reboot
fi
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9