Skip to main content
The kb-download.sh script downloads packages from the SCANOSS SFTP server. It can fetch the full Knowledge Base (KB), a KB update, the test KB, a SQLite KB snapshot, or an HFH KB snapshot. It connects to the server, lists the available versions, and lets you pick a package. Before it downloads, it checks that you have enough free disk space. A KB update package includes a separate import utility, ldb-import.sh. Use it to import the update into your local LDB instance.

KB download prerequisites

  • lftp is recommended. It gives faster, parallel, resumable downloads. Install it with apt install lftp. If lftp isn’t available, the script can fall back to the standard sftp client. With the -y flag, the script falls back to sftp without asking.
  • sshpass is required only for the sftp fallback. It passes the password to sftp non-interactively. Install it with apt install sshpass. You don’t need it when you use lftp.
  • SFTP credentials come from the SCANOSS sales team: host, port, username, and password.

Running the script

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

Command-line options

You can pass the connection details, paths, and download mode as arguments. The script then skips the prompt for each value you pass:
Connection and mode Path and version overrides Non-interactive flags Unless you set -y, the script prompts for any option you didn’t pass on the command line.

Non-interactive examples

How it works

  1. The script prompts for the SFTP host, port, username, and password, or reads them from arguments.
  2. You choose what to download: the full KB, a KB update, the test KB, a SQLite KB snapshot, or an HFH snapshot.
  3. For full, update, sqlite, and hfh modes, the script connects to the SFTP server, lists every available version of the chosen type, and marks the latest. The test KB has no versions. The server holds one current test KB.
  4. For full, update, sqlite, and hfh modes, you choose a version. The default is the latest.
  5. The script fetches the metadata and checks for enough free disk space. If there isn’t enough, it warns you and asks you to confirm before it continues. For HFH, it reads the size from ls -l on the remote .zip instead of metadata.json.
  6. The script downloads the package:
    • The full KB goes to two destinations. The oss folder, which holds the main LDB data, goes to its own destination (default: /var/lib/ldb/oss). The remaining files and folders go to a separate directory (default: /tmp/scanoss_kb_full_<version>). You can change both destinations at the prompt.
    • An update downloads as one folder to a single directory (default: /tmp/scanoss_kb_update/<version>).
    • The test KB’s oss folder goes to a single destination (default: /var/lib/ldb/oss). This fills your LDB with the test data for verification.
    • A SQLite KB downloads as a version folder to <base>/<version> (default base: the current working directory). The folder holds one or more .sqlite files and 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.
    • An HFH KB downloads as a single <version>.zip archive to <base>/<version>.zip (default base: the current working directory). With lftp, the script fetches the file in parallel chunks (pget -n <threads>). With sftp, it uses a single-stream get with the live progress poller. The script doesn’t extract the archive. Leave that to your downstream tooling.
  7. For updates only, run the ldb-import.sh script in the downloaded folder after the download finishes.

Example sessions

Update

Full KB

Test KB

SQLite KB

The downloaded folder holds every .sqlite file the SFTP user has access to, and metadata.json. Different users may see different sets of files, depending on their permissions.

HFH KB

HFH ships as a single <version>.zip archive with no metadata.json. The disk-space check reads the file size from the remote ls -l output. The script doesn’t extract the archive. Leave that to your downstream tooling.

Verifying a KB update

After you import an update, check it by scanning the test WFP files in the update directory:
If both scans return the expected matches, the import worked.
An interrupted import can corrupt the existing LDB.

Next steps

When the Knowledge Base is installed, continue to Verify installation.