Guest User

Untitled

a guest
Jun 27th, 2026
153
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # OpenVAS installation script for Debian 13+ and Kali systems, following Greenbone Community Edition guidelines.
  4. # Version: v1.1.0
  5. # Purpose: Installs and configures OpenVAS from source following Greenbone Community Edition guidelines.
  6. # Repository: https://github.com/Kastervo/OpenVAS-Installation
  7. #
  8. # Copyright 2025 KASTERVO LTD
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS,
  18. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. #
  22. # Company: KASTERVO LTD
  23. # Address: Efesou 9, Paralimni, 5280, Famagusta, Cyprus
  24. # Contact: https://kastervo.com/contact
  25. #
  26. # Modified by: Eero Volotinen
  27. # Changes: Dropped Debian 12 support (no longer supported); added support for Kali Linux,
  28. # Debian 13+, and other minor fixes.
  29. #
  30. # Original source code is at location: https://github.com/Kastervo/OpenVAS-Installation
  31. #
  32.  
  33.  
  34. # Run all apt/dpkg operations non-interactively so the script never blocks on prompts.
  35. export DEBIAN_FRONTEND=noninteractive
  36. export APT_LISTCHANGES_FRONTEND=none
  37. export NEEDRESTART_MODE=a
  38. export NEEDRESTART_SUSPEND=1
  39.  
  40. # -----------------------------------
  41. # Section: Environment Setup
  42. # -----------------------------------
  43.  
  44. # Sets up environment variables for the installation process.
  45. # Creates consistent paths for source, build, and install directories.
  46. set_environment() {
  47. log INFO "Starting environment variable setup..."
  48. export INSTALL_PREFIX=/usr/local
  49. export PATH=$PATH:$INSTALL_PREFIX/sbin
  50. export SOURCE_DIR=$HOME/source
  51. export BUILD_DIR=$HOME/build
  52. export INSTALL_DIR=$HOME/install
  53. export GNUPGHOME=/tmp/openvas-gnupg
  54. export OPENVAS_GNUPG_HOME=/etc/openvas/gnupg
  55.  
  56. # Check disk space for directories
  57. for dir in "$SOURCE_DIR" "$BUILD_DIR" "$INSTALL_DIR"; do
  58. if ! mkdir -p "$dir" 2>/dev/null; then
  59. log ERROR "Failed to create directory $dir. Check permissions or disk space."
  60. exit 1
  61. fi
  62. local free_space
  63. free_space=$(df -k "$dir" | tail -1 | awk '{print $4}')
  64. if [ "$free_space" -lt 1048576 ]; then # Less than 1GB
  65. log WARN "Low disk space in $dir: $((free_space/1024)) MB available. Recommend at least 1GB."
  66. fi
  67. done
  68. log INFO "Environment variable set: INSTALL_PREFIX=$INSTALL_PREFIX"
  69. log INFO "Environment variable set: PATH=$PATH"
  70. log INFO "Environment variable set: SOURCE_DIR=$SOURCE_DIR"
  71. log INFO "Environment variable set: BUILD_DIR=$BUILD_DIR"
  72. log INFO "Environment variable set: INSTALL_DIR=$INSTALL_DIR"
  73. log INFO "Environment variable set: GNUPGHOME=$GNUPGHOME"
  74. log INFO "Environment variable set: OPENVAS_GNUPG_HOME=$OPENVAS_GNUPG_HOME"
  75. }
  76.  
  77. # -----------------------------------
  78. # Section: Version Management
  79. # -----------------------------------
  80.  
  81. # Fetches the latest version of OpenVAS components from GitHub.
  82. # Exports version numbers as environment variables for use in installation.
  83. check_latest_version() {
  84. log INFO "Starting version check for OpenVAS components..."
  85.  
  86. # Check network connectivity to GitHub API
  87. if ! curl --proto '=https' --tlsv1.2 -s -I "https://api.github.com" >/dev/null 2>&1; then
  88. log ERROR "No network connectivity to api.github.com. Check network settings."
  89. exit 1
  90. fi
  91.  
  92. declare -A component_vars=(
  93. ["gvm-libs"]="GVM_LIBS_VERSION"
  94. ["gvmd"]="GVMD_VERSION"
  95. ["pg-gvm"]="PG_GVM_VERSION"
  96. ["gsa"]="GSA_VERSION"
  97. ["gsad"]="GSAD_VERSION"
  98. ["openvas-smb"]="OPENVAS_SMB_VERSION"
  99. ["openvas-scanner"]="OPENVAS_SCANNER_VERSION"
  100. ["ospd-openvas"]="OSPD_OPENVAS_VERSION"
  101. )
  102.  
  103. for component in "${!component_vars[@]}"; do
  104. log INFO "Fetching latest version for $component..."
  105. local comp_ver
  106. comp_ver=$(curl --proto '=https' --tlsv1.2 -s "https://api.github.com/repos/greenbone/$component/releases/latest" | grep tag_name | cut -d '"' -f 4 | sed 's/v//')
  107.  
  108. if [ -z "$comp_ver" ]; then
  109. log ERROR "Failed to fetch version for $component. Check network or GitHub API."
  110. exit 1
  111. fi
  112.  
  113. local var_name="${component_vars[$component]}"
  114. export "$var_name=$comp_ver"
  115. log INFO "Set $var_name=$comp_ver"
  116.  
  117. if [ "$component" = "openvas-scanner" ]; then
  118. export OPENVAS_DAEMON="$comp_ver"
  119. log INFO "Set OPENVAS_DAEMON=$comp_ver"
  120. fi
  121. done
  122. log INFO "Completed version check for all components."
  123. }
  124.  
  125. # -----------------------------------
  126. # Section: Logging and Error Handling
  127. # -----------------------------------
  128.  
  129. # Structured logging with levels (INFO, WARN, ERROR) to a log file with colors.
  130. # Usage: log <LEVEL> <MESSAGE>
  131. LOG_FILE=/var/log/openvas_install.log
  132. log() {
  133. local level=$1
  134. shift
  135. local message="$*"
  136. local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
  137.  
  138. # ANSI color codes
  139. local COLOR_INFO="\033[1;36m" # Cyan for INFO
  140. local COLOR_WARN="\033[1;33m" # Yellow for WARN
  141. local COLOR_ERROR="\033[1;31m" # Red for ERROR
  142. local COLOR_RESET="\033[0m" # Reset color
  143.  
  144. # Select color based on log level
  145. case "$level" in
  146. INFO)
  147. color=$COLOR_INFO
  148. ;;
  149. WARN)
  150. color=$COLOR_WARN
  151. ;;
  152. ERROR)
  153. color=$COLOR_ERROR
  154. ;;
  155. *)
  156. color=$COLOR_RESET
  157. ;;
  158. esac
  159.  
  160. # Output to console with color and log to file without color
  161. echo -e "${color}${timestamp} [$level] $message${COLOR_RESET}" | tee -a "$LOG_FILE"
  162. }
  163.  
  164. # Executes a command with error handling and logging.
  165. # Logs command execution and exits on failure with status code.
  166. run_command() {
  167. log INFO "Executing command: $*"
  168. "$@"
  169. local status=$?
  170. if [ $status -ne 0 ]; then
  171. log ERROR "Command '$*' failed with status $status."
  172. exit $status
  173. fi
  174. log INFO "Command '$*' completed successfully."
  175. }
  176.  
  177. # -----------------------------------
  178. # Section: System Checks
  179. # -----------------------------------
  180.  
  181. # Ensures the script is run as root to meet permission requirements.
  182. check_root() {
  183. log INFO "Checking for root privileges..."
  184. if [ "$EUID" -ne 0 ]; then
  185. log ERROR "This script must be run as root."
  186. exit 1
  187. fi
  188. log INFO "Root privilege check passed."
  189. }
  190.  
  191. # Detects the running Debian release and exports DEBIAN_VERSION_ID (e.g. 12, 13).
  192. # Supported: Debian 12 (bookworm), Debian 13 (trixie). Other releases trigger a warning.
  193. detect_debian_version() {
  194. log INFO "Detecting Debian release..."
  195. if [ ! -r /etc/os-release ]; then
  196. log ERROR "/etc/os-release not found. Cannot detect distribution."
  197. exit 1
  198. fi
  199. # shellcheck disable=SC1091
  200. . /etc/os-release
  201. if [ "$ID" != "debian" ]; then
  202. log WARN "Detected distribution '$ID'. This script is validated for Debian 12 and 13 only."
  203. fi
  204. export DEBIAN_VERSION_ID="${VERSION_ID:-unknown}"
  205. export DEBIAN_CODENAME="${VERSION_CODENAME:-unknown}"
  206. case "$DEBIAN_VERSION_ID" in
  207. 12)
  208. echo "not supported os anymore"
  209. exit 1
  210. ;;
  211. 13)
  212. export PEP668_ENFORCED=1
  213. export HAS_LIBPAHO_MQTT=0
  214. log INFO "Detected Debian 13 ($DEBIAN_CODENAME)."
  215. ;;
  216. *)
  217. export PEP668_ENFORCED=1
  218. export HAS_LIBPAHO_MQTT=1
  219. log WARN "Untested Debian version '$DEBIAN_VERSION_ID'. Proceeding with best-effort defaults."
  220. ;;
  221. esac
  222. }
  223.  
  224. # Runs python3 -m pip install with --break-system-packages where required (PEP 668).
  225. # Usage: pip_install_root <target_root> <pip args...>
  226. pip_install_root() {
  227. local target_root=$1
  228. shift
  229. local extra_flags=()
  230. if [ "${PEP668_ENFORCED:-0}" -eq 1 ]; then
  231. extra_flags+=(--break-system-packages)
  232. fi
  233. run_command python3 -m pip install --root="$target_root" --no-warn-script-location "${extra_flags[@]}" "$@"
  234. }
  235.  
  236. # -----------------------------------
  237. # Section: User and Group Management
  238. # -----------------------------------
  239.  
  240. # Creates a dedicated 'gvm' user and group for running OpenVAS services.
  241. create_gvm_user() {
  242. log INFO "Setting up GVM user and group..."
  243. if getent passwd gvm > /dev/null 2>&1; then
  244. log WARN "GVM user already exists, skipping creation. Verify user settings."
  245. else
  246. run_command useradd -r -M -U -G sudo -s /usr/sbin/nologin gvm
  247. if ! run_command usermod -aG gvm "$USER"; then
  248. log WARN "Failed to add $USER to gvm group. Manual addition may be required."
  249. else
  250. log INFO "Created GVM user and group, added $USER to gvm group."
  251. fi
  252. fi
  253. }
  254.  
  255. # -----------------------------------
  256. # Section: Dependency Installation
  257. # -----------------------------------
  258.  
  259. # Installs common build tools and dependencies required for all components.
  260. install_common_dep() {
  261. log INFO "Installing common build dependencies..."
  262. if ! run_command apt install -y --no-install-recommends --assume-yes \
  263. build-essential curl cmake pkg-config python3 python3-pip gnupg; then
  264. log ERROR "Failed to install common dependencies. Check apt configuration."
  265. exit 1
  266. fi
  267. if ! command -v cmake >/dev/null 2>&1; then
  268. log ERROR "cmake not found after installation. Dependency installation incomplete."
  269. exit 1
  270. fi
  271. log INFO "Common dependencies installed."
  272. }
  273.  
  274. # Installs dependencies for gvm-libs component.
  275. install_gvm_libs_dep() {
  276. log INFO "Installing gvm-libs dependencies..."
  277. # Required dependencies for gvm-libs
  278. if ! run_command apt install -y \
  279. libcjson-dev libcurl4-gnutls-dev libgcrypt-dev libglib2.0-dev libgnutls28-dev libgpgme-dev libhiredis-dev libnet1-dev libpcap-dev libssh-dev libxml2-dev uuid-dev ; then
  280. log ERROR "Failed to install required dependencies for gvm-libs. Check apt configuration."
  281. exit 1
  282. fi
  283. # libpaho-mqtt-dev was dropped from Debian 13 (trixie). It enables optional MQTT publishing in gvm-libs.
  284. if [ "${HAS_LIBPAHO_MQTT:-1}" -eq 1 ]; then
  285. if ! run_command apt install -y libpaho-mqtt-dev; then
  286. log WARN "libpaho-mqtt-dev not installed. MQTT support in gvm-libs will be disabled."
  287. fi
  288. else
  289. log WARN "Skipping libpaho-mqtt-dev (not available on Debian ${DEBIAN_VERSION_ID:-?}). MQTT support in gvm-libs will be disabled."
  290. fi
  291. # Optional dependencies for gvm-libs
  292. if ! run_command apt install -y \
  293. libldap2-dev libradcli-dev ; then
  294. log WARN "Optional gvm-libs dependencies (libldap2-dev, libradcli-dev) not installed. Some features may be limited."
  295. fi
  296. log INFO "gvm-libs dependencies installed."
  297. }
  298.  
  299. # Installs dependencies for gvmd component.
  300. install_gvmd_dep() {
  301. log INFO "Installing gvmd dependencies..."
  302. # Required dependencies for gvmd
  303. if ! run_command apt install -y \
  304. libbsd-dev libcjson-dev libglib2.0-dev libgnutls28-dev libgpgme-dev libical-dev libpq-dev postgresql-server-dev-all rsync xsltproc; then
  305. log ERROR "Failed to install required dependencies for gvmd. Check apt configuration."
  306. exit 1
  307. fi
  308. # Optional dependencies for gvmd
  309. if ! run_command apt install -y --no-install-recommends \
  310. dpkg fakeroot gnupg gnutls-bin gpgsm nsis openssh-client python3 python3-lxml rpm smbclient snmp socat sshpass texlive-fonts-recommended texlive-latex-extra wget xmlstarlet zip; then
  311. log WARN "Optional gvmd dependencies not installed. Some features may be limited."
  312. fi
  313. log INFO "gvmd dependencies installed."
  314. }
  315.  
  316. # Installs dependencies for pg-gvm component.
  317. install_pg_gvm_dep() {
  318. log INFO "Installing pg-gvm dependencies..."
  319. # Required dependencies for pg-gvm
  320. if ! run_command apt install -y \
  321. libglib2.0-dev libical-dev postgresql-server-dev-all; then
  322. log ERROR "Failed to install required dependencies for pg-gvm. Check apt configuration."
  323. exit 1
  324. fi
  325. log INFO "pg-gvm dependencies installed."
  326. }
  327.  
  328. # Installs dependencies for gsad component.
  329. install_gsad_dep() {
  330. log INFO "Installing gsad dependencies..."
  331. # Required dependencies for gsad
  332. if ! run_command apt install -y \
  333. libbrotli-dev libglib2.0-dev libgnutls28-dev libmicrohttpd-dev libxml2-dev; then
  334. log ERROR "Failed to install required dependencies for gsad. Check apt configuration."
  335. exit 1
  336. fi
  337. log INFO "gsad dependencies installed."
  338. }
  339.  
  340. # Installs dependencies for openvas-smb component.
  341. install_openvas_smb_dep() {
  342. log INFO "Installing openvas-smb dependencies..."
  343. # Required dependencies for openvas-smb
  344. if ! run_command apt install -y \
  345. gcc-mingw-w64 libgnutls28-dev libglib2.0-dev libpopt-dev libunistring-dev heimdal-multidev perl-base; then
  346. log ERROR "Failed to install required dependencies for openvas-smb. Check apt configuration."
  347. exit 1
  348. fi
  349. log INFO "openvas-smb dependencies installed."
  350. }
  351.  
  352. # Installs dependencies for openvas-scanner component.
  353. install_openvas_scanner_dep() {
  354. log INFO "Installing openvas-scanner dependencies..."
  355. # Required dependencies for openvas-scanner
  356. # libmagic-dev is required as of newer openvas-scanner releases (misc/CMakeLists.txt).
  357. if ! run_command apt install -y \
  358. bison libglib2.0-dev libgnutls28-dev libgcrypt20-dev libpcap-dev libgpgme-dev libksba-dev libmagic-dev rsync nmap libjson-glib-dev libcurl4-gnutls-dev libbsd-dev krb5-multidev; then
  359. log ERROR "Failed to install required dependencies for openvas-scanner. Check apt configuration."
  360. exit 1
  361. fi
  362. # Optional dependencies for openvas-scanner
  363. if ! run_command apt install -y \
  364. python3-impacket libsnmp-dev; then
  365. log WARN "Optional openvas-scanner dependencies (python3-impacket, libsnmp-dev) not installed. Some features may be limited."
  366. fi
  367. log INFO "openvas-scanner dependencies installed."
  368. }
  369.  
  370. # Installs dependencies for ospd-openvas component.
  371. install_ospd_openvas_dep() {
  372. log INFO "Installing ospd-openvas dependencies..."
  373. # Required dependencies for ospd-openvas
  374. if ! run_command apt install -y \
  375. python3 python3-pip python3-setuptools python3-packaging python3-wrapt python3-cffi python3-psutil python3-lxml python3-defusedxml python3-paramiko python3-redis python3-gnupg python3-paho-mqtt; then
  376. log ERROR "Failed to install required dependencies for ospd-openvas. Check apt configuration."
  377. exit 1
  378. fi
  379. log INFO "ospd-openvas dependencies installed."
  380. }
  381.  
  382. # Verifies that a working container engine (podman or docker) is available.
  383. # The nasl-c-lib Makefile probes for podman/docker via 'sh -lc command -v ...'
  384. # and aborts the build with "neither docker nor podman was detected" if neither
  385. # is on PATH. On distributions where 'podman' installs but is not usable
  386. # (observed on some Kali Linux setups), this falls back to installing docker.io.
  387. # Exports CONTAINER_ENGINE for use by later build steps.
  388. ensure_container_engine() {
  389. log INFO "Verifying container engine for nasl-c-lib archive build..."
  390. local engine=""
  391. if command -v podman >/dev/null 2>&1 && podman --version >/dev/null 2>&1; then
  392. engine="podman"
  393. elif command -v docker >/dev/null 2>&1 && docker --version >/dev/null 2>&1; then
  394. engine="docker"
  395. fi
  396.  
  397. if [ -z "$engine" ]; then
  398. log WARN "No working container engine found after apt install. Attempting docker.io fallback."
  399. if ! run_command apt install -y --no-install-recommends docker.io; then
  400. log ERROR "Failed to install docker.io fallback. A container engine (podman or docker) is required to build openvasd."
  401. exit 1
  402. fi
  403. if command -v docker >/dev/null 2>&1 && docker --version >/dev/null 2>&1; then
  404. engine="docker"
  405. fi
  406. fi
  407.  
  408. if [ -z "$engine" ]; then
  409. log ERROR "Neither podman nor docker is usable. Install one manually and re-run."
  410. exit 1
  411. fi
  412.  
  413. # The Makefile uses 'sh -lc' which reads /etc/profile; confirm the engine is
  414. # reachable from that shell too, otherwise the build will still fail.
  415. if ! sh -lc "command -v $engine" >/dev/null 2>&1; then
  416. log WARN "$engine not visible in login shell PATH. The nasl-c-lib Makefile may not detect it."
  417. fi
  418.  
  419. export CONTAINER_ENGINE="$engine"
  420. log INFO "Container engine ready: $engine ($(command -v $engine))"
  421. }
  422.  
  423. # Installs dependencies for openvasd component.
  424. install_openvasd_dep() {
  425. log INFO "Installing openvasd dependencies..."
  426. # Required dependencies for openvasd. A container engine (podman or docker) + make
  427. # are required to build the static archive bundle that newer openvas-scanner releases
  428. # consume via rust/crates/nasl-c-lib/build-cache/archives (see rust/doc/build.md).
  429. # capnproto + clang are required by sequoia-ipc / sequoia-openpgp build scripts
  430. # pulled in transitively by openvasd.
  431. if ! run_command apt install -y \
  432. pkg-config libssl-dev make podman uidmap capnproto clang libclang-dev nettle-dev; then
  433. log ERROR "Failed to install required dependencies for openvasd. Check apt configuration."
  434. exit 1
  435. fi
  436. # A working container engine is mandatory for the nasl-c-lib archive build.
  437. # On some distributions (notably Kali Linux) the 'podman' package may install
  438. # without a usable binary; in that case fall back to docker.io.
  439. ensure_container_engine
  440.  
  441. # Install Rust and Cargo for openvasd
  442. log INFO "Installing Rust and Cargo for openvasd..."
  443. # Check if rustc is already installed
  444. if command -v rustc >/dev/null 2>&1 && command -v cargo >/dev/null 2>&1; then
  445. log INFO "Rust and Cargo are already installed. Verifying versions..."
  446. local rustc_version
  447. rustc_version=$(rustc --version)
  448. local cargo_version
  449. cargo_version=$(cargo --version)
  450. log INFO "Found $rustc_version and $cargo_version"
  451. else
  452. # Download and install rustup
  453. if ! curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh; then
  454. log ERROR "Failed to download rustup installer. Check network."
  455. exit 1
  456. fi
  457. # Install rustup non-interactively
  458. if ! sh /tmp/rustup-init.sh -y --no-modify-path; then
  459. log ERROR "Failed to install Rust and Cargo. Check installation script."
  460. exit 1
  461. fi
  462. # Clean up installer
  463. rm -f /tmp/rustup-init.sh
  464. log INFO "Rust and Cargo installed successfully."
  465. fi
  466.  
  467. # Source Cargo environment
  468. if [ -f "$HOME/.cargo/env" ]; then
  469. # shellcheck disable=SC1091
  470. . "$HOME/.cargo/env"
  471. else
  472. log ERROR "Cargo environment file not found at $HOME/.cargo/env."
  473. exit 1
  474. fi
  475.  
  476. # Verify Rust and Cargo installation
  477. if ! command -v rustc >/dev/null 2>&1 || ! command -v cargo >/dev/null 2>&1; then
  478. log ERROR "Rust or Cargo not found after installation. Check PATH or installation."
  479. exit 1
  480. fi
  481. log INFO "Rust and Cargo verified: $(rustc --version), $(cargo --version)"
  482. log INFO "openvasd dependencies installed."
  483. }
  484.  
  485. # Installs dependencies for gvm-tools component.
  486. install_gvm_tools_dep() {
  487. log INFO "Installing gvm-tools dependencies..."
  488. # Required dependencies for gvm-tools
  489. if ! run_command apt install -y \
  490. python3 python3-lxml python3-packaging python3-paramiko python3-pip python3-setuptools python3-venv; then
  491. log ERROR "Failed to install required dependencies for gvm-tools. Check apt configuration."
  492. exit 1
  493. fi
  494. log INFO "gvm-tools dependencies installed."
  495. }
  496.  
  497. # Installs all required dependencies for OpenVAS components.
  498. install_packages() {
  499. log INFO "Starting installation of all dependencies..."
  500. if ! run_command apt update -y; then
  501. log ERROR "apt update failed. Check network connectivity and apt sources."
  502. exit 1
  503. fi
  504. for dep_func in install_common_dep install_gvm_libs_dep install_gvmd_dep install_pg_gvm_dep install_gsad_dep install_openvas_smb_dep install_openvas_scanner_dep install_ospd_openvas_dep install_openvasd_dep install_gvm_tools_dep; do
  505. if ! $dep_func; then
  506. log ERROR "Failed to install dependencies in $dep_func."
  507. exit 1
  508. fi
  509. done
  510. log INFO "All dependencies installed successfully."
  511. }
  512.  
  513. # -----------------------------------
  514. # Section: Directory and Key Setup
  515. # -----------------------------------
  516.  
  517. # Creates directories for source, build, and installation.
  518. create_directories() {
  519. log INFO "Creating directories for source, build, and installation..."
  520. for dir in "$SOURCE_DIR" "$BUILD_DIR" "$INSTALL_DIR"; do
  521. if ! mkdir -p "$dir" 2>/dev/null; then
  522. log ERROR "Failed to create directory $dir. Check permissions or disk space."
  523. exit 1
  524. fi
  525. if [ ! -w "$dir" ]; then
  526. log ERROR "Directory $dir is not writable. Check permissions."
  527. exit 1
  528. fi
  529. done
  530. log INFO "Directories created: $SOURCE_DIR, $BUILD_DIR, $INSTALL_DIR"
  531. }
  532.  
  533. # Imports Greenbone's GPG signing key for package verification.
  534. import_signing_key() {
  535. log INFO "Importing Greenbone Community Signing Key..."
  536. if ! run_command mkdir -p "$GNUPGHOME"; then
  537. log ERROR "Failed to create GPG home directory $GNUPGHOME."
  538. exit 1
  539. fi
  540. if ! run_command curl -f -L https://www.greenbone.net/GBCommunitySigningKey.asc -o /tmp/GBCommunitySigningKey.asc; then
  541. log ERROR "Failed to download Greenbone signing key. Check network or URL."
  542. exit 1
  543. fi
  544. if ! run_command gpg --homedir "$GNUPGHOME" --import /tmp/GBCommunitySigningKey.asc; then
  545. log ERROR "Failed to import Greenbone signing key. Check GPG configuration."
  546. exit 1
  547. fi
  548. if ! gpg --homedir "$GNUPGHOME" --list-keys | grep -q "Greenbone"; then
  549. log WARN "Greenbone key imported but not found in keyring. Verification may fail."
  550. fi
  551. log INFO "Greenbone signing key imported."
  552. }
  553.  
  554. # Generates a self-signed SSL certificate for gsad if not already present.
  555. generate_ssl_cert() {
  556. log INFO "Checking for gsad SSL certificate..."
  557. if [ -f /etc/gvm/gsad.crt ] && [ -f /etc/gvm/gsad.key ]; then
  558. log INFO "SSL certificate and key already exist, skipping generation."
  559. if [ "$(stat -c %U:%G /etc/gvm/gsad.crt)" != "gvm:gvm" ]; then
  560. log WARN "SSL certificate ownership is not gvm:gvm. Fixing permissions."
  561. run_command chown gvm:gvm /etc/gvm/gsad.crt /etc/gvm/gsad.key
  562. fi
  563. else
  564. log INFO "Generating self-signed SSL certificate for gsad..."
  565. if ! run_command mkdir -p /etc/gvm; then
  566. log ERROR "Failed to create /etc/gvm directory."
  567. exit 1
  568. fi
  569. if ! run_command openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  570. -keyout /etc/gvm/gsad.key -out /etc/gvm/gsad.crt \
  571. -subj "/C=US/ST=State/L=City/O=Organization/OU=IT/CN=$(hostname)"; then
  572. log ERROR "Failed to generate SSL certificate for gsad."
  573. exit 1
  574. fi
  575. if ! run_command chown gvm:gvm /etc/gvm/gsad.crt /etc/gvm/gsad.key; then
  576. log ERROR "Failed to set ownership for SSL certificate."
  577. exit 1
  578. fi
  579. if ! run_command chmod 640 /etc/gvm/gsad.crt || ! run_command chmod 600 /etc/gvm/gsad.key; then
  580. log ERROR "Failed to set permissions for SSL certificate."
  581. exit 1
  582. fi
  583. log WARN "Generated self-signed certificate. Replace with a trusted certificate for production use."
  584. fi
  585. }
  586.  
  587. # -----------------------------------
  588. # Section: Component Installation
  589. # -----------------------------------
  590.  
  591. # Builds and installs Eclipse paho.mqtt.c from source.
  592. # Required on Debian 13 (trixie) where libpaho-mqtt-dev was removed from the archive.
  593. # gvm-libs hard-requires paho-mqtt3c (util/CMakeLists.txt emits SEND_ERROR otherwise),
  594. # so MQTT cannot simply be disabled.
  595. build_install_paho_mqtt_from_source() {
  596. local paho_version="1.3.13"
  597. log INFO "Building Eclipse paho.mqtt.c $paho_version from source (libpaho-mqtt-dev unavailable on this release)..."
  598.  
  599. # Pre-existing system library check: skip the source build if a usable libpaho-mqtt3c is already installed.
  600. if ldconfig -p 2>/dev/null | grep -q 'libpaho-mqtt3c\.so'; then
  601. log INFO "libpaho-mqtt3c is already present on the system; skipping source build."
  602. return 0
  603. fi
  604.  
  605. if ! run_command apt install -y --no-install-recommends libssl-dev ca-certificates; then
  606. log ERROR "Failed to install build dependencies for paho.mqtt.c."
  607. exit 1
  608. fi
  609.  
  610. local paho_tar="$SOURCE_DIR/paho.mqtt.c-$paho_version.tar.gz"
  611. local paho_src="$SOURCE_DIR/paho.mqtt.c-$paho_version"
  612. rm -rf "$paho_src"
  613.  
  614. if ! run_command curl -f -L "https://github.com/eclipse/paho.mqtt.c/archive/refs/tags/v${paho_version}.tar.gz" -o "$paho_tar"; then
  615. log ERROR "Failed to download paho.mqtt.c source."
  616. exit 1
  617. fi
  618. if ! run_command tar -C "$SOURCE_DIR" -xzf "$paho_tar"; then
  619. log ERROR "Failed to extract paho.mqtt.c source."
  620. exit 1
  621. fi
  622. if ! run_command mkdir -p "$BUILD_DIR/paho.mqtt.c"; then
  623. log ERROR "Failed to create build directory for paho.mqtt.c."
  624. exit 1
  625. fi
  626. if ! run_command cmake \
  627. -S "$paho_src" \
  628. -B "$BUILD_DIR/paho.mqtt.c" \
  629. -DCMAKE_INSTALL_PREFIX=/usr \
  630. -DCMAKE_BUILD_TYPE=Release \
  631. -DPAHO_WITH_SSL=TRUE \
  632. -DPAHO_BUILD_STATIC=FALSE \
  633. -DPAHO_BUILD_SHARED=TRUE \
  634. -DPAHO_BUILD_DOCUMENTATION=FALSE \
  635. -DPAHO_BUILD_SAMPLES=FALSE \
  636. -DPAHO_ENABLE_TESTING=FALSE; then
  637. log ERROR "CMake configuration failed for paho.mqtt.c."
  638. exit 1
  639. fi
  640. if ! run_command cmake --build "$BUILD_DIR/paho.mqtt.c" -j"$(nproc)"; then
  641. log ERROR "Build failed for paho.mqtt.c."
  642. exit 1
  643. fi
  644. if ! run_command cmake --install "$BUILD_DIR/paho.mqtt.c"; then
  645. log ERROR "Install failed for paho.mqtt.c."
  646. exit 1
  647. fi
  648. if ! run_command ldconfig; then
  649. log WARN "ldconfig failed; paho-mqtt3c may not be discoverable."
  650. fi
  651.  
  652. if ! ldconfig -p 2>/dev/null | grep -q 'libpaho-mqtt3c\.so'; then
  653. log ERROR "libpaho-mqtt3c.so not visible to the dynamic linker after install."
  654. exit 1
  655. fi
  656. log INFO "Eclipse paho.mqtt.c $paho_version installed."
  657. }
  658.  
  659. # Builds and installs a generic OpenVAS component from source.
  660. build_install_component() {
  661. local comp_name=$1
  662. local comp_ver=$2
  663. local comp_args=$3
  664.  
  665. log INFO "Starting build and installation of $comp_name-$comp_ver..."
  666.  
  667. # Set the source URL
  668. local comp_src="https://github.com/greenbone/$comp_name/archive/refs/tags/v$comp_ver.tar.gz"
  669.  
  670. # Set the signature URL
  671. if [ "$comp_name" = "openvas-smb" ] || [ "$comp_name" = "openvas-scanner" ]; then
  672. local comp_sig="https://github.com/greenbone/$comp_name/releases/download/v$comp_ver/$comp_name-v$comp_ver.tar.gz.asc"
  673. else
  674. local comp_sig="https://github.com/greenbone/$comp_name/releases/download/v$comp_ver/$comp_name-$comp_ver.tar.gz.asc"
  675. fi
  676.  
  677. # Download Sources
  678. if ! run_command curl -f -L "$comp_src" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  679. log ERROR "Failed to download source for $comp_name-$comp_ver from $comp_src"
  680. exit 1
  681. fi
  682. if ! run_command curl -f -L "$comp_sig" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc"; then
  683. log ERROR "Failed to download signature for $comp_name-$comp_ver from $comp_sig"
  684. exit 1
  685. fi
  686.  
  687. # Verify GPG signature
  688. if ! gpg --homedir "$GNUPGHOME" --verify "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc" "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  689. log ERROR "GPG signature verification failed for $comp_name-$comp_ver"
  690. exit 1
  691. fi
  692.  
  693. # Extract Sources
  694. if ! run_command tar -C "$SOURCE_DIR" -xvzf "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  695. log ERROR "Failed to extract source for $comp_name-$comp_ver"
  696. exit 1
  697. fi
  698.  
  699. # Building
  700. if ! run_command mkdir -p "$BUILD_DIR/$comp_name"; then
  701. log ERROR "Failed to create build directory $BUILD_DIR/$comp_name"
  702. exit 1
  703. fi
  704. if ! run_command cmake $comp_args; then
  705. log ERROR "CMake configuration failed for $comp_name-$comp_ver with args: $comp_args"
  706. exit 1
  707. fi
  708. if ! run_command cmake --build "$BUILD_DIR/$comp_name" -j$(nproc); then
  709. log ERROR "Build failed for $comp_name-$comp_ver"
  710. exit 1
  711. fi
  712.  
  713. # Installing
  714. if ! run_command mkdir -p "$INSTALL_DIR/$comp_name"; then
  715. log ERROR "Failed to create install directory $INSTALL_DIR/$comp_name"
  716. exit 1
  717. fi
  718. if ! run_command cd "$BUILD_DIR/$comp_name"; then
  719. log ERROR "Failed to change to build directory $BUILD_DIR/$comp_name"
  720. exit 1
  721. fi
  722. if ! run_command make DESTDIR="$INSTALL_DIR/$comp_name" install; then
  723. log ERROR "Installation failed for $comp_name-$comp_ver"
  724. exit 1
  725. fi
  726. if ! run_command cp -rv "$INSTALL_DIR/$comp_name"/* /; then
  727. log ERROR "Failed to copy installed files for $comp_name-$comp_ver to system directories"
  728. exit 1
  729. fi
  730.  
  731. log INFO "Successfully built and installed $comp_name-$comp_ver"
  732. }
  733.  
  734. # Installs the GSA (Greenbone Security Assistant) web interface.
  735. build_install_gsa() {
  736. local comp_name=$1
  737. local comp_ver=$2
  738.  
  739. log INFO "Starting installation of $comp_name-$comp_ver..."
  740.  
  741. local comp_src="https://github.com/greenbone/gsa/releases/download/v$comp_ver/gsa-dist-$comp_ver.tar.gz"
  742. local comp_sig="https://github.com/greenbone/gsa/releases/download/v$comp_ver/gsa-dist-$comp_ver.tar.gz.asc"
  743.  
  744. # Download and verify
  745. log INFO "Downloading $comp_name-$comp_ver source and signature..."
  746. if ! run_command curl -f -L "$comp_src" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  747. log ERROR "Failed to download $comp_name-$comp_ver source."
  748. exit 1
  749. fi
  750. if ! run_command curl -f -L "$comp_sig" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc"; then
  751. log ERROR "Failed to download $comp_name-$comp_ver signature."
  752. exit 1
  753. fi
  754.  
  755. log INFO "Verifying GPG signature for $comp_name-$comp_ver..."
  756. if ! gpg --homedir "$GNUPGHOME" --verify "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc" "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  757. log ERROR "GPG signature verification failed for $comp_name-$comp_ver."
  758. exit 1
  759. fi
  760.  
  761. # Extract and install
  762. log INFO "Extracting and installing $comp_name-$comp_ver..."
  763. if ! run_command mkdir -p "$SOURCE_DIR/$comp_name-$comp_ver"; then
  764. log ERROR "Failed to create source directory for $comp_name-$comp_ver."
  765. exit 1
  766. fi
  767. if ! run_command tar -C "$SOURCE_DIR/$comp_name-$comp_ver" -xvzf "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  768. log ERROR "Failed to extract $comp_name-$comp_ver."
  769. exit 1
  770. fi
  771. if ! run_command mkdir -p "$INSTALL_PREFIX/share/gvm/gsad/web/"; then
  772. log ERROR "Failed to create web directory for $comp_name-$comp_ver."
  773. exit 1
  774. fi
  775. if ! run_command cp -rv "$SOURCE_DIR/$comp_name-$comp_ver"/* "$INSTALL_PREFIX/share/gvm/gsad/web/"; then
  776. log ERROR "Failed to install $comp_name-$comp_ver web files."
  777. exit 1
  778. fi
  779. log INFO "Completed installation of $comp_name-$comp_ver."
  780. }
  781.  
  782. # Installs ospd-openvas using Python pip.
  783. build_install_opsd() {
  784. local comp_name=$1
  785. local comp_ver=$2
  786.  
  787. log INFO "Starting installation of $comp_name-$comp_ver..."
  788.  
  789. local comp_src="https://github.com/greenbone/ospd-openvas/archive/refs/tags/v$comp_ver.tar.gz"
  790. local comp_sig="https://github.com/greenbone/ospd-openvas/releases/download/v$comp_ver/ospd-openvas-v$comp_ver.tar.gz.asc"
  791.  
  792. # Download and verify
  793. log INFO "Downloading $comp_name-$comp_ver source and signature..."
  794. if ! run_command curl -f -L "$comp_src" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  795. log ERROR "Failed to download $comp_name-$comp_ver source."
  796. exit 1
  797. fi
  798. if ! run_command curl -f -L "$comp_sig" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc"; then
  799. log ERROR "Failed to download $comp_name-$comp_ver signature."
  800. exit 1
  801. fi
  802.  
  803. log INFO "Verifying GPG signature for $comp_name-$comp_ver..."
  804. if ! gpg --homedir "$GNUPGHOME" --verify "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc" "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  805. log ERROR "GPG signature verification failed for $comp_name-$comp_ver."
  806. exit 1
  807. fi
  808.  
  809. # Extract and install
  810. log INFO "Extracting and installing $comp_name-$comp_ver..."
  811. if ! run_command tar -C "$SOURCE_DIR" -xvzf "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  812. log ERROR "Failed to extract $comp_name-$comp_ver."
  813. exit 1
  814. fi
  815. if ! run_command cd "$SOURCE_DIR/$comp_name-$comp_ver"; then
  816. log ERROR "Failed to change to $comp_name-$comp_ver directory."
  817. exit 1
  818. fi
  819. if ! run_command mkdir -p "$INSTALL_DIR/$comp_name"; then
  820. log ERROR "Failed to create install directory for $comp_name."
  821. exit 1
  822. fi
  823. if ! pip_install_root "$INSTALL_DIR/$comp_name" .; then
  824. log ERROR "Failed to install $comp_name-$comp_ver via pip."
  825. exit 1
  826. fi
  827. if ! run_command cp -rv "$INSTALL_DIR/$comp_name"/* /; then
  828. log ERROR "Failed to copy $comp_name-$comp_ver to system directories."
  829. exit 1
  830. fi
  831. log INFO "Completed installation of $comp_name-$comp_ver."
  832. }
  833.  
  834. # Installs openvasd and scannerctl using Rust.
  835. build_install_openvasd() {
  836. local comp_name=$1
  837. local comp_sub=$2
  838. local comp_ver=$3
  839.  
  840. log INFO "Starting installation of $comp_sub-$comp_ver..."
  841.  
  842. local comp_src="https://github.com/greenbone/openvas-scanner/archive/refs/tags/v$comp_ver.tar.gz"
  843. local comp_sig="https://github.com/greenbone/openvas-scanner/releases/download/v$comp_ver/openvas-scanner-v$comp_ver.tar.gz.asc"
  844.  
  845. # Download and verify
  846. log INFO "Downloading $comp_name-$comp_ver source and signature..."
  847. if ! run_command curl -f -L "$comp_src" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  848. log ERROR "Failed to download $comp_name-$comp_ver source."
  849. exit 1
  850. fi
  851. if ! run_command curl -f -L "$comp_sig" -o "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc"; then
  852. log ERROR "Failed to download $comp_name-$comp_ver signature."
  853. exit 1
  854. fi
  855.  
  856. log INFO "Verifying GPG signature for $comp_name-$comp_ver..."
  857. if ! gpg --homedir "$GNUPGHOME" --verify "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz.asc" "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  858. log ERROR "GPG signature verification failed for $comp_name-$comp_ver."
  859. exit 1
  860. fi
  861.  
  862. # Extract and build
  863. log INFO "Extracting and building $comp_sub-$comp_ver..."
  864. if ! run_command tar -C "$SOURCE_DIR" -xvzf "$SOURCE_DIR/$comp_name-$comp_ver.tar.gz"; then
  865. log ERROR "Failed to extract $comp_name-$comp_ver."
  866. exit 1
  867. fi
  868. if ! run_command mkdir -p "$INSTALL_DIR/$comp_sub/usr/local/bin"; then
  869. log ERROR "Failed to create install directory for $comp_sub."
  870. exit 1
  871. fi
  872. # Newer openvas-scanner releases require the static archive bundle
  873. # (libgcrypt, libgpg-error, libpcap, libkrb5 .a files plus headers) under
  874. # rust/crates/nasl-c-lib/build-cache/archives. The bundled `make` target in
  875. # rust/ builds these archives via a container image (podman or docker).
  876. if ! run_command cd "$SOURCE_DIR/$comp_name-$comp_ver/rust"; then
  877. log ERROR "Failed to change to rust directory."
  878. exit 1
  879. fi
  880. if ! command -v podman >/dev/null 2>&1 && ! command -v docker >/dev/null 2>&1; then
  881. log ERROR "Neither podman nor docker is available. Required to build the openvasd static archive bundle."
  882. exit 1
  883. fi
  884. # Re-verify a working engine right before invoking make, since the nasl-c-lib
  885. # Makefile probes via 'sh -lc command -v ...' and fails with
  886. # "neither docker nor podman was detected" if neither is usable.
  887. ensure_container_engine
  888. if ! run_command make; then
  889. log ERROR "Failed to prepare openvasd static archive bundle via 'make' in $SOURCE_DIR/$comp_name-$comp_ver/rust."
  890. exit 1
  891. fi
  892. if ! run_command cd "$SOURCE_DIR/$comp_name-$comp_ver/rust/src/$comp_sub"; then
  893. log ERROR "Failed to change to $comp_sub directory."
  894. exit 1
  895. fi
  896. if ! run_command cargo build --release; then
  897. log ERROR "Failed to build $comp_sub."
  898. exit 1
  899. fi
  900. if ! run_command cd "$SOURCE_DIR/$comp_name-$comp_ver/rust/src/scannerctl"; then
  901. log ERROR "Failed to change to scannerctl directory."
  902. exit 1
  903. fi
  904. if ! run_command cargo build --release; then
  905. log ERROR "Failed to build scannerctl."
  906. exit 1
  907. fi
  908.  
  909. # Install
  910. log INFO "Installing $comp_sub and scannerctl..."
  911. if ! run_command cp -v "../../target/release/$comp_sub" "$INSTALL_DIR/$comp_sub/usr/local/bin/"; then
  912. log ERROR "Failed to copy $comp_sub binary."
  913. exit 1
  914. fi
  915. if ! run_command cp -v "../../target/release/scannerctl" "$INSTALL_DIR/$comp_sub/usr/local/bin/"; then
  916. log ERROR "Failed to copy scannerctl binary."
  917. exit 1
  918. fi
  919. if ! run_command cp -rv "$INSTALL_DIR/$comp_sub"/* /; then
  920. log ERROR "Failed to copy $comp_sub binaries to system directories."
  921. exit 1
  922. fi
  923. log INFO "Completed installation of $comp_sub-$comp_ver."
  924. }
  925.  
  926. # Installs a Python-based component using pip.
  927. build_install_py() {
  928. local comp_name=$1
  929.  
  930. log INFO "Starting installation of $comp_name..."
  931.  
  932. log INFO "Installing $comp_name via pip..."
  933. if ! run_command mkdir -p "$INSTALL_DIR/$comp_name"; then
  934. log ERROR "Failed to create install directory for $comp_name."
  935. exit 1
  936. fi
  937. if ! pip_install_root "$INSTALL_DIR/$comp_name" "$comp_name"; then
  938. log ERROR "Failed to install $comp_name via pip."
  939. exit 1
  940. fi
  941. if ! run_command cp -rv "$INSTALL_DIR/$comp_name"/* /; then
  942. log ERROR "Failed to copy $comp_name to system directories."
  943. exit 1
  944. fi
  945. log INFO "Completed installation of $comp_name."
  946. }
  947.  
  948. # -----------------------------------
  949. # Section: System Configuration
  950. # -----------------------------------
  951.  
  952. # Configures Redis for OpenVAS and sets up service.
  953. perform_system_setup() {
  954. log INFO "Starting system setup for Redis..."
  955. if ! run_command apt install -y redis-server; then
  956. log ERROR "Failed to install redis-server."
  957. exit 1
  958. fi
  959. if [ ! -f "$SOURCE_DIR/openvas-scanner-$OPENVAS_SCANNER_VERSION/config/redis-openvas.conf" ]; then
  960. log ERROR "Redis configuration file not found in source directory."
  961. exit 1
  962. fi
  963. if ! run_command cp "$SOURCE_DIR/openvas-scanner-$OPENVAS_SCANNER_VERSION/config/redis-openvas.conf" /etc/redis/; then
  964. log ERROR "Failed to copy Redis configuration."
  965. exit 1
  966. fi
  967. if ! run_command chown redis:redis /etc/redis/redis-openvas.conf; then
  968. log ERROR "Failed to set ownership for Redis configuration."
  969. exit 1
  970. fi
  971. if ! run_command sh -c "echo 'db_address = /run/redis-openvas/redis.sock' >> /etc/openvas/openvas.conf"; then
  972. log ERROR "Failed to update openvas.conf."
  973. exit 1
  974. fi
  975. if ! run_command systemctl start [email protected]; then
  976. log ERROR "Failed to start [email protected]."
  977. exit 1
  978. fi
  979. if ! run_command systemctl enable [email protected]; then
  980. log WARN "Failed to enable [email protected]. Service may not start on boot."
  981. fi
  982. if ! run_command usermod -aG redis gvm; then
  983. log ERROR "Failed to add gvm user to redis group."
  984. exit 1
  985. fi
  986. log INFO "Redis setup completed."
  987. }
  988.  
  989. # Adjusts permissions for OpenVAS directories and binaries.
  990. adjusting_permissions() {
  991. log INFO "Adjusting permissions for OpenVAS directories and binaries..."
  992. for dir in /var/lib/notus /run/gvmd; do
  993. if ! run_command mkdir -p "$dir"; then
  994. log ERROR "Failed to create directory $dir."
  995. exit 1
  996. fi
  997. done
  998. for dir in /var/lib/gvm /var/lib/openvas /var/lib/notus /var/log/gvm /run/gvmd; do
  999. if ! run_command chown -R gvm:gvm "$dir"; then
  1000. log ERROR "Failed to set ownership for $dir."
  1001. exit 1
  1002. fi
  1003. if ! run_command chmod -R g+srw "$dir"; then
  1004. log ERROR "Failed to set permissions for $dir."
  1005. exit 1
  1006. fi
  1007. if [ "$(stat -c %U:%G "$dir")" != "gvm:gvm" ]; then
  1008. log WARN "Directory $dir ownership is not gvm:gvm after setting. Verify permissions."
  1009. fi
  1010. done
  1011. if ! run_command chown gvm:gvm /usr/local/sbin/gvmd; then
  1012. log ERROR "Failed to set ownership for gvmd."
  1013. exit 1
  1014. fi
  1015. if ! run_command chmod 6750 /usr/local/sbin/gvmd; then
  1016. log ERROR "Failed to set permissions for gvmd."
  1017. exit 1
  1018. fi
  1019. if ! run_command setcap cap_net_raw+ep "$(which openvas)"; then
  1020. log ERROR "Failed to set CAP_NET_RAW capability on openvas binary."
  1021. exit 1
  1022. fi
  1023. if ! run_command setcap cap_net_raw+ep "$(which ospd-openvas)"; then
  1024. log ERROR "Failed to set CAP_NET_RAW capability on ospd-openvas binary."
  1025. exit 1
  1026. fi
  1027. log INFO "Permissions adjusted."
  1028. }
  1029.  
  1030. # Configures GPG for feed validation.
  1031. feed_validation() {
  1032. log INFO "Setting up feed validation with GPG..."
  1033. if ! run_command curl -f -L https://www.greenbone.net/GBCommunitySigningKey.asc -o /tmp/GBCommunitySigningKey.asc; then
  1034. log ERROR "Failed to download Greenbone signing key for feed validation."
  1035. exit 1
  1036. fi
  1037. if ! run_command mkdir -p "$GNUPGHOME"; then
  1038. log ERROR "Failed to create GPG home directory $GNUPGHOME."
  1039. exit 1
  1040. fi
  1041. if ! run_command gpg --import /tmp/GBCommunitySigningKey.asc; then
  1042. log ERROR "Failed to import Greenbone signing key for feed validation."
  1043. exit 1
  1044. fi
  1045. if ! run_command sh -c "echo '8AE4BE429B60A59B311C2E739823FAA60ED1E580:6:' | gpg --import-ownertrust"; then
  1046. log ERROR "Failed to set owner trust for Greenbone signing key."
  1047. exit 1
  1048. fi
  1049. if ! run_command mkdir -p "$OPENVAS_GNUPG_HOME"; then
  1050. log ERROR "Failed to create OpenVAS GPG directory $OPENVAS_GNUPG_HOME."
  1051. exit 1
  1052. fi
  1053. if ! run_command cp -r "$GNUPGHOME"/* "$OPENVAS_GNUPG_HOME"/; then
  1054. log ERROR "Failed to copy GPG keys to $OPENVAS_GNUPG_HOME."
  1055. exit 1
  1056. fi
  1057. if ! run_command chown -R gvm:gvm "$OPENVAS_GNUPG_HOME"; then
  1058. log ERROR "Failed to set ownership for $OPENVAS_GNUPG_HOME."
  1059. exit 1
  1060. fi
  1061. log INFO "Feed validation setup completed."
  1062. }
  1063.  
  1064. # Configures sudo for the gvm group to run openvas with elevated privileges.
  1065. setting_up_sudo_for_scanning() {
  1066. log INFO "Configuring sudo for gvm group..."
  1067. if grep -Fxq "%gvm ALL = NOPASSWD: /usr/local/sbin/openvas" /etc/sudoers.d/gvm; then
  1068. log INFO "Sudo already configured for gvm group."
  1069. else
  1070. log INFO "Setting up sudoers file for gvm group..."
  1071. if ! run_command sh -c "echo '%gvm ALL = NOPASSWD: /usr/local/sbin/openvas' > /etc/sudoers.d/gvm"; then
  1072. log ERROR "Failed to create sudoers file for gvm."
  1073. exit 1
  1074. fi
  1075. if ! run_command chmod 0440 /etc/sudoers.d/gvm; then
  1076. log ERROR "Failed to set permissions for sudoers file."
  1077. exit 1
  1078. fi
  1079. if ! run_command visudo -c -f /etc/sudoers.d/gvm; then
  1080. log ERROR "Sudoers file validation failed for /etc/sudoers.d/gvm."
  1081. exit 1
  1082. fi
  1083. log INFO "Sudo configuration for gvm group completed."
  1084. fi
  1085. }
  1086.  
  1087. # Sets up PostgreSQL database for gvmd.
  1088. setting_up_postgresql() {
  1089. log INFO "Setting up PostgreSQL for gvmd..."
  1090. if ! run_command apt install -y postgresql; then
  1091. log ERROR "Failed to install PostgreSQL."
  1092. exit 1
  1093. fi
  1094. # Detect the installed PostgreSQL cluster version dynamically (Debian 12 ships 15, Debian 13 ships 17).
  1095. local pg_version=""
  1096. if command -v pg_lsclusters >/dev/null 2>&1; then
  1097. pg_version=$(pg_lsclusters -h 2>/dev/null | awk '$2=="main"{print $1; exit}')
  1098. fi
  1099. if [ -z "$pg_version" ] && [ -d /etc/postgresql ]; then
  1100. pg_version=$(find /etc/postgresql -mindepth 1 -maxdepth 1 -type d -printf '%f\n' 2>/dev/null | sort -n | tail -1)
  1101. fi
  1102. if [ -z "$pg_version" ]; then
  1103. log ERROR "Could not detect installed PostgreSQL cluster version."
  1104. exit 1
  1105. fi
  1106. log INFO "Detected PostgreSQL cluster version: $pg_version"
  1107. if ! run_command systemctl start "postgresql@${pg_version}-main"; then
  1108. log ERROR "Failed to start postgresql@${pg_version}-main service."
  1109. exit 1
  1110. fi
  1111. if ! runuser -l postgres -c 'createuser -DRS gvm'; then
  1112. log ERROR "Failed to create PostgreSQL user gvm."
  1113. exit 1
  1114. fi
  1115. if ! runuser -l postgres -c 'createdb -O gvm gvmd'; then
  1116. log ERROR "Failed to create gvmd database."
  1117. exit 1
  1118. fi
  1119. if ! runuser -l postgres -c 'psql gvmd -c "create role dba with superuser noinherit; grant dba to gvm;"'; then
  1120. log ERROR "Failed to configure PostgreSQL roles for gvm."
  1121. exit 1
  1122. fi
  1123. log INFO "PostgreSQL setup completed."
  1124. }
  1125.  
  1126. # Creates an admin user for gvmd and captures the password.
  1127. setting_up_an_admin_user() {
  1128. log INFO "Creating admin user for gvmd..."
  1129. local output
  1130. output=$(/usr/local/sbin/gvmd --create-user=admin 2>&1)
  1131. if [ $? -ne 0 ]; then
  1132. log ERROR "Failed to create admin user for gvmd."
  1133. exit 1
  1134. fi
  1135. # Extract password from output.
  1136. local password
  1137. password=$(echo "$output" | grep -oP "User created with password '\K[^']+")
  1138. if [ -z "$password" ]; then
  1139. log ERROR "Failed to extract admin password from gvmd output."
  1140. exit 1
  1141. fi
  1142. # Store password in a temporary file with restricted permissions
  1143. if ! echo "$password" > /tmp/gvm_admin_password; then
  1144. log ERROR "Failed to store admin password."
  1145. exit 1
  1146. fi
  1147. if ! chmod 600 /tmp/gvm_admin_password; then
  1148. log ERROR "Failed to set permissions for admin password file."
  1149. exit 1
  1150. fi
  1151. if ! chown gvm:gvm /tmp/gvm_admin_password; then
  1152. log ERROR "Failed to set ownership for admin password file."
  1153. exit 1
  1154. fi
  1155. log INFO "Admin user created."
  1156. }
  1157.  
  1158. # Sets the feed import owner to the admin user.
  1159. setting_the_feed_import_owner() {
  1160. log INFO "Setting feed import owner to admin..."
  1161. local admin_uuid
  1162. admin_uuid=$(/usr/local/sbin/gvmd --get-users --verbose | grep admin | awk '{print $2}')
  1163. if [ -z "$admin_uuid" ]; then
  1164. log ERROR "Failed to retrieve admin user UUID."
  1165. exit 1
  1166. fi
  1167. if ! /usr/local/sbin/gvmd --modify-setting 78eceaec-3385-11ea-b237-28d24461215b --value "$admin_uuid"; then
  1168. log ERROR "Failed to set feed import owner."
  1169. exit 1
  1170. fi
  1171. log INFO "Feed import owner set."
  1172. }
  1173.  
  1174. # Configures systemd services for OpenVAS components.
  1175. setting_up_services_for_systemd() {
  1176. log INFO "Setting up systemd services..."
  1177.  
  1178. # ospd-openvas service
  1179. log INFO "Creating ospd-openvas systemd service..."
  1180. if ! cat << EOF > "$BUILD_DIR/ospd-openvas.service"
  1181. [Unit]
  1182. Description=OSPd Wrapper for the OpenVAS Scanner (ospd-openvas)
  1183. Documentation=man:ospd-openvas(8) man:openvas(8)
  1184. After=network.target networking.service [email protected] openvasd.service
  1185. [email protected] openvasd.service
  1186. ConditionKernelCommandLine=!recovery
  1187.  
  1188. [Service]
  1189. Type=exec
  1190. User=gvm
  1191. Group=gvm
  1192. RuntimeDirectory=ospd
  1193. RuntimeDirectoryMode=2775
  1194. PIDFile=/run/ospd/ospd-openvas.pid
  1195. ExecStart=/usr/local/bin/ospd-openvas --foreground --unix-socket /run/ospd/ospd-openvas.sock --pid-file /run/ospd/ospd-openvas.pid --log-file /var/log/gvm/ospd-openvas.log --lock-file-dir /var/lib/openvas --socket-mode 0o770 --notus-feed-dir /var/lib/notus/advisories
  1196. SuccessExitStatus=SIGKILL
  1197. Restart=always
  1198. RestartSec=60
  1199.  
  1200. [Install]
  1201. WantedBy=multi-user.target
  1202. EOF
  1203. then
  1204. log ERROR "Failed to create ospd-openvas systemd service file."
  1205. exit 1
  1206. fi
  1207. if ! run_command cp -v "$BUILD_DIR/ospd-openvas.service" /etc/systemd/system/; then
  1208. log ERROR "Failed to install ospd-openvas systemd service."
  1209. exit 1
  1210. fi
  1211.  
  1212. # gvmd service
  1213. log INFO "Creating gvmd systemd service..."
  1214. if ! cat << EOF > "$BUILD_DIR/gvmd.service"
  1215. [Unit]
  1216. Description=Greenbone Vulnerability Manager daemon (gvmd)
  1217. After=network.target networking.service postgresql.service ospd-openvas.service
  1218. Wants=postgresql.service ospd-openvas.service
  1219. Documentation=man:gvmd(8)
  1220. ConditionKernelCommandLine=!recovery
  1221.  
  1222. [Service]
  1223. Type=exec
  1224. User=gvm
  1225. Group=gvm
  1226. PIDFile=/run/gvmd/gvmd.pid
  1227. RuntimeDirectory=gvmd
  1228. RuntimeDirectoryMode=2775
  1229. ExecStart=/usr/local/sbin/gvmd --foreground --osp-vt-update=/run/ospd/ospd-openvas.sock --listen-group=gvm
  1230. Restart=always
  1231. TimeoutStopSec=10
  1232.  
  1233. [Install]
  1234. WantedBy=multi-user.target
  1235. EOF
  1236. then
  1237. log ERROR "Failed to create gvmd systemd service file."
  1238. exit 1
  1239. fi
  1240. if ! run_command cp -v "$BUILD_DIR/gvmd.service" /etc/systemd/system/; then
  1241. log ERROR "Failed to install gvmd systemd service."
  1242. exit 1
  1243. fi
  1244.  
  1245. # gsad service
  1246. log INFO "Creating gsad systemd service..."
  1247. if ! cat << EOF > "$BUILD_DIR/gsad.service"
  1248. [Unit]
  1249. Description=Greenbone Security Assistant daemon (gsad)
  1250. Documentation=man:gsad(8) https://www.greenbone.net
  1251. After=network.target gvmd.service
  1252. Wants=gvmd.service
  1253.  
  1254. [Service]
  1255. Type=exec
  1256. User=gvm
  1257. Group=gvm
  1258. RuntimeDirectory=gsad
  1259. RuntimeDirectoryMode=2775
  1260. PIDFile=/run/gsad/gsad.pid
  1261. ExecStart=/usr/local/sbin/gsad --foreground --listen=0.0.0.0 --port=9392 --ssl-certificate=/etc/gvm/gsad.crt --ssl-private-key=/etc/gvm/gsad.key
  1262. Restart=always
  1263. TimeoutStopSec=10
  1264.  
  1265. [Install]
  1266. WantedBy=multi-user.target
  1267. Alias=greenbone-security-assistant.service
  1268. EOF
  1269. then
  1270. log ERROR "Failed to create gsad systemd service file."
  1271. exit 1
  1272. fi
  1273. if ! run_command cp -v "$BUILD_DIR/gsad.service" /etc/systemd/system/; then
  1274. log ERROR "Failed to install gsad systemd service."
  1275. exit 1
  1276. fi
  1277.  
  1278. # openvasd service
  1279. log INFO "Creating openvasd systemd service..."
  1280. if ! cat << EOF > "$BUILD_DIR/openvasd.service"
  1281. [Unit]
  1282. Description=OpenVASD
  1283. Documentation=https://github.com/greenbone/openvas-scanner/tree/main/rust/openvasd
  1284. ConditionKernelCommandLine=!recovery
  1285. [Service]
  1286. Type=exec
  1287. User=gvm
  1288. RuntimeDirectory=openvasd
  1289. RuntimeDirectoryMode=2775
  1290. ExecStart=/usr/local/bin/openvasd --mode service_notus --products /var/lib/notus/products --advisories /var/lib/notus/advisories --listening 127.0.0.1:3000
  1291. SuccessExitStatus=SIGKILL
  1292. Restart=always
  1293. RestartSec=60
  1294. [Install]
  1295. WantedBy=multi-user.target
  1296. EOF
  1297. then
  1298. log ERROR "Failed to create openvasd systemd service file."
  1299. exit 1
  1300. fi
  1301. if ! run_command cp -v "$BUILD_DIR/openvasd.service" /etc/systemd/system/; then
  1302. log ERROR "Failed to install openvasd systemd service."
  1303. exit 1
  1304. fi
  1305.  
  1306. log INFO "Reloading systemd daemon..."
  1307. if ! run_command systemctl daemon-reload; then
  1308. log ERROR "Failed to reload systemd daemon."
  1309. exit 1
  1310. fi
  1311. log INFO "Systemd services setup completed."
  1312. }
  1313.  
  1314. # Synchronizes Greenbone feed data.
  1315. feed_synchronization() {
  1316. log INFO "Starting feed synchronization..."
  1317. if ! run_command /usr/local/bin/greenbone-feed-sync; then
  1318. log ERROR "Failed to synchronize Greenbone feed."
  1319. exit 1
  1320. fi
  1321. log INFO "Feed synchronization completed."
  1322. }
  1323.  
  1324. # Starts and enables OpenVAS services.
  1325. start_openvas() {
  1326. log INFO "Starting and enabling OpenVAS services..."
  1327. for service in ospd-openvas gvmd gsad openvasd; do
  1328. if ! run_command systemctl start "$service"; then
  1329. log ERROR "Failed to start $service service."
  1330. exit 1
  1331. fi
  1332. if ! run_command systemctl enable "$service"; then
  1333. log WARN "Failed to enable $service service. Service may not start on boot."
  1334. else
  1335. log INFO "$service service started and enabled."
  1336. fi
  1337. done
  1338. log INFO "OpenVAS services started and enabled."
  1339. }
  1340.  
  1341. # Displays login information for the OpenVAS web interface.
  1342. login_info() {
  1343. # ANSI color codes
  1344. local COLOR_INFO="\033[1;36m" # Cyan for info
  1345. local COLOR_RESET="\033[0m"
  1346. local BOX_COLOR="\033[1;34m" # Blue for box borders
  1347. local WIDTH=60 # Box width
  1348.  
  1349. log INFO "Providing login information for OpenVAS web interface..."
  1350.  
  1351. # Retrieve password securely
  1352. local password
  1353. if [ -f /tmp/gvm_admin_password ]; then
  1354. password=$(cat /tmp/gvm_admin_password)
  1355. else
  1356. log ERROR "Admin password file not found at /tmp/gvm_admin_password."
  1357. exit 1
  1358. fi
  1359. # Get the primary network interface IP address
  1360. local host_ip
  1361. host_ip=$(ip -4 addr show | grep inet | awk '{print $2}' | cut -d'/' -f1 | grep -v '127.0.0.1' | head -n 1)
  1362. if [ -z "$host_ip" ]; then
  1363. log WARN "Could not determine host IP address. Using 'localhost' for URL."
  1364. host_ip="localhost"
  1365. fi
  1366. local login_url="https://${host_ip}:9392"
  1367.  
  1368. # Print boxed login information
  1369. printf "\n${BOX_COLOR}%*s${COLOR_RESET}\n" "$WIDTH" | tr ' ' '#' # Top border
  1370. printf "${BOX_COLOR}#${COLOR_RESET} OpenVAS Web Interface Login%*s${BOX_COLOR}${COLOR_RESET}\n" $((WIDTH-28)) ""
  1371. printf "${BOX_COLOR}${COLOR_RESET}%*s${BOX_COLOR}${COLOR_RESET}\n" $WIDTH | tr ' ' '-' # Separator
  1372. printf "${BOX_COLOR}#${COLOR_RESET} Username : admin%*s${BOX_COLOR}${COLOR_RESET}\n" $((WIDTH-24)) ""
  1373. printf "${BOX_COLOR}#${COLOR_RESET} Password : %s%*s${BOX_COLOR}${COLOR_RESET}\n" "$password" $((WIDTH-19-${#password})) ""
  1374. printf "${BOX_COLOR}#${COLOR_RESET} URL : %s%*s${BOX_COLOR}${COLOR_RESET}\n" "$login_url" $((WIDTH-19-${#login_url})) ""
  1375. printf "${BOX_COLOR}%*s${COLOR_RESET}\n" "$WIDTH" | tr ' ' '#' # Bottom border
  1376. printf "\n${COLOR_INFO}Consider changing the administrator password with the following command:${COLOR_RESET}\n"
  1377. printf "\n${COLOR_INFO}/usr/local/sbin/gvmd --user=admin --new-password=<your_new_strong_password>${COLOR_RESET}\n"
  1378. printf "\n"
  1379.  
  1380. # Clean up the password file
  1381. if ! rm -f /tmp/gvm_admin_password; then
  1382. log WARN "Failed to remove temporary password file /tmp/gvm_admin_password."
  1383. fi
  1384. }
  1385.  
  1386. # -----------------------------------
  1387. # Section: Cleanup
  1388. # -----------------------------------
  1389.  
  1390. # Cleans up temporary directories used during installation.
  1391. cleanup() {
  1392. log INFO "Cleaning up temporary directories..."
  1393. if ! rm -rf "$SOURCE_DIR" "$BUILD_DIR" "$INSTALL_DIR" 2>/dev/null; then
  1394. log WARN "Failed to fully clean up temporary directories. Check permissions."
  1395. fi
  1396. log INFO "Cleanup completed."
  1397. }
  1398.  
  1399. # Trap errors and cleanup on exit
  1400. trap 'log ERROR "Script terminated due to an error."; cleanup' ERR
  1401. trap cleanup EXIT
  1402.  
  1403. # -----------------------------------
  1404. # Section: Main Execution
  1405. # -----------------------------------
  1406.  
  1407. # Main function to orchestrate the OpenVAS installation process.
  1408. main() {
  1409. log INFO "Starting OpenVAS installation on $(date '+%Y-%m-%d %H:%M:%S')..."
  1410.  
  1411. # Check if the installation is running as root
  1412. check_root
  1413.  
  1414. # Detect Debian release (12/13) to drive version-specific behavior
  1415. detect_debian_version
  1416.  
  1417. # Install the required packeges for OpenVAS
  1418. install_packages
  1419.  
  1420. # Set the apropriate environment variables for the installation
  1421. set_environment
  1422.  
  1423. # Check for the latest component versions
  1424. check_latest_version
  1425.  
  1426. # Creating a User and a Group
  1427. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#creating-a-user-and-a-group
  1428. create_gvm_user
  1429.  
  1430. # Setting a Source, Build and Install Directory
  1431. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#setting-a-source-build-and-install-directory
  1432. create_directories
  1433.  
  1434. # Importing the Greenbone Signing Key
  1435. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#importing-the-greenbone-signing-key
  1436. import_signing_key
  1437.  
  1438. # Generate self-signed SSL certificate for gsad
  1439. generate_ssl_cert
  1440.  
  1441. # Build Eclipse paho.mqtt.c from source where the libpaho-mqtt-dev package is unavailable
  1442. # (e.g. Debian 13 / trixie). gvm-libs hard-requires paho-mqtt3c.
  1443. if [ "${HAS_LIBPAHO_MQTT:-1}" -ne 1 ]; then
  1444. build_install_paho_mqtt_from_source
  1445. fi
  1446.  
  1447. # Install gvm-libs
  1448. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#pg-gvm
  1449. build_install_component \
  1450. "gvm-libs" \
  1451. "$GVM_LIBS_VERSION" \
  1452. "-S $SOURCE_DIR/gvm-libs-$GVM_LIBS_VERSION -B $BUILD_DIR/gvm-libs -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release -DSYSCONFDIR=/etc -DLOCALSTATEDIR=/var"
  1453.  
  1454. # Install gvmd
  1455. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#pg-gvm
  1456. build_install_component \
  1457. "gvmd" \
  1458. "$GVMD_VERSION" \
  1459. "-S $SOURCE_DIR/gvmd-$GVMD_VERSION -B $BUILD_DIR/gvmd -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release -DLOCALSTATEDIR=/var -DSYSCONFDIR=/etc -DGVM_DATA_DIR=/var -DGVM_LOG_DIR=/var/log/gvm -DGVMD_RUN_DIR=/run/gvmd -DOPENVAS_DEFAULT_SOCKET=/run/ospd/ospd-openvas.sock -DGVM_FEED_LOCK_PATH=/var/lib/gvm/feed-update.lock -DLOGROTATE_DIR=/etc/logrotate.d"
  1460.  
  1461. # Install pg-gvm
  1462. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#pg-gvm
  1463. build_install_component \
  1464. "pg-gvm" \
  1465. "$PG_GVM_VERSION" \
  1466. "-S $SOURCE_DIR/pg-gvm-$PG_GVM_VERSION -B $BUILD_DIR/pg-gvm -DCMAKE_BUILD_TYPE=Release"
  1467.  
  1468. # Install gsa
  1469. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#gsa
  1470. build_install_gsa \
  1471. "gsa" \
  1472. "$GSA_VERSION"
  1473.  
  1474. # Install gsad
  1475. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#gsad
  1476. build_install_component \
  1477. "gsad" \
  1478. "$GSAD_VERSION" \
  1479. "-S $SOURCE_DIR/gsad-$GSAD_VERSION -B $BUILD_DIR/gsad -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release -DSYSCONFDIR=/etc -DLOCALSTATEDIR=/var -DGVMD_RUN_DIR=/run/gvmd -DGSAD_RUN_DIR=/run/gsad -DGVM_LOG_DIR=/var/log/gvm -DLOGROTATE_DIR=/etc/logrotate.d"
  1480.  
  1481. # Install openvas-smb
  1482. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#openvas-smb
  1483. build_install_component \
  1484. "openvas-smb" \
  1485. "$OPENVAS_SMB_VERSION" \
  1486. "-S $SOURCE_DIR/openvas-smb-$OPENVAS_SMB_VERSION -B $BUILD_DIR/openvas-smb -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release"
  1487.  
  1488. # Install openvas-scanner
  1489. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#openvas-scanner
  1490. build_install_component \
  1491. "openvas-scanner" \
  1492. "$OPENVAS_SCANNER_VERSION" \
  1493. "-S $SOURCE_DIR/openvas-scanner-$OPENVAS_SCANNER_VERSION -B $BUILD_DIR/openvas-scanner -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release -DSYSCONFDIR=/etc -DLOCALSTATEDIR=/var -DOPENVAS_FEED_LOCK_PATH=/var/lib/openvas/feed-update.lock -DOPENVAS_RUN_DIR=/run/ospd"
  1494.  
  1495. # Install ospd-openvas
  1496. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#ospd-openvas
  1497. build_install_opsd \
  1498. "ospd-openvas" \
  1499. "$OSPD_OPENVAS_VERSION"
  1500.  
  1501. # Install openvasd
  1502. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#openvasd
  1503. build_install_openvasd \
  1504. "openvas-scanner" \
  1505. "openvasd" \
  1506. "$OPENVAS_DAEMON"
  1507.  
  1508. # Install greenbone-feed-sync
  1509. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#greenbone-feed-sync
  1510. build_install_py \
  1511. "greenbone-feed-sync"
  1512.  
  1513. # Install greenbone-feed-sync
  1514. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#gvm-tools
  1515. build_install_py \
  1516. "gvm-tools"
  1517.  
  1518. # Performing a System Setup
  1519. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#performing-a-system-setup
  1520. perform_system_setup
  1521.  
  1522. # Adjusting Permissions
  1523. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#adjusting-permissions
  1524. adjusting_permissions
  1525.  
  1526. # Feed Validation
  1527. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#feed-validation
  1528. feed_validation
  1529.  
  1530. # Setting up sudo for Scanning
  1531. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#setting-up-sudo-for-scanning
  1532. setting_up_sudo_for_scanning
  1533.  
  1534. # Setting up PostgreSQL
  1535. # URL: https://greenbone.github.io/docs/latest/22.4/source-build/index.html#setting-up-postgresql
  1536. setting_up_postgresql
  1537.  
  1538. # Setting up an Admin User
  1539. setting_up_an_admin_user
  1540.  
  1541. # Setting the Feed Import Owner
  1542. setting_the_feed_import_owner
  1543.  
  1544. # Setting up Services for Systemd
  1545. setting_up_services_for_systemd
  1546.  
  1547. # Performing a Feed Synchronization
  1548. feed_synchronization
  1549.  
  1550. # Starting the Greenbone Community Edition Services
  1551. start_openvas
  1552.  
  1553. # Providing Login Information
  1554. login_info
  1555.  
  1556. # Cleanup temporary directories
  1557. cleanup
  1558.  
  1559. log INFO "OpenVAS installation completed successfully."
  1560. }
  1561.  
  1562. main
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment