Compare commits

...

2 commits

Author SHA1 Message Date
0cb4bc43f9 store state passwords in map & edn 2024-04-17 11:37:13 +02:00
5b5bc0ab96 install restic_management.clj to image 2024-04-17 11:36:24 +02:00
2 changed files with 22 additions and 3 deletions

View file

@ -27,6 +27,7 @@ function main() {
install -m 0400 /tmp/functions.sh /usr/local/lib/
install -m 0400 /tmp/pg-functions.sh /usr/local/lib/
install -m 0400 /tmp/file-functions.sh /usr/local/lib/
install -m 0740 /tmp/restic_management.clj /usr/local/bin/
cleanupDocker
}

View file

@ -26,8 +26,26 @@
(catch RuntimeException e
(printf "Error parsing edn file '%s': %s\n" "backup-repository-state.edn" (.getMessage e)))))
(println (read-backup-repository-state))
(defn read-secret [s]
(slurp (str "/var/run/secrets/" s)))
;"/var/run/secrets/rotation-credential-secret/rotation-credential"))
(println (:state (read-backup-repository-state)))
;(println (read-backup-repository-state))
(println (s/valid? ::backup-repository-state (read-backup-repository-state)))
;(println (:state (read-backup-repository-state)))
;(println (s/valid? ::backup-repository-state (read-backup-repository-state)))
(println (read-secret "rotation-credential-secret/rotation-credential"))
(println (read-secret "backup-secrets/restic-password"))
(s/def ::new-password string?)
(s/def ::old-password string?)
(s/def ::password-state
(s/keys :req-un [::new-password ::old-password]))
(defn rotate []
(let [state {:new-password (read-secret "rotation-credential-secret/rotation-credential")
:old-password (read-secret "backup-secrets/restic-password")}]
(store-backup-repository-state (prn-str state))))
(rotate)