deploy.sh 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. set -o nounset -o errexit -o pipefail
  3. # TODO: Do not use grep, only jq instead.
  4. node_not_ready()
  5. {
  6. kubectl get node -o json kube3 2>/dev/null | gron | grep -F 'node.cilium.io/agent-not-ready'
  7. }
  8. start_node()
  9. {
  10. echo "INFO: Waiting Guix host is running." 1>&2
  11. until timeout 2 ssh 192.168.0.192 id
  12. do
  13. sleep 2
  14. done
  15. get_uptime_total_seconds()
  16. {
  17. ssh 192.168.0.192 uptime \
  18. | jc --uptime \
  19. | jq --raw-output .uptime_total_seconds
  20. }
  21. if [[ "$(get_uptime_total_seconds)" -lt 3600 ]]
  22. then
  23. ssh 192.168.0.192 sudo chvt 2
  24. ssh 192.168.0.192 sudo /home/oleg/.local/share/chezmoi/dotfiles/run/pc0/00-run.sh &
  25. /home/oleg/.local/share/chezmoi/run-guix-workstation.sh
  26. fi
  27. }
  28. while :
  29. do
  30. echo "INFO: Waiting Kubernetes node is not available." 1>&2
  31. if node_not_ready
  32. then
  33. start_node
  34. sleep 2
  35. else
  36. sleep 2
  37. fi
  38. done