Browse Source

set initial host and port

pull/1736/head
Bernd Storath 3 weeks ago
parent
commit
2f5675e8e9
  1. 11
      src/server/database/sqlite.ts
  2. 4
      src/server/utils/config.ts

11
src/server/database/sqlite.ts

@ -74,10 +74,12 @@ async function initialSetup(db: DBServiceType) {
}
if (WG_INITIAL_ENV.USERNAME && WG_INITIAL_ENV.PASSWORD) {
DB_DEBUG('Creating initial user...');
await db.users.create(WG_INITIAL_ENV.USERNAME, WG_INITIAL_ENV.PASSWORD);
}
if (WG_INITIAL_ENV.IPV4_CIDR && WG_INITIAL_ENV.IPV6_CIDR) {
DB_DEBUG('Setting initial CIDR...');
await db.interfaces.updateCidr({
ipv4Cidr: WG_INITIAL_ENV.IPV4_CIDR,
ipv6Cidr: WG_INITIAL_ENV.IPV6_CIDR,
@ -85,6 +87,7 @@ async function initialSetup(db: DBServiceType) {
}
if (WG_INITIAL_ENV.DNS) {
DB_DEBUG('Setting initial DNS...');
const userConfig = await db.userConfigs.get();
await db.userConfigs.update({
...userConfig,
@ -92,7 +95,13 @@ async function initialSetup(db: DBServiceType) {
});
}
// TODO: set host, port
if (WG_INITIAL_ENV.HOST && WG_INITIAL_ENV.PORT) {
DB_DEBUG('Setting initial host and port...');
await db.userConfigs.updateHostPort(
WG_INITIAL_ENV.HOST,
WG_INITIAL_ENV.PORT
);
}
await db.general.setSetupStep(0);
}

4
src/server/utils/config.ts

@ -26,6 +26,10 @@ export const WG_INITIAL_ENV = {
DNS: process.env.INIT_DNS?.split(',').map((x) => x.trim()),
IPV4_CIDR: process.env.INIT_IPV4_CIDR,
IPV6_CIDR: process.env.INIT_IPV6_CIDR,
HOST: process.env.INIT_HOST,
PORT: process.env.INIT_PORT
? Number.parseInt(process.env.INIT_PORT, 10)
: undefined,
};
function assertEnv<T extends string>(env: T) {

Loading…
Cancel
Save