Compare commits

...

2 commits

Author SHA1 Message Date
chaos 937a5df23f
run formatter 2024-03-10 18:29:49 +00:00
chaos dd4bc277d1
add basic music library sync check script 2024-03-10 18:27:22 +00:00
6 changed files with 211 additions and 181 deletions

View file

@ -5,7 +5,8 @@
writeShellApplication,
}: let
encryptedUSBData = import ../data/drives/encryptedUSB.nix;
in writeShellApplication {
in
writeShellApplication {
name = "mk-enc-usb";
runtimeInputs = [
parted

View file

@ -6,7 +6,8 @@
writeShellApplication,
}: let
driveData = import ../data/drives/encryptedDrive.nix;
in writeShellApplication {
in
writeShellApplication {
name = "mk-encrypted-drive";
runtimeInputs = [
parted

View file

@ -5,7 +5,8 @@
writeShellApplication,
}: let
externalDriveData = import ../data/drives/raspberryExternalDrive.nix;
in writeShellApplication {
in
writeShellApplication {
name = "mk-raspberry-ext-drive";
runtimeInputs = [
util-linux

View file

@ -21,6 +21,29 @@ in {
'')
];
home.file."Music/music-sync-check.sh" = {
executable = true;
text = ''
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "''${SCRIPT_DIR}"
ERROR_LOG=$(mktemp -t music-check-log-XXX)
echo "Checking StorageBox sync status"
if rclone check . Storage:Music --exclude "/*.sh" 2>$ERROR_LOG; then
echo "Up to date with StorageBox"
else
echo "An error occured attempting to check sync status:"
cat "$ERROR_LOG"
echo
fi
rm "$ERROR_LOG"
'';
};
home.file."Music/music-sync.sh" = {
executable = true;
text = ''
@ -29,7 +52,7 @@ in {
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "''${SCRIPT_DIR}"
rclone sync -P . Storage:Music --exclude music-sync.sh,music-download.sh
rclone sync -P . Storage:Music --exclude "/*.sh"
restic-music backup $(fd -t d --max-depth=1 && fd -t f --max-depth=1)
TITLE="chaos's Music Library"

View file

@ -306,7 +306,8 @@ in rec {
then "secrets-init"
else "secrets-init-${name}";
scripts = genScripts cfg;
in writeShellApplication {
in
writeShellApplication {
name = scriptName;
runtimeInputs = defaultPackages ++ cfg.packages;
text = scripts.initScript;
@ -319,7 +320,8 @@ in rec {
then "secrets-check"
else "secrets-check-${name}";
scripts = genScripts cfg;
in writeShellApplication {
in
writeShellApplication {
name = scriptName;
runtimeInputs = defaultPackages ++ cfg.checkPackages;
text = scripts.checkScript;
@ -344,7 +346,8 @@ in rec {
capabilities = [${concatStringsSep "," (forEach capabilities escapeString)}]
}
'');
in toFile "vault-policy-${name}.hcl" ''
in
toFile "vault-policy-${name}.hcl" ''
${concatStringsSep "\n" policies}
'';
}

View file

@ -202,7 +202,8 @@ in
(mergeAttrsList (forEach machinesWithContainers (machineName: let
machine = machines.${machineName};
inherit (machine) containers;
in mergeAttrsList (forEach containers (containerName: {
in
mergeAttrsList (forEach containers (containerName: {
"secrets-init-${machineName}-container-${containerName}" = secretsInitScriptForContainer machineName containerName;
"vault-policy-${machineName}-container-${containerName}" = vaultPolicyForContainer machineName containerName;
})))))