Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- function header_info {
- clear
- cat <<"EOF"
- ___ __ __ _
- / _ \ _ __ ___ _ __ | \/ | _____ _(_) ___
- | | | | '_ \ / _ \ '_ \| |\/| |/ _ \ \/ / |/ _ \
- | |_| | |_) | __/ | | | | | | (_) > <| | __/
- \___/| .__/ \___|_| |_|_| |_|\___/_/\_\_|\___|
- |_|
- EOF
- }
- header_info
- set -e
- TEMPLATE="debian-12-standard_12.2-1_amd64.tar.zst"
- STORAGE="local-lvm"
- HOST="openmoxie"
- MEMORY=2048
- DISK=8
- # Auto-select next available CTID
- CTID=$(pct list | awk 'NR>1 {print $1}' | sort -n | tail -n1)
- CTID=$((CTID + 1))
- echo "Creating LXC container $CTID..."
- pct create "$CTID" \
- "local:vztmpl/$TEMPLATE" \
- --hostname "$HOST" \
- --storage "$STORAGE" \
- --rootfs ${DISK}G \
- --memory "$MEMORY" \
- --net0 name=eth0,bridge=vmbr0,ip=dhcp \
- --ostype debian \
- --features nesting=1 \
- --unprivileged 0
- echo "Enabling TUN device..."
- CONFIG_FILE="/etc/pve/lxc/${CTID}.conf"
- grep -q "lxc.cgroup2.devices.allow: c 10:200 rwm" "$CONFIG_FILE" || echo "lxc.cgroup2.devices.allow: c 10:200 rwm" >> "$CONFIG_FILE"
- 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"
- pct start "$CTID"
- sleep 5
- header_info
- echo "Installing Docker and OpenMoxie..."
- pct exec "$CTID" -- bash -c '
- set -e
- apt update
- apt install -y ca-certificates curl gnupg git lsb-release
- # Install Docker
- install -m 0755 -d /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- chmod a+r /etc/apt/keyrings/docker.gpg
- 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
- apt update
- apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- # Clone and run OpenMoxie
- cd /opt
- git clone https://github.com/jbeghtol/openmoxie.git
- cd openmoxie
- # Expose port 3000 if not already
- if ! grep -q "3000:3000" docker-compose.yml; then
- sed -i "/ports:/a \ \ \ \ - '3000:3000'" docker-compose.yml
- fi
- docker compose up -d
- # Save credentials (if known)
- echo -e "Access via http://<LXC-IP>:3000\nDefault login (unless changed during setup):\nUsername: [email protected]\nPassword: password123" > /root/openmoxie-login.txt
- '
- pct set "$CTID" -tags "openmoxie"
- # Get IP
- IP=$(pct exec "$CTID" -- hostname -I | awk '{print $1}')
- header_info
- echo -e "\e[1;32m✔ OpenMoxie deployed in LXC $CTID\e[0m"
- echo -e "\e[1;34mWeb Interface:\e[0m http://$IP:3000"
- 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