#!/usr/bin/env bash # # Nextcloud with Euro-Office on Proxmox: one VM, Docker Compose and a Cloudflare Tunnel # https://www.zadran.net/guides/nextcloud-euro-office-proxmox-cloudflare-tunnel # Generated from the guide, last updated 2026-10-18. # # NO WARRANTY. This script is provided as is. You are responsible for # understanding what it does before running it, and for the consequences. # Take a backup first. See https://www.zadran.net/disclaimer # # Destructive steps are left commented out on purpose -- uncomment them # only once you have understood what they do. # # Where the guide writes a file with <<'EOF' and your values are in it, # this script uses < /root/${VM_USER}.pub cd /root wget https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2 VMID=${VMID} qm create $VMID --name nextcloud --ostype l26 --machine q35 \ --cpu host --cores 4 --memory 8192 --balloon 0 --agent 1 \ --scsihw virtio-scsi-single --net0 virtio,bridge=${BRIDGE},firewall=1 \ --serial0 socket --vga serial0 --onboot 1 qm set $VMID --scsi0 ${STORAGE}:0,import-from=/root/debian-13-genericcloud-amd64.qcow2,discard=on,iothread=1,ssd=1 qm resize $VMID scsi0 32G qm set $VMID --scsi1 ${STORAGE}:${DATA_DISK_GB},discard=on,iothread=1,ssd=1 qm set $VMID --ide2 ${STORAGE}:cloudinit --boot order=scsi0 qm set $VMID --ciuser ${VM_USER} --ipconfig0 ip=${VM_IP}/24,gw=${GATEWAY} \ --nameserver "${DNS_SERVERS}" --searchdomain ${SEARCH_DOMAIN} qm set $VMID --sshkeys /root/${VM_USER}.pub qm start $VMID sudo apt update && sudo apt -y full-upgrade && sudo apt -y install qemu-guest-agent && sudo systemctl enable --now qemu-guest-agent lsblk sudo mkfs.ext4 -L ncdata /dev/sdb sudo mkdir -p /srv/nextcloud echo 'LABEL=ncdata /srv/nextcloud ext4 defaults,noatime,discard 0 2' | sudo tee -a /etc/fstab sudo systemctl daemon-reload && sudo mount -a df -h /srv/nextcloud sudo apt -y install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt update && sudo apt -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo usermod -aG docker ${VM_USER} exit docker run --rm hello-world | grep "Hello from Docker" docker compose version cd /srv/nextcloud sudo chown ${VM_USER}:${VM_USER} /srv/nextcloud mkdir -p db html data sudo chown 33:33 data && sudo chmod 0770 data cat > .env < hsts.conf cat > compose.yaml <