Fix discrepancies: use WG_CLIENT_PORT instead of WG_PORT for setup fallback

- Fixed setup/2.post.ts to use WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT instead of WG_INTERFACE_OVERRIDE_ENV.PORT
- Fixed sqlite.ts initialSetup to use WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT for consistency
- Corrected unattended-setup.md documentation:
  - Changed INIT_HOST and INIT_PORT from group "1*" to group "2"
  - Clarified INIT_PORT description as "Port clients will connect to (endpoint port)"
  - Updated group numbers: DNS is group 3, CIDR is group 4, Allowed IPs is group 5
  - Fixed warning text: setup requires groups 1 and 2, and use WG_CLIENT_PORT (not WG_PORT)
- Ensures consistency between code behavior and documentation

Co-authored-by: kaaax0815 <32197462+kaaax0815@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-17 10:31:11 +00:00
parent 3a52e1321b
commit e192855280
3 changed files with 14 additions and 14 deletions
@@ -6,23 +6,23 @@ If you want to run the setup without any user interaction, e.g. with a tool like
These will only be used during the first start of the container. After that, the setup will be disabled. These will only be used during the first start of the container. After that, the setup will be disabled.
| Env | Example | Description | Group | | Env | Example | Description | Group |
| ------------------ | ---------------------------- | --------------------------------------------------------- | ----- | | ------------------ | ---------------------------- | -------------------------------------------------- | ----- |
| `INIT_ENABLED` | `true` | Enables the below env vars | 0 | | `INIT_ENABLED` | `true` | Enables the below env vars | 0 |
| `INIT_USERNAME` | `admin` | Sets admin username | 1 | | `INIT_USERNAME` | `admin` | Sets admin username | 1 |
| `INIT_PASSWORD` | `Se!ureP%ssw` | Sets admin password | 1 | | `INIT_PASSWORD` | `Se!ureP%ssw` | Sets admin password | 1 |
| `INIT_HOST` | `vpn.example.com` | Host clients will connect to | 1\* | | `INIT_HOST` | `vpn.example.com` | Host clients will connect to | 2 |
| `INIT_PORT` | `51820` | Port clients will connect to and WireGuard will listen on | 1\* | | `INIT_PORT` | `51820` | Port clients will connect to (endpoint port) | 2 |
| `INIT_DNS` | `1.1.1.1,8.8.8.8` | Sets global dns setting | 2 | | `INIT_DNS` | `1.1.1.1,8.8.8.8` | Sets global dns setting | 3 |
| `INIT_IPV4_CIDR` | `10.8.0.0/24` | Sets IPv4 cidr | 3 | | `INIT_IPV4_CIDR` | `10.8.0.0/24` | Sets IPv4 cidr | 4 |
| `INIT_IPV6_CIDR` | `2001:0DB8::/32` | Sets IPv6 cidr | 3 | | `INIT_IPV6_CIDR` | `2001:0DB8::/32` | Sets IPv6 cidr | 4 |
| `INIT_ALLOWED_IPS` | `10.8.0.0/24,2001:0DB8::/32` | Sets global Allowed IPs | 4 | | `INIT_ALLOWED_IPS` | `10.8.0.0/24,2001:0DB8::/32` | Sets global Allowed IPs | 5 |
/// warning | Variables have to be used together /// warning | Variables have to be used together
If variables are in the same group, you have to set all of them. For example, if you set `INIT_IPV4_CIDR`, you also have to set `INIT_IPV6_CIDR`. If variables are in the same group, you have to set all of them. For example, if you set `INIT_IPV4_CIDR`, you also have to set `INIT_IPV6_CIDR`.
To skip the setup process, you must configure group `1`. You can alternatively use `WG_HOST` and `WG_PORT` to set the host and port without using the `INIT_` variables. To skip the setup process, you must configure groups `1` and `2`. You can alternatively use `WG_HOST` and `WG_CLIENT_PORT` to set the host and port without using the `INIT_` variables.
Avoid setting both `INIT_` and `WG_` variables for the same setting to prevent confusion. Avoid setting both `INIT_` and `WG_` variables for the same setting to prevent confusion.
/// ///
+1 -1
View File
@@ -10,7 +10,7 @@ export default defineSetupEventHandler(2, async ({ event }) => {
// If host and port are already set by environment variables, skip step 4 // If host and port are already set by environment variables, skip step 4
const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST; const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST;
const port = WG_INITIAL_ENV.PORT ?? WG_INTERFACE_OVERRIDE_ENV.PORT; const port = WG_INITIAL_ENV.PORT ?? WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT;
const setupDone = host && port; const setupDone = host && port;
+1 -1
View File
@@ -110,7 +110,7 @@ async function initialSetup(db: DBServiceType) {
// Use INIT vars or fall back to override vars for HOST and PORT // Use INIT vars or fall back to override vars for HOST and PORT
const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST; const host = WG_INITIAL_ENV.HOST ?? WG_CLIENT_OVERRIDE_ENV.HOST;
const port = WG_INITIAL_ENV.PORT ?? WG_INTERFACE_OVERRIDE_ENV.PORT; const port = WG_INITIAL_ENV.PORT ?? WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT;
// HOST and PORT can come from either INIT vars or override vars // HOST and PORT can come from either INIT vars or override vars
if (host && port) { if (host && port) {