diff options
Diffstat (limited to 'nixops/scripts')
-rwxr-xr-x | nixops/scripts/pull_deployment | 33 | ||||
-rwxr-xr-x | nixops/scripts/pull_environment | 13 | ||||
-rwxr-xr-x | nixops/scripts/push_deployment | 13 | ||||
-rwxr-xr-x | nixops/scripts/push_environment | 13 | ||||
-rwxr-xr-x | nixops/scripts/setup | 20 | ||||
-rwxr-xr-x | nixops/scripts/with_env (renamed from nixops/scripts/nixops_wrap) | 16 |
6 files changed, 14 insertions, 94 deletions
diff --git a/nixops/scripts/pull_deployment b/nixops/scripts/pull_deployment deleted file mode 100755 index 08b9915..0000000 --- a/nixops/scripts/pull_deployment +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" | ||
4 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then | ||
5 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" | ||
6 | exit 1; | ||
7 | fi | ||
8 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
9 | export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" | ||
10 | export NIXOPS_DEPLOYMENT="$DeploymentUuid" | ||
11 | source $(dirname $(dirname $DIR))/scripts/nix_env | ||
12 | |||
13 | export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" | ||
14 | |||
15 | if nixops_custom info -d $DeploymentUuid 2>/dev/null >/dev/null; then | ||
16 | cat <<EOF | ||
17 | This will remove your current deployment file and recreate it! | ||
18 | Continue? [y/N] | ||
19 | EOF | ||
20 | read y | ||
21 | if [ "$y" = "y" -o "$y" = "Y" ]; then | ||
22 | nixops_custom delete --force -d $DeploymentUuid | ||
23 | else | ||
24 | echo "Aborting" | ||
25 | exit 1 | ||
26 | fi | ||
27 | fi | ||
28 | |||
29 | deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment) | ||
30 | |||
31 | echo "$deployment" | nixops_custom import | ||
32 | |||
33 | nixops_custom modify -d "$DeploymentUuid" "$(dirname $DIR)/default.nix" | ||
diff --git a/nixops/scripts/pull_environment b/nixops/scripts/pull_environment deleted file mode 100755 index e508a2e..0000000 --- a/nixops/scripts/pull_environment +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then | ||
4 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" | ||
5 | exit 1; | ||
6 | fi | ||
7 | |||
8 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_REMOTE" ]; then | ||
9 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_REMOTE to the password-store subtree remote name" | ||
10 | exit 1; | ||
11 | fi | ||
12 | |||
13 | pass git subtree pull --prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master | ||
diff --git a/nixops/scripts/push_deployment b/nixops/scripts/push_deployment deleted file mode 100755 index f2d25f9..0000000 --- a/nixops/scripts/push_deployment +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" | ||
4 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then | ||
5 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" | ||
6 | exit 1; | ||
7 | fi | ||
8 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
9 | export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" | ||
10 | export NIXOPS_DEPLOYMENT="$DeploymentUuid" | ||
11 | source $(dirname $(dirname $DIR))/scripts/nix_env | ||
12 | |||
13 | nixops_custom export | pass insert -m $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment | ||
diff --git a/nixops/scripts/push_environment b/nixops/scripts/push_environment deleted file mode 100755 index 8b59240..0000000 --- a/nixops/scripts/push_environment +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then | ||
4 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" | ||
5 | exit 1; | ||
6 | fi | ||
7 | |||
8 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_REMOTE" ]; then | ||
9 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_REMOTE to the password-store subtree remote name" | ||
10 | exit 1; | ||
11 | fi | ||
12 | |||
13 | pass git subtree push --prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master | ||
diff --git a/nixops/scripts/setup b/nixops/scripts/setup index 793b7c3..3b364ac 100755 --- a/nixops/scripts/setup +++ b/nixops/scripts/setup | |||
@@ -3,7 +3,7 @@ | |||
3 | set -euo pipefail | 3 | set -euo pipefail |
4 | 4 | ||
5 | RemoteRepo="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Sites" | 5 | RemoteRepo="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Sites" |
6 | DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" | 6 | MAKEFILE_DIR="$( cd "$( dirname $( dirname "${BASH_SOURCE[0]}" ))" >/dev/null 2>&1 && pwd )" |
7 | 7 | ||
8 | if ! which nix 2>/dev/null >/dev/null; then | 8 | if ! which nix 2>/dev/null >/dev/null; then |
9 | cat <<-EOF | 9 | cat <<-EOF |
@@ -52,8 +52,8 @@ if ! pass $NIXOPS_CONFIG_PASS_SUBTREE_PATH > /dev/null 2>/dev/null; then | |||
52 | fi | 52 | fi |
53 | fi | 53 | fi |
54 | 54 | ||
55 | # Repull it before using it, just in case | 55 | # Repull it before adding keys, just in case |
56 | pass git subtree pull --prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master | 56 | make -C $MAKEFILE_DIR pull_environment |
57 | 57 | ||
58 | gpg_keys=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/GPGKeys | sed -e "1d" | cut -d" " -f2) | 58 | gpg_keys=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/GPGKeys | sed -e "1d" | cut -d" " -f2) |
59 | for key in $gpg_keys; do | 59 | for key in $gpg_keys; do |
@@ -97,29 +97,21 @@ if nix show-config --json | jq -e '.sandbox.value == "true"' >/dev/null; then | |||
97 | read y | 97 | read y |
98 | fi | 98 | fi |
99 | 99 | ||
100 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | 100 | if ! make -C $MAKEFILE_DIR deployment_is_set 2>/dev/null >/dev/null; then |
101 | export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" | ||
102 | export NIXOPS_DEPLOYMENT="$DeploymentUuid" | ||
103 | source $(dirname $(dirname $DIR))/scripts/nix_env | ||
104 | |||
105 | if ! nixops_custom info 2>/dev/null >/dev/null; then | ||
106 | cat <<-EOF | 101 | cat <<-EOF |
107 | Importing deployment file into nixops: | 102 | Importing deployment file into nixops: |
108 | Continue? [y/N] | 103 | Continue? [y/N] |
109 | EOF | 104 | EOF |
110 | read y | 105 | read y |
111 | if [ "$y" = "y" -o "$y" = "Y" ]; then | 106 | if [ "$y" = "y" -o "$y" = "Y" ]; then |
112 | deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment) | 107 | make -C $MAKEFILE_DIR pull_deployment |
113 | echo "$deployment" | nixops_custom import | ||
114 | else | 108 | else |
115 | echo "Aborting" | 109 | echo "Aborting" |
116 | exit 1 | 110 | exit 1 |
117 | fi | 111 | fi |
118 | fi | 112 | fi |
119 | 113 | ||
120 | nixops_custom modify "$(dirname $DIR)/default.nix" | ||
121 | |||
122 | cat <<-EOF | 114 | cat <<-EOF |
123 | All set up. | 115 | All set up. |
124 | Please make sure you’re using scripts/nixops_wrap when deploying | 116 | Please make sure you’re using make commands when deploying |
125 | EOF | 117 | EOF |
diff --git a/nixops/scripts/nixops_wrap b/nixops/scripts/with_env index 28aa917..a442ced 100755 --- a/nixops/scripts/nixops_wrap +++ b/nixops/scripts/with_env | |||
@@ -1,21 +1,21 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" | 3 | if [ -z "$NIXOPS" ]; then |
4 | echo "Please set NIXOPS to the nixops command" | ||
5 | exit 1; | ||
6 | fi | ||
7 | |||
4 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then | 8 | if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then |
5 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" | 9 | echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path" |
6 | exit 1; | 10 | exit 1; |
7 | fi | 11 | fi |
8 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
9 | export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops" | ||
10 | export NIXOPS_DEPLOYMENT="$DeploymentUuid" | ||
11 | source $(dirname $(dirname $DIR))/scripts/nix_env | ||
12 | 12 | ||
13 | TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files) | 13 | TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files) |
14 | chmod go-rwx $TEMP | 14 | chmod go-rwx $TEMP |
15 | 15 | ||
16 | finish() { | 16 | finish() { |
17 | rm -rf "$TEMP" | 17 | rm -rf "$TEMP" |
18 | nixops_custom set-args --unset privateFiles | 18 | $NIXOPS set-args --unset privateFiles |
19 | } | 19 | } |
20 | 20 | ||
21 | trap finish EXIT | 21 | trap finish EXIT |
@@ -26,6 +26,6 @@ files=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files | sed -e '1d' -e ' | |||
26 | for file in $files; do | 26 | for file in $files; do |
27 | pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files/$file" > $TEMP/$file | 27 | pass show "$NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files/$file" > $TEMP/$file |
28 | done | 28 | done |
29 | nixops_custom set-args --argstr privateFiles "$TEMP" | 29 | $NIXOPS set-args --argstr privateFiles "$TEMP" |
30 | 30 | ||
31 | nixops_custom "$@" | 31 | "$@" |