gpustack-prerun.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/command/with-contenv /bin/bash
  2. # shellcheck disable=SC1008,SC1091
  3. # ================================
  4. # GPUStack migration oneshot service
  5. # ================================
  6. source /etc/profile
  7. SCRIPT_ROOT=/etc/s6-overlay/scripts
  8. source "$SCRIPT_ROOT/base.sh"
  9. ARGS_FILE="/run/gpustack/args"
  10. CUSTOM_CA_DIR="${GPUSTACK_CUSTOM_CA_DIR:-/usr/local/share/ca-certificates}"
  11. # Read arguments from the args file if it exists and is not empty
  12. set --
  13. if [ -s "$ARGS_FILE" ]; then
  14. while IFS= read -r line || [ -n "$line" ]; do
  15. [ -z "$line" ] && continue
  16. set -- "$@" "$line"
  17. done < "$ARGS_FILE"
  18. fi
  19. if command -v update-ca-certificates >/dev/null 2>&1; then
  20. shopt -s nullglob
  21. custom_ca_certs=("${CUSTOM_CA_DIR}"/*.crt)
  22. shopt -u nullglob
  23. if [ ${#custom_ca_certs[@]} -gt 0 ]; then
  24. echo "[INFO] Updating CA certificates from ${CUSTOM_CA_DIR}."
  25. update-ca-certificates
  26. fi
  27. fi
  28. echo "[INFO] Starting gpustack prerun check."
  29. if [ "$#" -gt 0 ]; then
  30. exec gpustack prerun "$@"
  31. else
  32. exec gpustack prerun
  33. fi