aboutsummaryrefslogblamecommitdiff
path: root/nixops/scripts/pull_deployment
blob: 08b99159c619ea686ffe64c217dec9508238c627 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                                     



                                                                                      
                                                                       

                                                          
                                                 
 

                                                          
                                                                     





                                                              
                                                   





                   
                                                                          
 
                                         
 
                                                                       
#!/bin/bash

DeploymentUuid="cef694f3-081d-11e9-b31f-0242ec186adf"
if [ -z "$NIXOPS_CONFIG_PASS_SUBTREE_PATH" ]; then
  echo "Please set NIXOPS_CONFIG_PASS_SUBTREE_PATH to the password-store subtree path"
  exit 1;
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"
export NIXOPS_DEPLOYMENT="$DeploymentUuid"
source $(dirname $(dirname $DIR))/scripts/nix_env

export NIXOPS_STATE="$(dirname $DIR)/state/eldiron.nixops"

if nixops_custom info -d $DeploymentUuid 2>/dev/null >/dev/null; then
  cat <<EOF
This will remove your current deployment file and recreate it!
Continue? [y/N]
EOF
  read y
  if [ "$y" = "y" -o "$y" = "Y" ]; then
    nixops_custom delete --force -d $DeploymentUuid
  else
    echo "Aborting"
    exit 1
  fi
fi

deployment=$(pass show $NIXOPS_CONFIG_PASS_SUBTREE_PATH/Nixops/Deployment)

echo "$deployment" | nixops_custom import

nixops_custom modify -d "$DeploymentUuid" "$(dirname $DIR)/default.nix"