Skip to content

CLI

The scripts/cli/ directory contains the SafeCall CLI tool, which is bundled into the installer and deployed to production servers.

Overview

The CLI is a Commander-based TypeScript application that manages SafeCall installations. It is bundled into a single file by build/generators/installer.ts and embedded in the installer shell script.

cli/
├── main.ts         Entry point (Commander setup, all commands)
├── system.ts       Install, update, repair, uninstall, service, status
├── config.ts       Config show, edit, set, reset
├── setup.ts        Phase 2 guided setup wizard
├── nginx.ts        Nginx + self-signed certificate setup
├── selftest.ts     Deployment health checks
├── test.ts         Test command (selftest, full VM suite, cleanup)
├── user.ts         User create, delete, reset password
├── monit.ts        Monit monitoring setup
├── cron.ts         Automatic update cron job
└── helpers.ts      Shared prompt utilities (input, password, select)

Commands

Installation

CommandDescription
safecall installPhase 1: download binary, scripts, and default config
safecall setupPhase 2: guided wizard for service configuration
safecall setup --defaultsAccept all defaults without prompting

Configuration

CommandDescription
safecall configPretty-print current main.config.json
safecall config editOpen config in $EDITOR or nano, restart service after save
safecall config set <key> <value>Set a single config key and restart
safecall config resetOverwrite with default config

System Management

CommandDescription
safecall serviceSet up systemd service
safecall nginxGenerate nginx config and self-signed cert
safecall cronSet up daily update cron job
safecall monitInstall and configure monit monitoring
safecall statusCheck status of service, monit, cron, and CLI

User Management

CommandDescription
safecall user --createCreate a new user
safecall user --deleteDelete a user by email
safecall user --reset-passwordReset the default user's password

Maintenance

CommandDescription
safecall updateUpdate to the latest version
safecall repairRepair a broken installation
safecall uninstallStop service and remove all files
safecall selftestRun deployment health checks
safecall test --selftestQuick health check (same as selftest)
safecall test --fullFull VM test suite
safecall test --cleanClean up test artifacts

Architecture

The CLI entry point (main.ts) registers all commands with Commander and delegates to handler functions in the other modules. Each module is self-contained with its own imports.

At build time, build/generators/installer.ts bundles all CLI modules into a single minified JavaScript file using Bun.build(). This bundle is embedded in build/templates/installer.sh along with a util.sh wrapper script. The installer extracts both files to the installation directory, where the compiled SafeCall binary runs util.ts (the bundled CLI) in Bun mode.