Allow specifying domains per service

This commit is contained in:
Manuel Thalmann 2024-11-07 03:31:48 +01:00
parent bd9faadec0
commit c50d6ddd2e
3 changed files with 20 additions and 25 deletions

View file

@ -4,10 +4,6 @@ begin
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
function getServiceSubdomain
echo "anki"
end
function installSW -V dir -V source
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l userKey ".services.anki.environment.SYNC_USER1"
@ -26,7 +22,7 @@ begin
end
function getServiceConfigs
printf "%s\0" "anki" "/"
printf "%s\0" anki anki "" /
end
runInstaller --force $argv

View file

@ -17,14 +17,6 @@ begin
getOSConfig fqdn
end
function getServiceDomain
echo "$(getServiceSubdomain $argv).$(getMachineFQDN)"
end
function getServiceSubdomain
getServiceName $argv
end
function getServiceRoot -V root
echo "$root/$(getServiceName $argv)"
end
@ -50,7 +42,7 @@ begin
function installDockerService -V dir -V nginxRoot -V portPattern
set -l services (getServiceConfigs $argv | string split0)
for i in (seq 1 2 (count $services))
for i in (seq 1 4 (count $services))
set -l file (mktemp)
set -l config (getServiceSecretsConfig $argv)
set -l service $services[$i]
@ -68,18 +60,28 @@ begin
function configureDockerService -V portPattern
set -l services (getServiceConfigs $argv | string split0)
for i in (seq 1 2 (count $services))
for i in (seq 1 4 (count $services))
set -l config (getServiceSecretsConfig $argv)
set -l service $services[$i]
set -l location $services[(math $i + 1)]
set -l subdomain $services[(math $i + 1)]
set -l domain $services[(math $i + 2)]
set -l location $services[(math $i + 3)]
set -l portKey (__getServicePortKey "$service")
set -l port (yq --raw-output "$portKey" "$config" | sed "s/$portPattern/\2/")
set -l nginxConfig (__getServiceNginxConfig $argv)
if [ -z "$domain" ]
set domain (getMachineFQDN)
end
if [ -n "$subdomain" ]
set domain "$subdomain.$domain"
end
printf "%s\n" \
"server {" \
"listen 80;" \
"server_name $(getServiceDomain $argv);" \
"server_name $domain;" \
"location $location {" \
"proxy_pass http://127.0.0.1:$port;" \
'proxy_set_header Host $host;' \

View file

@ -1,14 +1,11 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l domain "passwords"
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
function getServiceSubdomain
echo "passwords"
end
function installSW -V dir -V source
function installSW -V dir -V domain -V source
set -l file "$dir/docker-compose.yml"
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l envKey ".services.vaultwarden.environment"
@ -16,7 +13,7 @@ begin
set -l dbUrl (yq --raw-output "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
initializeServiceInstallation $argv
URL="https://$(getServiceDomain $argv)" yq "$envKey.DOMAIN = env.URL" "$file" | \
URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env.URL" "$file" | \
ADDRESS="noreply@$(getMachineFQDN)" yq -y "$envKey.SMTP_FROM = env.ADDRESS" | \
sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null
@ -31,9 +28,9 @@ begin
configureDockerService $argv
end
function getServiceConfigs
function getServiceConfigs -V domain
argparse -i "name=" -- $argv
printf "%s\0" "$_flag_name" "/"
printf "%s\0" "$_flag_name" "$domain" "" /
end
function getBackupArgs -V root