Add GVM (OpenVAS) add-on initialization script

- Create a new script `run.sh` for initializing and launching the GVM add-on.
- Ensure required environment variables `USERNAME` and `PASSWORD` are set.
- Set the timezone if the `TZ` variable is provided.
- Initialize a data directory at `/data` if it does not exist.
- Launch the GVM service and log output to a file.

fix(sonarqube): fix config.json
This commit is contained in:
2025-05-07 11:01:10 +02:00
parent 46aa8e052d
commit cf43143810
11 changed files with 189 additions and 22 deletions

31
gvm/run.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -e
set -o pipefail
log() {
echo "[GVM ADD-ON] $(date +"%Y-%m-%d %H:%M:%S") - $*"
}
# Ensure required env vars are set
: "${USERNAME:?Environment variable USERNAME not set}"
: "${PASSWORD:?Environment variable PASSWORD not set}"
log "Starting GVM (OpenVAS) add-on..."
# Setup timezone
if [ -n "$TZ" ]; then
log "Setting timezone to $TZ"
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo "$TZ" > /etc/timezone
fi
# Initialize data directory
DATA_DIR="/data"
if [ ! -d "$DATA_DIR" ]; then
log "Creating data directory at $DATA_DIR"
mkdir -p "$DATA_DIR"
fi
log "Launching GVM service..."
exec /usr/local/bin/dumb-init gvm-start | tee -a "$DATA_DIR/gvm.log"