aboutsummaryrefslogtreecommitdiff
path: root/nixops/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'nixops/scripts')
-rwxr-xr-xnixops/scripts/pull_deployment33
-rwxr-xr-xnixops/scripts/pull_environment13
-rwxr-xr-xnixops/scripts/push_deployment13
-rwxr-xr-xnixops/scripts/push_environment13
-rwxr-xr-xnixops/scripts/setup20
-rwxr-xr-xnixops/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
3DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf"
4if [ -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;
7fi
8DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
10export NIXOPS_DEPLOYMENT="$DeploymentUuid"
11source $(dirname $(dirname $DIR))/scripts/nix_env
12
13export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
14
15if nixops_custom info -d $DeploymentUuid 2>/dev/null >/dev/null; then
16 cat <<EOF
17This will remove your current deployment file and recreate it!
18Continue? [y/N]
19EOF
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
27fi
28
29deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment)
30
31echo "$deployment" | nixops_custom import
32
33nixops_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
3if [ -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;
6fi
7
8if [ -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;
11fi
12
13pass 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
3DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf"
4if [ -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;
7fi
8DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
10export NIXOPS_DEPLOYMENT="$DeploymentUuid"
11source $(dirname $(dirname $DIR))/scripts/nix_env
12
13nixops_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
3if [ -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;
6fi
7
8if [ -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;
11fi
12
13pass 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 @@
3set -euo pipefail 3set -euo pipefail
4 4
5RemoteRepo="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Sites" 5RemoteRepo="gitolite@git.immae.eu:perso/Immae/Prive/Password_store/Sites"
6DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" 6MAKEFILE_DIR="$( cd "$( dirname $( dirname "${BASH_SOURCE[0]}" ))" >/dev/null 2>&1 && pwd )"
7 7
8if ! which nix 2>/dev/null >/dev/null; then 8if ! 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
53fi 53fi
54 54
55# Repull it before using it, just in case 55# Repull it before adding keys, just in case
56pass git subtree pull --prefix=$NIXOPS_CONFIG_PASS_SUBTREE_PATH $NIXOPS_CONFIG_PASS_SUBTREE_REMOTE master 56make -C $MAKEFILE_DIR pull_environment
57 57
58gpg_keys=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/GPGKeys | sed -e "1d" | cut -d" " -f2) 58gpg_keys=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/GPGKeys | sed -e "1d" | cut -d" " -f2)
59for key in $gpg_keys; do 59for 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
98fi 98fi
99 99
100DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 100if ! make -C $MAKEFILE_DIR deployment_is_set 2>/dev/null >/dev/null; then
101export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
102export NIXOPS_DEPLOYMENT="$DeploymentUuid"
103source $(dirname $(dirname $DIR))/scripts/nix_env
104
105if ! 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
118fi 112fi
119 113
120nixops_custom modify "$(dirname $DIR)/default.nix"
121
122cat <<-EOF 114cat <<-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
3DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf" 3if [ -z "$NIXOPS" ]; then
4 echo "Please set NIXOPS to the nixops command"
5 exit 1;
6fi
7
4if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then 8if [ -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;
7fi 11fi
8DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
10export NIXOPS_DEPLOYMENT="$DeploymentUuid"
11source $(dirname $(dirname $DIR))/scripts/nix_env
12 12
13TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files) 13TEMP=$(mktemp -d /tmp/XXXXXX-nixops-files)
14chmod go-rwx $TEMP 14chmod go-rwx $TEMP
15 15
16finish() { 16finish() {
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
21trap finish EXIT 21trap finish EXIT
@@ -26,6 +26,6 @@ files=$(pass ls $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/files | sed -e '1d' -e '
26for file in $files; do 26for 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
28done 28done
29nixops_custom set-args --argstr privateFiles "$TEMP" 29$NIXOPS set-args --argstr privateFiles "$TEMP"
30 30
31nixops_custom "$@" 31"$@"