- 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
32 lines
710 B
Bash
32 lines
710 B
Bash
#!/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"
|