44 lines
1.5 KiB
Bash
44 lines
1.5 KiB
Bash
|
set -e
|
||
|
|
||
|
#for f in 172.16.1.{2,3};do ssh -l james $f sudo systemctl stop pgpool ; done
|
||
|
#for f in 172.16.1.{2,3};do ssh -l james $f sudo systemctl stop postgresql ; done
|
||
|
|
||
|
deploy() {
|
||
|
TARGET="$1"
|
||
|
shift
|
||
|
nixos-rebuild --flake ".#$TARGET" --target-host "$TARGET" switch --impure --use-remote-sudo "$@"
|
||
|
}
|
||
|
spread_token() {
|
||
|
#PW=$(
|
||
|
# ssh snorlax sudo cat /var/lib/rancher/k3s/server/node-token /etc/k3s.token | grep . | head -1 | grep . \
|
||
|
# || dd if=/dev/random bs=16 count=1 status=none | xxd -ps
|
||
|
#)
|
||
|
PW=$(
|
||
|
ssh snorlax sudo cat /etc/k3s.token | grep . | head -1 | grep . \
|
||
|
|| dd if=/dev/random bs=16 count=1 status=none | xxd -ps
|
||
|
)
|
||
|
for f in snorlax sobble rowlet;do
|
||
|
ssh $f "sudo bash -c 'touch /etc/k3s.token; chmod 600 /etc/k3s.token; dd of=/etc/k3s.token oflag=sync'" <<<"$PW"
|
||
|
done
|
||
|
}
|
||
|
k3s_reset() {
|
||
|
ssh $1 sudo /nix/store/*k3s*/bin/k3s-killall.sh || true
|
||
|
ssh $1 sudo rm -rf /var/lib/rancher/k3s /etc/rancher/k3s
|
||
|
}
|
||
|
#k3s_reset snorlax
|
||
|
#k3s_reset sobble
|
||
|
#k3s_reset rowlet
|
||
|
#nix run nixpkgs#natscli -- -s 172.16.1.2 kv del kine -f || true
|
||
|
#nix run nixpkgs#natscli -- -s 172.16.1.2 kv del k0-kine -f || true
|
||
|
|
||
|
#spread_token
|
||
|
#deploy snorlax
|
||
|
spread_token
|
||
|
deploy snorlax "$@"
|
||
|
deploy sobble "$@"
|
||
|
deploy rowlet "$@"
|
||
|
|
||
|
#(PW=$(dd if=/dev/random bs=16 count=1 status=none | xxd -ps);for f in 172.16.1.{2,3};do ssh $f "sudo bash -c 'cat > /etc/pool_passwd'" <<<"$PW";done)
|
||
|
#for f in 172.16.1.{2,3};do ssh -l james $f sudo systemctl start postgresql ; done
|
||
|
#for f in 172.16.1.{2,3};do ssh -l james $f sudo systemctl start pgpool ; done
|