PortValhalla/scripts/Common/Software/docker/services/vaultwarden/main.fish

46 lines
1.5 KiB
Fish
Raw Normal View History

#!/bin/env fish
begin
set -l dir (status dirname)
2024-11-07 02:31:48 +00:00
set -l domain "passwords"
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
2024-11-07 02:31:48 +00:00
function installSW -V dir -V domain -V source
2024-11-07 02:01:45 +00:00
set -l file "$dir/docker-compose.yml"
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
2024-11-07 02:01:45 +00:00
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
2024-11-07 02:01:45 +00:00
2024-11-07 02:31:48 +00:00
URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env.URL" "$file" | \
2024-11-07 02:01:45 +00:00
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" | \
2024-11-06 18:34:27 +00:00
sudo tee (getServiceSecretsConfig $argv) >/dev/null
installDockerService $argv
end
function configureSW -V dir
configureDockerService $argv
end
function getServiceServers -V domain
printf "%s\0" "$domain" ""
end
function getServiceLocations
argparse -i "name=" -- $argv
printf "%s\0" "$_flag_name" /
end
function getBackupArgs
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv)
end
runInstaller --force $argv
end