diff --git a/scripts/install.sh b/scripts/install.sh index e23c441..a29e6fb 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,6 +10,8 @@ # sudo ./scripts/install.sh --port 9090 # install with custom port # ./scripts/install.sh -h # show usage +# sudo ./scripts/install.sh --nvml # build with NVML GPU support +# sudo ./scripts/install.sh --nvml --port 9090 set -euo pipefail HERE="$(cd "$(dirname "$0")/.." && pwd)" @@ -28,6 +30,7 @@ CONFIG_EXAMPLE="${HERE}/config.example.yaml" MONITOR_USER="root" DO_START=1 PORT="" +NVML_BUILD=0 # --------------------------------------------------------------------------- # Colors @@ -53,6 +56,7 @@ Build and install workstation-probe (monitor) as a system service. Requires root privileges. Options: + --nvml Build with NVML GPU collector (requires libnvidia-ml). -h Show this help and exit. --port N Set the server listen port (default: 19090 from config.example.yaml). --no-start Install the binary, config, and service, but do not start the service. @@ -78,6 +82,7 @@ fi while [ $# -gt 0 ]; do case "$1" in -h) usage ;; + --nvml) NVML_BUILD=1 ;; --port) shift if [ $# -eq 0 ]; then @@ -117,10 +122,15 @@ fi # --------------------------------------------------------------------------- # Build -# --------------------------------------------------------------------------- -info "Building binary..." -if ! make build; then - fatal "Build failed. Check the Go toolchain and try again." +if [ "$NVML_BUILD" -eq 1 ]; then + info "Building with NVML GPU support..." + if ! make build-nvml; then + fatal "Build failed. Check the Go toolchain, libnvidia-ml, and try again." + fi +else + if ! make build; then + fatal "Build failed. Check the Go toolchain and try again." + fi fi info "Build succeeded." diff --git a/scripts/rootless-install.sh b/scripts/rootless-install.sh index 9992b27..dd642e6 100755 --- a/scripts/rootless-install.sh +++ b/scripts/rootless-install.sh @@ -10,6 +10,8 @@ # ./scripts/rootless-install.sh --no-start # install without starting # ./scripts/rootless-install.sh --port 9090 # install with custom port # ./scripts/rootless-install.sh -h # show usage +# ./scripts/rootless-install.sh --nvml # build with NVML GPU support +# ./scripts/rootless-install.sh --nvml --port 9090 set -euo pipefail @@ -28,6 +30,7 @@ SERVICE_FILE="${SYSTEMD_USER_DIR}/${BIN_NAME}.service" CONFIG_EXAMPLE="${HERE}/config.example.yaml" DO_START=1 PORT="" +NVML_BUILD=0 # --------------------------------------------------------------------------- # Colors @@ -53,6 +56,7 @@ Build and install workstation-probe (monitor) as a user service (rootless). No root privileges required. Options: + --nvml Build with NVML GPU collector (requires libnvidia-ml). -h Show this help and exit. --port N Set the server listen port (default: 19090 from config.example.yaml). --no-start Install the binary, config, and service, but do not start the service. @@ -71,6 +75,7 @@ EOF while [ $# -gt 0 ]; do case "$1" in -h) usage ;; + --nvml) NVML_BUILD=1 ;; --port) shift if [ $# -eq 0 ]; then @@ -112,11 +117,18 @@ fi # --------------------------------------------------------------------------- # Build # --------------------------------------------------------------------------- -info "Building binary..." -if ! make build; then - fatal "Build failed. Check the Go toolchain and try again." +if [ "$NVML_BUILD" -eq 1 ]; then + info "Building with NVML GPU support..." + if ! make build-nvml; then + fatal "Build failed. Check the Go toolchain, libnvidia-ml, and try again." + fi +else + if ! make build; then + fatal "Build failed. Check the Go toolchain and try again." + fi fi info "Build succeeded." +info "Build succeeded." # --------------------------------------------------------------------------- # Install binary