Fetch FQDN from configuration
This commit is contained in:
parent
dfedb72f59
commit
3111c04a7f
4 changed files with 22 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
{ lib, ... }:
|
||||
{ config, lib, ... }:
|
||||
let inherit (lib) mkOption types;
|
||||
in {
|
||||
imports = [
|
||||
|
@ -28,6 +28,12 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
fqdn = mkOption {
|
||||
type = types.str;
|
||||
description = "The FQDN of the system.";
|
||||
default = config.valhalla.hostname;
|
||||
};
|
||||
|
||||
hostname = mkOption {
|
||||
type = types.str;
|
||||
description = "The hostname of the system.";
|
||||
|
|
|
@ -12,8 +12,13 @@ begin
|
|||
echo "$_flag_name"
|
||||
end
|
||||
|
||||
function getMachineFQDN -V dir
|
||||
source "$dir/../../../../lib/settings.fish"
|
||||
getOSConfig fqdn
|
||||
end
|
||||
|
||||
function getServiceDomain
|
||||
echo "$(getServiceSubdomain $argv).nuth.ch"
|
||||
echo "$(getServiceSubdomain $argv).$(getMachineFQDN)"
|
||||
end
|
||||
|
||||
function getServiceSubdomain
|
||||
|
|
|
@ -9,9 +9,9 @@ services:
|
|||
- ./data:/data
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
environment:
|
||||
DOMAIN: https://passwords.nuth.ch
|
||||
DOMAIN: null
|
||||
SMTP_HOST: bridge
|
||||
SMTP_FROM: no-reply@nuth.ch
|
||||
SMTP_FROM: null
|
||||
SMTP_FROM_VALUE: vaultwarden
|
||||
SMTP_PORT: 25
|
||||
SMTP_ACCEPT_INVALID_CERTS: "true"
|
||||
|
|
|
@ -9,11 +9,16 @@ begin
|
|||
end
|
||||
|
||||
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 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/")
|
||||
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" | \
|
||||
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env.PW" | \
|
||||
|
|
Loading…
Reference in a new issue