Allow specifying domains per service
This commit is contained in:
parent
5e352d0cb7
commit
533d343054
3 changed files with 20 additions and 25 deletions
|
@ -4,10 +4,6 @@ begin
|
||||||
set -l source "$dir/docker-compose.secrets.yml"
|
set -l source "$dir/docker-compose.secrets.yml"
|
||||||
source "$dir/../service.fish"
|
source "$dir/../service.fish"
|
||||||
|
|
||||||
function getServiceSubdomain
|
|
||||||
echo "anki"
|
|
||||||
end
|
|
||||||
|
|
||||||
function installSW -V dir -V source
|
function installSW -V dir -V source
|
||||||
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 userKey ".services.anki.environment.SYNC_USER1"
|
set -l userKey ".services.anki.environment.SYNC_USER1"
|
||||||
|
@ -26,7 +22,7 @@ begin
|
||||||
end
|
end
|
||||||
|
|
||||||
function getServiceConfigs
|
function getServiceConfigs
|
||||||
printf "%s\0" "anki" "/"
|
printf "%s\0" anki anki "" /
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller --force $argv
|
runInstaller --force $argv
|
||||||
|
|
|
@ -17,14 +17,6 @@ begin
|
||||||
getOSConfig fqdn
|
getOSConfig fqdn
|
||||||
end
|
end
|
||||||
|
|
||||||
function getServiceDomain
|
|
||||||
echo "$(getServiceSubdomain $argv).$(getMachineFQDN)"
|
|
||||||
end
|
|
||||||
|
|
||||||
function getServiceSubdomain
|
|
||||||
getServiceName $argv
|
|
||||||
end
|
|
||||||
|
|
||||||
function getServiceRoot -V root
|
function getServiceRoot -V root
|
||||||
echo "$root/$(getServiceName $argv)"
|
echo "$root/$(getServiceName $argv)"
|
||||||
end
|
end
|
||||||
|
@ -50,7 +42,7 @@ begin
|
||||||
function installDockerService -V dir -V nginxRoot -V portPattern
|
function installDockerService -V dir -V nginxRoot -V portPattern
|
||||||
set -l services (getServiceConfigs $argv | string split0)
|
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 file (mktemp)
|
||||||
set -l config (getServiceSecretsConfig $argv)
|
set -l config (getServiceSecretsConfig $argv)
|
||||||
set -l service $services[$i]
|
set -l service $services[$i]
|
||||||
|
@ -68,18 +60,28 @@ begin
|
||||||
function configureDockerService -V portPattern
|
function configureDockerService -V portPattern
|
||||||
set -l services (getServiceConfigs $argv | string split0)
|
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 config (getServiceSecretsConfig $argv)
|
||||||
set -l service $services[$i]
|
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 portKey (__getServicePortKey "$service")
|
||||||
set -l port (yq --raw-output "$portKey" "$config" | sed "s/$portPattern/\2/")
|
set -l port (yq --raw-output "$portKey" "$config" | sed "s/$portPattern/\2/")
|
||||||
set -l nginxConfig (__getServiceNginxConfig $argv)
|
set -l nginxConfig (__getServiceNginxConfig $argv)
|
||||||
|
|
||||||
|
if [ -z "$domain" ]
|
||||||
|
set domain (getMachineFQDN)
|
||||||
|
end
|
||||||
|
|
||||||
|
if [ -n "$subdomain" ]
|
||||||
|
set domain "$subdomain.$domain"
|
||||||
|
end
|
||||||
|
|
||||||
printf "%s\n" \
|
printf "%s\n" \
|
||||||
"server {" \
|
"server {" \
|
||||||
"listen 80;" \
|
"listen 80;" \
|
||||||
"server_name $(getServiceDomain $argv);" \
|
"server_name $domain;" \
|
||||||
"location $location {" \
|
"location $location {" \
|
||||||
"proxy_pass http://127.0.0.1:$port;" \
|
"proxy_pass http://127.0.0.1:$port;" \
|
||||||
'proxy_set_header Host $host;' \
|
'proxy_set_header Host $host;' \
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
|
set -l domain "passwords"
|
||||||
set -l source "$dir/docker-compose.secrets.yml"
|
set -l source "$dir/docker-compose.secrets.yml"
|
||||||
source "$dir/../service.fish"
|
source "$dir/../service.fish"
|
||||||
|
|
||||||
function getServiceSubdomain
|
function installSW -V dir -V domain -V source
|
||||||
echo "passwords"
|
|
||||||
end
|
|
||||||
|
|
||||||
function installSW -V dir -V source
|
|
||||||
set -l file "$dir/docker-compose.yml"
|
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 envKey ".services.vaultwarden.environment"
|
set -l envKey ".services.vaultwarden.environment"
|
||||||
|
@ -16,7 +13,7 @@ begin
|
||||||
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
|
||||||
|
|
||||||
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" | \
|
ADDRESS="noreply@$(getMachineFQDN)" yq -y "$envKey.SMTP_FROM = env.ADDRESS" | \
|
||||||
sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null
|
sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null
|
||||||
|
|
||||||
|
@ -31,9 +28,9 @@ begin
|
||||||
configureDockerService $argv
|
configureDockerService $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function getServiceConfigs
|
function getServiceConfigs -V domain
|
||||||
argparse -i "name=" -- $argv
|
argparse -i "name=" -- $argv
|
||||||
printf "%s\0" "$_flag_name" "/"
|
printf "%s\0" "$_flag_name" "$domain" "" /
|
||||||
end
|
end
|
||||||
|
|
||||||
function getBackupArgs
|
function getBackupArgs
|
||||||
|
|
Loading…
Reference in a new issue