]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - nixops/scripts/with_env
Fix shebangs in scripts
[perso/Immae/Config/Nix.git] / nixops / scripts / with_env
CommitLineData
2caad890 1#!/usr/bin/env bash
5f5efa6f 2
4506dbe5
IB
3if [ -z "$NIXOPS" ]; then
4 echo "Please set NIXOPS to the nixops command"
5 exit 1;
6fi
7
9f5da6d7
IB
8if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
9 echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path"
5f5efa6f
IB
10 exit 1;
11fi
12
9690acd9 13TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files)
5f5efa6f
IB
14chmod go-rwx $TEMP
15
16finish() {
9690acd9 17 rm -rf "$TEMP"
4506dbe5 18 $NIXOPS set-args --unset privateFiles
5f5efa6f
IB
19}
20
21trap finish EXIT
22
9690acd9
IB
23# pass cannot "just" list files in a directory without showing a tree :(
24files=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files | sed -e '1d' -e 's/^.* //')
25
26for file in $files; do
27 pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files/$file" > $TEMP/$file
28done
4506dbe5 29$NIXOPS set-args --argstr privateFiles "$TEMP"
5f5efa6f 30
4506dbe5 31"$@"