Public repo to distribute scripts and config's
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

83 lignes
2.7 KiB

il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
il y a 2 semaines
  1. #!/bin/bash
  2. update_system() {
  3. echo "Updating system and installing mandatory tools"
  4. apt-get update
  5. apt-get install sudo nmon tmux restic tcpdump nano iputils-ping net-tools -y
  6. }
  7. install_docker() {
  8. echo "Installing Docker"
  9. apt-get install ca-certificates curl gnupg lsb-release -y
  10. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  11. echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
  12. apt-get update
  13. apt-get install docker-ce docker-ce-cli containerd.io -y
  14. systemctl start docker
  15. echo "Docker installation completed"
  16. }
  17. install_caddy() {
  18. echo "Installing Caddy"
  19. apt install -y debian-keyring debian-archive-keyring apt-transport-https
  20. curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
  21. curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
  22. apt-get update
  23. apt-get install caddy -y
  24. echo "Caddy installation completed."
  25. }
  26. setup_tf_users() {
  27. echo "Setting up TFUsers"
  28. wget https://docs.grid.tf/threefold_public/public/raw/branch/master/add-tf-users.sh
  29. sh add-tf-users.sh
  30. rm add-tf-users.sh
  31. }
  32. configure_ssh() {
  33. echo "Configuring SSH"
  34. ubuntu_version=$(lsb_release -rs 2>/dev/null || . /etc/os-release && echo "$VERSION_ID")
  35. if [ "$ubuntu_version" = "22.04" ]; then
  36. echo "Detected Ubuntu 22.04 — replacing sshd_config and restarting ssh service"
  37. wget -q https://docs.grid.tf/threefold_public/public/raw/branch/master/sshd_config -O /etc/ssh/sshd_config
  38. systemctl restart ssh
  39. elif [ "$ubuntu_version" = "24.04" ]; then
  40. echo "Detected Ubuntu 24.04 — updating ssh.socket for port 34022"
  41. wget -q https://docs.grid.tf/threefold_public/public/raw/branch/master/sshd_config -O /etc/ssh/sshd_config
  42. mkdir -p /etc/systemd/system/ssh.socket.d
  43. cat > /etc/systemd/system/ssh.socket.d/port.conf <<EOF
  44. [Socket]
  45. ListenStream=
  46. ListenStream=34022
  47. EOF
  48. systemctl daemon-reload
  49. systemctl restart ssh.socket
  50. systemctl enable ssh.socket
  51. else
  52. echo "Unsupported Ubuntu version: $ubuntu_version"
  53. exit 1
  54. fi
  55. }
  56. update_system
  57. setup_tf_users
  58. configure_ssh
  59. while getopts ":dc" opt; do
  60. case ${opt} in
  61. d )
  62. install_docker
  63. ;;
  64. c )
  65. install_caddy
  66. ;;
  67. \? )
  68. echo "Invalid option: $OPTARG" 1>&2
  69. ;;
  70. esac
  71. done
  72. shift $((OPTIND -1))
  73. echo "Preping VM Completed."