Commit 2f0fd3
2025-07-06 21:14:33 Tebby Dog: Init/dev/null .. 2-code/server-init-script.md | |
@@ 0,0 1,85 @@ | |
+ | # Server-Init-Script |
+ | |
+ | ## This is a script I wrote that I can curl when setting up a new server to install tools I use on 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. |
+ | |
+ | ```python |
+ | 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: |
+ | |
+ | ```bash |
+ | curl https://somewebsite.com/bootstrap.sh && sudo chmod +x ./bootstrap.sh && ./bootstrap.sh |
+ | ``` |
+ | |
+ | ```bash |
+ | 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 |
+ | echo "Install pastey?" |
+ | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
+ | curl https://pastey.tebplex.tv/pastey |
+ | sudo cp ./pastey /usr/local/bin/pastey |
+ | sudo chmod +x /usr/local/bin/pastey |
+ | fi |
+ | echo "Do you want to reboot now?" read answer |
+ | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
+ | echo "Rebooting now..." |
+ | sudo reboot |
+ | fi |
+ | ``` |