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

45 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"
2024-11-27 01:54:44 +00:00
set -l source "$dir/docker-compose.overrides.yml"
source "$dir/../service.fish"
2024-11-07 02:31:48 +00:00
function installSW -V dir -V domain -V source
2024-11-13 15:22:57 +00:00
set -l file "$dir/docker-compose.base.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"
2024-11-19 23:30:08 +00:00
set -l dbUrl (yq "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
initializeServiceInstallation $argv
2024-11-27 02:41:26 +00:00
cp "$dir/docker-compose.base.yml" (getServiceRoot $argv)
2024-11-07 02:01:45 +00:00
2024-11-27 02:41:26 +00:00
URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env(URL)" "$source" | \
ADDRESS="no-reply@$(getMachineFQDN)" yq "$envKey.SMTP_FROM = env(ADDRESS)" | \
URL=$dbUrl yq "$dbKey = env(URL)" | \
2024-11-19 23:30:08 +00:00
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env(PW)" | \
2024-11-27 01:54:44 +00:00
sudo tee (getServiceOverrides $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