Fetch FQDN from configuration
This commit is contained in:
parent
2c3c0b24e1
commit
3d48e5c8b2
4 changed files with 22 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
let inherit (lib) mkOption types;
|
let inherit (lib) mkOption types;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -28,6 +28,12 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fqdn = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The FQDN of the system.";
|
||||||
|
default = config.valhalla.hostname;
|
||||||
|
};
|
||||||
|
|
||||||
hostname = mkOption {
|
hostname = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "The hostname of the system.";
|
description = "The hostname of the system.";
|
||||||
|
|
|
@ -12,8 +12,13 @@ begin
|
||||||
echo "$_flag_name"
|
echo "$_flag_name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getMachineFQDN -V dir
|
||||||
|
source "$dir/../../../../lib/settings.fish"
|
||||||
|
getOSConfig fqdn
|
||||||
|
end
|
||||||
|
|
||||||
function getServiceDomain
|
function getServiceDomain
|
||||||
echo "$(getServiceSubdomain $argv).nuth.ch"
|
echo "$(getServiceSubdomain $argv).$(getMachineFQDN)"
|
||||||
end
|
end
|
||||||
|
|
||||||
function getServiceSubdomain
|
function getServiceSubdomain
|
||||||
|
|
|
@ -9,9 +9,9 @@ services:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
environment:
|
environment:
|
||||||
DOMAIN: https://passwords.nuth.ch
|
DOMAIN: null
|
||||||
SMTP_HOST: bridge
|
SMTP_HOST: bridge
|
||||||
SMTP_FROM: no-reply@nuth.ch
|
SMTP_FROM: null
|
||||||
SMTP_FROM_VALUE: vaultwarden
|
SMTP_FROM_VALUE: vaultwarden
|
||||||
SMTP_PORT: 25
|
SMTP_PORT: 25
|
||||||
SMTP_ACCEPT_INVALID_CERTS: "true"
|
SMTP_ACCEPT_INVALID_CERTS: "true"
|
||||||
|
|
|
@ -9,11 +9,16 @@ begin
|
||||||
end
|
end
|
||||||
|
|
||||||
function installSW -V dir -V source
|
function installSW -V dir -V source
|
||||||
|
set -l file "$dir/docker-compose.yml"
|
||||||
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
|
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
|
||||||
set -l dbKey ".services.vaultwarden.environment.DATABASE_URL"
|
set -l envKey ".services.vaultwarden.environment"
|
||||||
|
set -l dbKey "$envKey.DATABASE_URL"
|
||||||
set -l dbUrl (yq --raw-output "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
|
set -l dbUrl (yq --raw-output "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
|
||||||
initializeServiceInstallation $argv
|
initializeServiceInstallation $argv
|
||||||
sudo cp "$dir/docker-compose.yml" (getServiceRoot $argv)
|
|
||||||
|
URL="https://$(getServiceDomain $argv)" yq "$envKey.DOMAIN = env.URL" "$file" | \
|
||||||
|
ADDRESS="noreply@$(getMachineFQDN)" yq -y "$envKey.SMTP_FROM = env.ADDRESS" | \
|
||||||
|
sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null
|
||||||
|
|
||||||
URL=$dbUrl yq "$dbKey = env.URL" "$source" | \
|
URL=$dbUrl yq "$dbKey = env.URL" "$source" | \
|
||||||
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env.PW" | \
|
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env.PW" | \
|
||||||
|
|
Loading…
Reference in a new issue