Blame
|
1 | # Server-Init-Script |
||||||
| 2 | ||||||||
| 3 | ## 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. |
|||||||
| 4 | ||||||||
| 5 | # WARNING: Copying code from the internet without reading it |
|||||||
| 6 | # is like eating a mysterious burrito you found on a park bench. |
|||||||
| 7 | # Sure, it might work... but there's a 404% chance of regret. |
|||||||
| 8 | ||||||||
| 9 | ```python |
|||||||
| 10 | def download_and_execute_random_code_from_the_internet(): |
|||||||
| 11 | import os |
|||||||
| 12 | import sys |
|||||||
| 13 | ||||||||
| 14 | print("Downloading code from shadyforum.biz/mystery_script.py...") |
|||||||
| 15 | # 🚨 DO NOT DO THIS 🚨 |
|||||||
| 16 | # os.system("curl http://shadyforum.biz/mystery_script.py | python3") |
|||||||
| 17 | ||||||||
| 18 | print("Just kidding! Let's be smarter than that.") |
|||||||
| 19 | print("✨ Always read and understand code before you run it!") |
|||||||
| 20 | print("Malicious code can delete files, steal data, or worse—") |
|||||||
| 21 | print("...make you start using tabs instead of spaces 🫢") |
|||||||
| 22 | ||||||||
| 23 | download_and_execute_random_code_from_the_internet() |
|||||||
| 24 | ``` |
|||||||
| 25 | ||||||||
| 26 | I host this on one of my domains so it is accessible at something akin to https://somewebsite.com/bootstrap.sh |
|||||||
| 27 | When I set up a new server I can run: |
|||||||
| 28 | ||||||||
| 29 | ```bash |
|||||||
| 30 | curl https://somewebsite.com/bootstrap.sh && sudo chmod +x ./bootstrap.sh && ./bootstrap.sh |
|||||||
| 31 | ``` |
|||||||
| 32 | ||||||||
| 33 | ```bash |
|||||||
| 34 | echo "Check if running as root..." |
|||||||
| 35 | if [[ $EUID -ne 0 ]]; then |
|||||||
| 36 | echo "This script must be run as root." 1>&2 |
|||||||
| 37 | exit 1 |
|||||||
| 38 | fi |
|||||||
| 39 | This script segment first prints the message "Check if running as root"" |
|||||||
| 40 | echo "Update First..." read answer |
|||||||
| 41 | sudo apt update && sudo apt upgrade -y |
|||||||
| 42 | echo "Install common packages?" |
|||||||
| 43 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 44 | echo "Instaling known needed packages." |
|||||||
| 45 | sudo apt install nano curl git wget ufw mc -y 1>&2 |
|||||||
| 46 | exit 1 |
|||||||
| 47 | fi |
|||||||
| 48 | echo "Install tailscale?" read answer |
|||||||
| 49 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 50 | echo "Installing tailscale." |
|||||||
| 51 | curl -fsSL https://tailscale.com/install.sh | sh |
|||||||
| 52 | sudo tailscale up |
|||||||
| 53 | fi |
|||||||
| 54 | echo "Install talosctl?" read answer |
|||||||
| 55 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 56 | echo "Installing talosctl." |
|||||||
| 57 | curl -sL https://talos.dev/install | sh 1>&2 |
|||||||
| 58 | exit 1 |
|||||||
| 59 | fi |
|||||||
| 60 | echo "Install kubectl?" read answer |
|||||||
| 61 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 62 | echo "Installing kubectl." |
|||||||
| 63 | curl -LO "https://dl.k8s.io/release/$(curl -L -s \ |
|||||||
| 64 | https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" |
|||||||
| 65 | sudo cp ./kubectl /usr/local/bin/kubectl |
|||||||
| 66 | chmod +x /usr/local/bin/kubectl |
|||||||
| 67 | fi |
|||||||
| 68 | echo "Install fish console?" read answer |
|||||||
| 69 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 70 | echo "Installing fish." |
|||||||
| 71 | sudo apt install fish |
|||||||
| 72 | chsh -s $(which fish) |
|||||||
| 73 | fi |
|||||||
| 74 | echo "Install pastey?" |
|||||||
| 75 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 76 | curl https://pastey.tebplex.tv/pastey |
|||||||
| 77 | sudo cp ./pastey /usr/local/bin/pastey |
|||||||
| 78 | sudo chmod +x /usr/local/bin/pastey |
|||||||
| 79 | fi |
|||||||
| 80 | echo "Do you want to reboot now?" read answer |
|||||||
| 81 | if [[ "$answer" == "yes" ]] || [[ "$answer" == "y" ]]; then |
|||||||
| 82 | echo "Rebooting now..." |
|||||||
| 83 | sudo reboot |
|||||||
| 84 | fi |
|||||||
| 85 | ``` |
|||||||