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. Iflftp is not available, the script can fall back to the standardsftpclient. When running with the-yflag, the fallback tosftpis handeld automatically. - sshpass (required only for sftp fallback): Needed to provide the password non-interactively when using
sftp. Install it withapt install sshpass. This dependency is not required when usinglftp. - SFTP credentials: Supplied by the SCANOSS sales team, including host, port, username and password.
Running the Script
Make sure the script has execution permissions:Command-line Options
All connection details, paths, and the download mode can be passed as arguments to skip the matching interactive prompt:| Flag | Description |
|---|---|
-m | Download mode: full (full KB), update (KB update), test (test KB), sqlite (SQLite KB snapshot), or hfh (HFH KB snapshot) |
-h | SFTP host |
-P | SFTP port |
-u | SFTP username |
-p | SFTP password |
-t | lftp parallel download threads (default: 25) |
-d | Force download tool: lftp or sftp |
-C | Enable 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). |
| Flag | Description |
|---|---|
-V | KB version (full/update/sqlite/hfh mode); default: latest from LATEST.txt on the server |
-o | Destination path. Test mode: test-KB destination. Full mode: oss folder destination. (default: /var/lib/ldb/oss) |
-r | Full mode only: destination for non-oss items (default: /tmp/scanoss_kb_full_<version>) |
-D | Update / 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 |
| Flag | Description |
|---|---|
-y | Don’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. |
-f | Force download even if free disk space is below the required size. Only meaningful with -y; without -y you are prompted to confirm. |
-? | Show help |
-y is set.
Non-interactive Examples
How It Works
- Connection: the script prompts for (or reads from arguments) the SFTP host, port, username, and password
- Mode selection: you choose between downloading the full KB, a KB update, the test KB, or a SQLite KB snapshot, or an HFH snapshot
- 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.
- Selection (full/update/sqlite/hfh only): you choose which version to download (defaults to the latest)
- 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 -lon the remote.ziprather thanmetadata.json.) - Download:
- For full KB: the download is split between two destinations. The
ossfolder (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
ossfolder 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.sqlitefiles plus ametadata.json. The script downloads every file you have access to in that folder — different users may see different sets of.sqlitefiles depending on their SFTP permissions. - For HFH KB: a single
<version>.ziparchive 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-streamgetwith the live progress poller. The script does not extract the archive — leave that to your downstream tooling.
- For full KB: the download is split between two destinations. The
- Import (updates only): after downloading an update, run the
ldb-import.shscript included in the downloaded folder
Example Sessions
Update
Full KB
Test KB
SQLite KB
.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
<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 the import is interrupted, it may cause corruption in the existing LDB.