run-guix-workstation.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -o nounset -o errexit -o pipefail
  3. ssh 192.168.0.192 <<'EOF'
  4. PATH="/home/oleg/.guix-profile/bin:/gnu/store/3q2x34wg1fff833wwzxnagnv7vbfxb0w-jc-1.25.2/bin:$PATH"
  5. export PATH
  6. guix_workstation_id()
  7. {
  8. sudo nerdctl -n k8s.io ps --format=json \
  9. | jq --exit-status --raw-output '. | select (.Image | startswith("harbor.home.wugi.info/library/guix-image-workstation")) | .ID'
  10. }
  11. echo "INFO: Waiting Guix workstation container is running." 1>&2
  12. until guix_workstation_id
  13. do
  14. sleep 2
  15. done
  16. echo "INFO: Waiting service in Guix workstation are running for 10 seconds." 1>&2
  17. sleep 10
  18. sudo /root/run.py
  19. sleep 1
  20. sudo /root/run.py
  21. echo "INFO: Waiting Guix workstation container to start for 10 seconds." 1>&2
  22. sleep 10
  23. bar()
  24. {
  25. if sudo /home/oleg/bin/nerdctl-guix-exec /bin/sh -lc 'export SWAYSOCK="$(echo /run/user/1000/sway-ipc*sock)"; /home/oleg/.guix-home/profile/bin/swaymsg -t get_outputs'
  26. then
  27. sudo herd restart container-guix-sway-autostart
  28. exit 0
  29. fi
  30. }
  31. until bar
  32. do
  33. sleep 2
  34. done
  35. EOF