pve_community/README.md
caoimhinr f6dc8e0970 Document the correct one-line installer
Clarify that the OpenCode CT script already sources build.func so the published one-liner works without hitting argument length issues.
2026-04-12 21:05:56 +02:00

98 lines
3.1 KiB
Markdown

# Personal Proxmox LXC Scripts
This repo is a small personal version of the `community-scripts` pattern:
- `ct/` contains host-side Proxmox creation scripts
- `install/` contains the in-container install logic
## OpenCode LXC
`ct/opencode.sh` creates a Debian LXC and installs the `opencode` CLI for a normal user.
It now follows the upstream `community-scripts` host-side flow more closely, including the standard `Default Install`, `Advanced Install`, and `User Defaults` entry points.
### What it does
- picks a Debian 12 template from your configured Proxmox storages
- creates an unprivileged LXC with sensible defaults for a coding box
- installs common CLI tooling (`git`, `ripgrep`, `fd`, `curl`, `build-essential`)
- installs OpenCode via the official installer
- creates a writable `/workspace` directory owned by the `opencode` user
- enables a systemd-managed OpenCode web interface on boot
### Usage
Run on the Proxmox host as `root`:
```bash
bash ct/opencode.sh
```
Community-scripts style one-liner:
```bash
bash -c "$(curl -fsSL https://forgejo.welvaert.org/caoimhinr/pve_community/raw/branch/main/ct/opencode.sh)"
```
The previous two-step `build.func` wrapper is not needed here because `ct/opencode.sh` already downloads and sources `build.func` itself.
Example with overrides:
```bash
CTID=220 \
HOSTNAME=opencode-dev \
BRIDGE=vmbr1 \
CONTAINER_STORAGE=local-lvm \
TEMPLATE_STORAGE=local \
MEMORY=8192 \
CORES=4 \
DISK_GB=24 \
OPENCODE_USER=dev \
OPENCODE_WEB_PORT=4096 \
bash ct/opencode.sh
```
One-liner with overrides:
```bash
CTID=220 MEMORY=8192 CORES=4 DISK_GB=24 OPENCODE_USER=dev bash -c "$(curl -fsSL https://forgejo.welvaert.org/caoimhinr/pve_community/raw/branch/main/ct/opencode.sh)"
```
You can also use the upstream-style `var_*` overrides, for example `var_cpu`, `var_ram`, `var_disk`, `var_brg`, `var_net`, `var_ctid`, and `var_hostname`.
### Common Variables
- `CTID` default `120`
- `HOSTNAME` default `opencode`
- `CORES` default `2`
- `MEMORY` default `4096`
- `DISK_GB` default `12`
- `BRIDGE` default `vmbr0`
- `IP_CONFIG` default `dhcp`
- `TEMPLATE_STORAGE` auto-selects first storage with `vztmpl`
- `CONTAINER_STORAGE` auto-selects first storage with `rootdir`
- `OPENCODE_USER` default `opencode`
- `OPENCODE_VERSION` empty means latest release
- `OPENCODE_WEB_HOSTNAME` default `0.0.0.0`
- `OPENCODE_WEB_PORT` default `4096`
- `OPENCODE_SERVER_USERNAME` default `opencode`
- `OPENCODE_SERVER_PASSWORD` optional basic-auth password for the web UI
- `SSH_PUBLIC_KEY_FILE` optional path to a host public key file to inject into the CT
### Community-Scripts Behavior
- supports the standard `community-scripts` settings flow on the Proxmox host
- supports `default.vars` and app-default handling from the shared `build.func` base
- still accepts the legacy environment variable names documented above for quick one-shot runs
### After Creation
```bash
pct enter 120
su - opencode
opencode
```
The web interface is started automatically at boot and listens on `http://<ct-ip>:4096` by default.
Then configure a provider inside OpenCode with `/connect`, or set your provider credentials manually.