Split upgrade to separate script

This commit is contained in:
Alex 2021-12-04 21:02:42 +01:00
parent 7c4a96bc71
commit 3db6c9a535
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1
2 changed files with 24 additions and 3 deletions

View file

@ -19,9 +19,6 @@ for NIXHOST in $NIXHOSTLIST; do
echo "==== DOING $NIXHOST ====" echo "==== DOING $NIXHOST ===="
echo "updating Nix channels"
ssh -F ssh_config $SSH_DEST sudo nix-channel --update
echo "generating NixOS config" echo "generating NixOS config"
cat configuration.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/configuration.nix > /dev/null cat configuration.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/configuration.nix > /dev/null
cat node/$NIXHOST.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/node.nix > /dev/null cat node/$NIXHOST.nix | ssh -F ssh_config $SSH_DEST sudo tee /etc/nixos/node.nix > /dev/null

24
upgrade.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
cd $(dirname $0)
if [ -z "$@" ]; then
NIXHOSTLIST=$(ls node | grep -v '\.site\.')
else
NIXHOSTLIST="$@"
fi
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 sudo nix-channel --update
ssh -F ssh_config $SSH_DEST sudo nixos-rebuild switch
done