Skip to main content
The kb-download.sh script provides a unified interface for retrieving the full Knowledge Base (KB), a KB update, the test KB, a SQLite KB snapshot or an HFH KB snapshot directly from the SCANOSS SFTP server. It connects to the server, displays the available versions and allows you to select the desired package for download. Before proceeding, it verifies that sufficient disk space is available. For KB updates, the downloaded package includes a separate import utility (ldb-import.sh) which is used to import the update into your local LDB instance.

KB Download Prerequisites

  • lftp (recommended): Enables faster, parallel, and resumable downloads. You can install it using apt install lftp. If lftp is not available, the script can fall back to the standard sftp client. When running with the -y flag, the fallback to sftp is handeld automatically.
  • sshpass (required only for sftp fallback): Needed to provide the password non-interactively when using sftp. Install it with apt install sshpass. This dependency is not required when using lftp.
  • SFTP credentials: Supplied by the SCANOSS sales team, including host, port, username and password.

Running the Script

Make sure the script has execution permissions:
Run the script without arguments for a fully interactive session:

Command-line Options

All connection details, paths, and the download mode can be passed as arguments to skip the matching interactive prompt:
Connection / mode
FlagDescription
-mDownload mode: full (full KB), update (KB update), test (test KB), sqlite (SQLite KB snapshot), or hfh (HFH KB snapshot)
-hSFTP host
-PSFTP port
-uSFTP username
-pSFTP password
-tlftp parallel download threads (default: 25)
-dForce download tool: lftp or sftp
-CEnable SSH transport compression. Off by default. Useful on slow links; on fast links it typically slows the transfer down (zlib CPU exceeds the bandwidth saving for dense payloads like hashes and indexes).
Path / version overrides
FlagDescription
-VKB version (full/update/sqlite/hfh mode); default: latest from LATEST.txt on the server
-oDestination path. Test mode: test-KB destination. Full mode: oss folder destination. (default: /var/lib/ldb/oss)
-rFull mode only: destination for non-oss items (default: /tmp/scanoss_kb_full_<version>)
-DUpdate / sqlite / hfh mode: download base directory. Final path is <D>/<version> for update/sqlite and <D>/<version>.zip for hfh. Defaults: /tmp/scanoss_kb_update for update, current directory for sqlite and hfh
Non-interactive flags
FlagDescription
-yDon’t prompt; use defaults for unspecified values and auto-confirm the download. Required values (-m, -h, -P, -u, -p) must be supplied — the script exits with an error if any are missing.
-fForce download even if free disk space is below the required size. Only meaningful with -y; without -y you are prompted to confirm.
-?Show help
Any options not provided on the command line will be prompted interactively, unless -y is set.

Non-interactive Examples

How It Works

  1. Connection: the script prompts for (or reads from arguments) the SFTP host, port, username, and password
  2. Mode selection: you choose between downloading the full KB, a KB update, the test KB, or a SQLite KB snapshot, or an HFH snapshot
  3. Version discovery (full/update/sqlite/hfh only): it connects to the SFTP server and lists all available versions of the chosen type, marking which one is the latest. Test KB has no versions — there is only one current test KB on the server.
  4. Selection (full/update/sqlite/hfh only): you choose which version to download (defaults to the latest)
  5. Disk space check: the script fetches the metadata and verifies there is enough free disk space before downloading. If not enough is available, you are warned and asked to confirm before continuing. (For HFH the size comes from ls -l on the remote .zip rather than metadata.json.)
  6. Download:
    • For full KB: the download is split between two destinations. The oss folder (the main LDB data) goes to its own destination (default: /var/lib/ldb/oss), and all remaining files and folders go to a separate directory (default: /tmp/scanoss_kb_full_<version>). Both destinations can be changed when prompted.
    • For updates: the whole update folder is downloaded to a single directory (default: /tmp/scanoss_kb_update/<version>).
    • For test KB: the test KB’s oss folder is downloaded to a single destination (default: /var/lib/ldb/oss). This will populate your LDB with the test data for verification.
    • For SQLite KB: the whole version folder is downloaded to <base>/<version> (default base: the current working directory). The folder contains one or more .sqlite files plus a metadata.json. The script downloads every file you have access to in that folder — different users may see different sets of .sqlite files depending on their SFTP permissions.
    • For HFH KB: a single <version>.zip archive is downloaded to <base>/<version>.zip (default base: the current working directory). With lftp the file is fetched in parallel chunks (pget -n <threads>); with sftp it’s a single-stream get with the live progress poller. The script does not extract the archive — leave that to your downstream tooling.
  7. Import (updates only): after downloading an update, run the ldb-import.sh script included in the downloaded folder

Example Sessions

Update

Full KB

Test KB

SQLite KB

The downloaded folder contains all .sqlite files the SFTP user has access to (plus metadata.json). Different users may see different sets of files depending on their permissions.

HFH KB

HFH ships as a single <version>.zip archive (no metadata.json); the disk-space check reads the file size from the remote ls -l output. The script does not extract the archive — that’s left to downstream tooling.

Verifying a KB Update

After importing an update, verify the installation by scanning the test WFP files included in the update directory:
If both scans return appropriate matches, the update was imported successfully.
If the import is interrupted, it may cause corruption in the existing LDB.

Next Steps

Once the Knowledge Base installation is complete, proceed to Verify Installation.