mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git
synced 2024-11-21 19:41:26 +00:00
feat(bitwarden): Add admin token support
This commit is contained in:
parent
7e590ae60c
commit
5e64b08381
16
files.nix
16
files.nix
|
@ -14,6 +14,7 @@ in
|
||||||
"d /var/lib/restic 0600 restic - - -"
|
"d /var/lib/restic 0600 restic - - -"
|
||||||
(if cfg.pleroma.enable then "f /var/lib/pleroma/secrets.exs 0755 pleroma pleroma - -" else "")
|
(if cfg.pleroma.enable then "f /var/lib/pleroma/secrets.exs 0755 pleroma pleroma - -" else "")
|
||||||
"f+ /var/domain 0444 selfprivacy-api selfprivacy-api - ${domain}"
|
"f+ /var/domain 0444 selfprivacy-api selfprivacy-api - ${domain}"
|
||||||
|
(if cfg.bitwarden.enable then "f /var/lib/bitwarden/.env 0640 vaultwarden vaultwarden - -" else "")
|
||||||
];
|
];
|
||||||
system.activationScripts =
|
system.activationScripts =
|
||||||
let
|
let
|
||||||
|
@ -79,5 +80,20 @@ in
|
||||||
'' else ''
|
'' else ''
|
||||||
rm -f /var/lib/pleroma/secrets.exs
|
rm -f /var/lib/pleroma/secrets.exs
|
||||||
'';
|
'';
|
||||||
|
bitwardenCredentials =
|
||||||
|
if cfg.bitwarden.enable then ''
|
||||||
|
mkdir -p /var/lib/bitwarden
|
||||||
|
token=$(cat /etc/nixos/userdata/userdata.json | ${jq} -r '.bitwarden.adminToken')
|
||||||
|
if [ "$token" == "null" ]; then
|
||||||
|
# If it's null, delete the contents of the file
|
||||||
|
> /var/lib/bitwarden/.env
|
||||||
|
else
|
||||||
|
echo "ADMIN_TOKEN=$token" > /var/lib/bitwarden/.env
|
||||||
|
fi
|
||||||
|
chmod 0640 /var/lib/bitwarden/.env
|
||||||
|
chown vaultwarden:vaultwarden /var/lib/bitwarden/.env
|
||||||
|
'' else ''
|
||||||
|
rm -f /var/lib/bitwarden/.env
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue