Advertisement
auiotour

OpenMoxie ProxMox Helper scripv v0.2

May 12th, 2025
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.75 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. function header_info {
  4.   clear
  5.   cat <<"EOF"
  6.   ___                   __  __           _      
  7.  / _ \ _ __   ___ _ __ |  \/  | _____  _(_) ___
  8. | | | | '_ \ / _ \ '_ \| |\/| |/ _ \ \/ / |/ _ \
  9. | |_| | |_) |  __/ | | | |  | | (_) >  <| |  __/
  10.  \___/| .__/ \___|_| |_|_|  |_|\___/_/\_\_|\___|
  11.       |_|                                      
  12. EOF
  13. }
  14. header_info
  15. set -e
  16.  
  17. TEMPLATE="debian-12-standard_12.2-1_amd64.tar.zst"
  18. STORAGE="local-lvm"
  19. HOST="openmoxie"
  20. MEMORY=2048
  21. DISK=8
  22.  
  23. # Auto-select next available CTID
  24. CTID=$(pct list | awk 'NR>1 {print $1}' | sort -n | tail -n1)
  25. CTID=$((CTID + 1))
  26.  
  27. echo "Creating LXC container $CTID..."
  28.  
  29. pct create "$CTID" \
  30.   "local:vztmpl/$TEMPLATE" \
  31.   --hostname "$HOST" \
  32.   --storage "$STORAGE" \
  33.   --rootfs ${DISK}G \
  34.   --memory "$MEMORY" \
  35.   --net0 name=eth0,bridge=vmbr0,ip=dhcp \
  36.   --ostype debian \
  37.   --features nesting=1 \
  38.   --unprivileged 0
  39.  
  40. echo "Enabling TUN device..."
  41. CONFIG_FILE="/etc/pve/lxc/${CTID}.conf"
  42. grep -q "lxc.cgroup2.devices.allow: c 10:200 rwm" "$CONFIG_FILE" || echo "lxc.cgroup2.devices.allow: c 10:200 rwm" >> "$CONFIG_FILE"
  43. grep -q "lxc.mount.entry: /dev/net/tun" "$CONFIG_FILE" || echo "lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file" >> "$CONFIG_FILE"
  44.  
  45. pct start "$CTID"
  46. sleep 5
  47.  
  48. header_info
  49. echo "Installing Docker and OpenMoxie..."
  50.  
  51. pct exec "$CTID" -- bash -c '
  52. set -e
  53. apt update
  54. apt install -y ca-certificates curl gnupg git lsb-release
  55.  
  56. # Install Docker
  57. install -m 0755 -d /etc/apt/keyrings
  58. curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  59. chmod a+r /etc/apt/keyrings/docker.gpg
  60. echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
  61. apt update
  62. apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  63.  
  64. # Clone and run OpenMoxie
  65. cd /opt
  66. git clone https://github.com/jbeghtol/openmoxie.git
  67. cd openmoxie
  68.  
  69. # Expose port 3000 if not already
  70. if ! grep -q "3000:3000" docker-compose.yml; then
  71.  sed -i "/ports:/a \ \ \ \ - '3000:3000'" docker-compose.yml
  72. fi
  73.  
  74. docker compose up -d
  75.  
  76. # Save credentials (if known)
  77. echo -e "Access via http://<LXC-IP>:3000\nDefault login (unless changed during setup):\nUsername: [email protected]\nPassword: password123" > /root/openmoxie-login.txt
  78. '
  79.  
  80. pct set "$CTID" -tags "openmoxie"
  81.  
  82. # Get IP
  83. IP=$(pct exec "$CTID" -- hostname -I | awk '{print $1}')
  84.  
  85. header_info
  86. echo -e "\e[1;32m✔ OpenMoxie deployed in LXC $CTID\e[0m"
  87. echo -e "\e[1;34mWeb Interface:\e[0m http://$IP:3000"
  88. echo -e "\e[1;33mTo view login info:\e[0m pct exec $CTID -- cat /root/openmoxie-login.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement