aboutsummaryrefslogtreecommitdiff
path: root/upgrade.sh
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-04-20 13:01:51 +0200
committerAlex Auvolat <alex@adnab.me>2022-04-20 13:03:29 +0200
commit9c9c776213478023d4cab6290efcb6adfdbbbe86 (patch)
tree85ae8d2c3dac9c01daf5a1524b8a4ff83b84df70 /upgrade.sh
parent50e9f0b589b6387d193fcb420ddc045c0bc6d632 (diff)
downloadnixcfg-9c9c776213478023d4cab6290efcb6adfdbbbe86.tar.gz
nixcfg-9c9c776213478023d4cab6290efcb6adfdbbbe86.zip
Refactor deployment scripts
Diffstat (limited to 'upgrade.sh')
-rwxr-xr-xupgrade.sh51
1 files changed, 0 insertions, 51 deletions
diff --git a/upgrade.sh b/upgrade.sh
deleted file mode 100755
index cb45924..0000000
--- a/upgrade.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env bash
-
-# Get cluster subdirectory name
-
-cd $(dirname $0)
-
-CLUSTER="$1"
-if [ -z "$CLUSTER" ] || [ ! -d "cluster/$CLUSTER" ]; then
- echo "Usage: $0 <cluster name>"
- echo "The cluster name must be the name of a subdirectory of cluster/"
- exit 1
-fi
-shift 1
-
-# Do actual stuff
-
-if [ -z "$@" ]; then
- NIXHOSTLIST=$(ls cluster/$CLUSTER/node | grep -v '\.site\.')
-else
- NIXHOSTLIST="$@"
-fi
-
-TMP_SCRIPT=/tmp/tmp-upgrade-$(date +%s).sh
-SSH_CONFIG=cluster/$CLUSTER/ssh_config
-
-for NIXHOST in $NIXHOSTLIST; do
- NIXHOST=${NIXHOST%.*}
-
- if [ -z "$SSH_USER" ]; then
- SSH_DEST=$NIXHOST
- else
- SSH_DEST=$SSH_USER@$NIXHOST
- fi
-
- echo "==== DOING $NIXHOST ===="
-
- ssh -F $SSH_CONFIG $SSH_DEST tee $TMP_SCRIPT > /dev/null <<EOF
-set -ex
-
-nix-channel --add https://nixos.org/channels/nixos-21.11 nixos
-nix-channel --update
-nixos-rebuild boot
-EOF
-
- read -p "Press Enter to continue (run upgrade on $NIXHOST)..."
- ssh -t -F $SSH_CONFIG $SSH_DEST sudo sh $TMP_SCRIPT
- ssh -F $SSH_CONFIG $SSH_DEST rm -v $TMP_SCRIPT
-
- read -p "Press Enter to continue (reboot $NIXHOST)..."
- ssh -t -F $SSH_CONFIG $SSH_DEST sudo reboot
-done