Docs/ CLI/ Référence des commandes

Référence des commandes

Les 48 commandes de la version publiée (v1.10.2), regroupées par tâche. Chaque bloc ci-dessous est le <code>--help</code> de la commande, réduit à sa syntaxe : ce que vous lisez ici est ce que le binaire accepte.

Configuration et options globales

La plupart des commandes parlent à un serveur sh0 par son API. Elles le trouvent dans cet ordre :

  • Les variables d'environnement SH0_API_URL et SH0_API_TOKEN, quand les deux sont posées -- la voie à suivre en intégration continue. Elles l'emportent sur le fichier.
  • Le fichier ~/.sh0/config.toml, écrit par sh0 login. sh0 config show affiche le serveur et un jeton masqué ; sans l'un ni l'autre, les commandes s'arrêtent sur « No configuration found. Run `sh0 login` or set SH0_API_URL and SH0_API_TOKEN environment variables. »
  • Les options globales se limitent à --log-level, -h, --help et -V, --version. --config désigne le fichier de configuration du serveur (/etc/sh0/config.toml) et ne concerne que les commandes qui tournent sur le serveur, comme sh0 serve.
  • --json est une option propre à chaque commande : elle existe là où la référence ci-dessous la montre (listes, cron runs…), pas partout.
Terminal
$ sh0 whoami
  Server:  https://panel.example.com
  User:    [email protected]
  Role:    owner

$ SH0_API_URL=https://panel.example.com SH0_API_TOKEN=sh0_... sh0 apps
  NAME      STATUS    BRANCH  PORT  REPLICAS  UPDATED
  --------  --------  ------  ----  --------  -------
  my-api    running   main    3001  1         2m ago
Warning
Il n'existe aucune option globale --url, --token, --json ou --verbose. Un script écrit d'après une ancienne version de cette page qui les utilisait échoue sur « unexpected argument » : utilisez plutôt les variables d'environnement ci-dessus.

Lire les blocs : <APP> est obligatoire, [--option] est facultatif, ... se répète. La ligne qui commence par # est la description de la commande elle-même. <APP> accepte le nom ou l'identifiant d'une application ; la plupart des commandes de services (sh0 db…) prennent un identifiant, affiché à la création de la ressource et par leur list.

Compte et configuration de la CLI

Relier la CLI à un serveur et vérifier qui vous y êtes.

sh0 login

sh0 login --help
# Authenticate with a sh0 server
sh0 login [--url <URL>]

sh0 whoami

sh0 whoami --help
# Show current user and server info
sh0 whoami

sh0 config

sh0 config --help
# Show current configuration
sh0 config show
# Get a specific configuration value
sh0 config get <KEY>
# Set a configuration value
sh0 config set <KEY> <VALUE>

sh0 version

sh0 version --help
# Print version information
sh0 version

Répertoire de travail

Lier un répertoire local à une application, le vérifier avant de déployer, et redéployer à chaque modification.

sh0 init

sh0 init --help
# Initialize a project directory for sh0 deployments
sh0 init [PATH]
sh0 link --help
# Link the current directory to an existing app on the server
sh0 link <APP> [--path <PATH>]

sh0 open

sh0 open --help
# Open the app's primary domain in the default browser
sh0 open [APP]

sh0 watch

sh0 watch --help
# Watch for file changes and auto-push
sh0 watch [PATH] [--name <NAME>] [--project <PROJECT>] [--port <PORT>] [--no-check] [--timeout <TIMEOUT>] [--debounce <DEBOUNCE>]

sh0 check

sh0 check --help
# Run Code Health Check on local directory
sh0 check [PATH] [--json]

Déployer

sh0 push envoie un répertoire sous forme d'archive et crée ou met à jour l'application : c'est la voie principale, sans dépôt Git. Voir Déployer par push.

sh0 push

sh0 push --help
# Push local directory to deploy (create or update)
sh0 push [PATH] [--name <NAME>] [--project <PROJECT>] [--port <PORT>] [--no-check] [--timeout <TIMEOUT>]

sh0 deploy

sh0 deploy --help
# Trigger a deployment
sh0 deploy <APP> [--message <MESSAGE>] [--wait]

sh0 templates

sh0 templates --help
# List available templates
sh0 templates list
# Show template details
sh0 templates info <NAME>
# Deploy a template
sh0 templates deploy --app-name <APP_NAME> <NAME> [--var]

sh0 compose

sh0 compose --help
# Deploy a Docker Compose file
sh0 compose deploy --app-name <APP_NAME> [PATH] [--var] [--wait]
# Validate a Docker Compose file without deploying
sh0 compose validate [PATH]

sh0 yaml

sh0 yaml --help
# Apply a sh0.yaml configuration
sh0 yaml apply [PATH]
# Validate a sh0.yaml configuration without applying
sh0 yaml validate [PATH]
# Export current configuration as sh0.yaml
sh0 yaml export [--project <PROJECT>]

sh0 export

sh0 export --help
# Export app configuration to a platform-specific format
sh0 export <APP> <FORMAT> [--output <OUTPUT>]

Gérer les applications

Cycle de vie, variables, domaines, journaux et shell dans une application en service. Les variables s'appliquent au déploiement suivant.

sh0 apps

sh0 apps --help
# List all applications
sh0 apps [--json]

sh0 status

sh0 status --help
# Show server or app status
sh0 status [APP] [--json]

sh0 restart

sh0 restart --help
# Restart an application
sh0 restart <APP>
Warning
Sur une application lente à s'arrêter, sh0 restart peut se terminer sur « operation timed out » au bout de 30 secondes alors que le redémarrage se poursuit et réussit sur le serveur (mesuré : 41 s avant la réponse de l'API). Vérifiez avec sh0 status <APP> avant de relancer.

sh0 stop

sh0 stop --help
# Stop an application
sh0 stop <APP> [--yes]

sh0 start

sh0 start --help
# Start a stopped application
sh0 start <APP>

sh0 delete

sh0 delete --help
# Delete an application and its resources
sh0 delete <APP> [--yes]

sh0 scale

sh0 scale --help
# Scale application replicas
sh0 scale <APP> [REPLICAS] [--auto] [--status] [--json]

sh0 env

sh0 env --help
# List environment variables
sh0 env <APP> list [--reveal]
# Set an environment variable
sh0 env <APP> set <PAIR> [--build]
# Delete an environment variable
sh0 env <APP> delete <KEY>
Terminal
$ sh0 env my-api set "DATABASE_URL=postgresql://appuser:<password>@my-pg.internal:5432/appdb"
[ok] Set DATABASE_URL for 'my-api'

$ sh0 env my-api list
  KEY           VALUE    BUILD  CREATED
  ------------  -------  -----  -------
  DATABASE_URL  *******  no     4m ago
  GREETING      *******  no     16m ago

sh0 domains

sh0 domains --help
# List domains for the app
sh0 domains <APP> list
# Add a domain to the app
sh0 domains <APP> add <DOMAIN> [--primary]
# Remove a domain from the app
sh0 domains <APP> remove <DOMAIN> [--yes]

sh0 logs

sh0 logs --help
# Stream application logs
sh0 logs <APP> [--follow] [--tail <TAIL>]

sh0 ssh

sh0 ssh --help
# Execute command in app container
sh0 ssh <APP> [COMMAND]...
Note
sh0 ssh a besoin d'un terminal interactif (depuis un script qui n'en a pas, il s'arrête sur « cannot attach stdin to a TTY-enabled container »). Placez -- devant une commande qui a ses propres options : sh0 ssh my-api -- node --version.

Tâches planifiées, hooks et prévisualisations

Avant de créer une tâche planifiée, lisez où sa commande s'exécute : elle ne voit pas les variables de votre application.

sh0 cron

sh0 cron --help
# List cron jobs
sh0 cron list [--app <APP>] [--json]
# Create a new cron job
sh0 cron create --app <APP> --name <NAME> --schedule <SCHEDULE> --command <COMMAND> [--image <IMAGE>] [--timeout <TIMEOUT>]
# Manually trigger a cron job
sh0 cron trigger <ID>
# Show execution history for a cron job
sh0 cron runs <ID> [--json]
# Delete a cron job
sh0 cron delete <ID> [--yes]

sh0 hooks

sh0 hooks --help
# List deploy hooks for an app
sh0 hooks <APP> list [--json]
# Create a deploy hook
sh0 hooks <APP> create --hook-type <type> --command <COMMAND> [--timeout <TIMEOUT>]
# Delete a deploy hook
sh0 hooks <APP> delete <ID>

sh0 preview

sh0 preview --help
# List preview environments for an app
sh0 preview <APP> list [--json]
# Destroy a preview environment
sh0 preview <APP> delete <ID>
# Enable preview environments for an app
sh0 preview <APP> enable [--ttl <TTL>]
# Disable preview environments for an app
sh0 preview <APP> disable

Services

Serveurs de bases de données, d'authentification, de temps réel, de fonctions, de courrier, de stockage et de disponibilité. Chaque commande a un alias court (db, auth, realtime, fn, storage) ; le nom long fonctionne aussi.

sh0 db

sh0 db --help
# List all database servers
sh0 db list [--json]
# Show database server details
sh0 db info <ID> [--json]
# Create a new database server
sh0 db create --name <NAME> --engine <ENGINE> [--project <PROJECT>]
# Update a database server
sh0 db update <ID> [--name <NAME>] [--project <PROJECT>]
# Delete a database server
sh0 db delete <ID> [--yes]
# Start a database server
sh0 db start <ID>
# Stop a database server
sh0 db stop <ID>
# Recreate a database server container
sh0 db recreate <ID>
# Show connection info for a database server
sh0 db connection-info <ID> [--json]
# Create a database on a server
sh0 db create-database --name <NAME> <ID>
# Create a user on a database server
sh0 db create-user --username <USERNAME> --password <PASSWORD> <ID>
# Grant a user access to a database
sh0 db grant --user <USER> --database <DATABASE> <ID> [--privileges <PRIVILEGES>]
# Enable PostgREST sidecar
sh0 db enable-postgrest <ID> [--anon-role <ANON_ROLE>] [--schemas <SCHEMAS>]
# Disable PostgREST sidecar
sh0 db disable-postgrest <ID>

sh0 auth

sh0 auth --help
# List all auth servers
sh0 auth-servers list [--json]
# Show auth server details
sh0 auth-servers info <ID> [--json]
# Create a new auth server
sh0 auth-servers create --name <NAME> --database-server <DATABASE_SERVER> [--project <PROJECT>]
# Delete an auth server
sh0 auth-servers delete <ID> [--yes]
# Start an auth server
sh0 auth-servers start <ID>
# Stop an auth server
sh0 auth-servers stop <ID>

sh0 realtime

sh0 realtime --help
# List all realtime servers
sh0 realtime-servers list [--json]
# Show realtime server details
sh0 realtime-servers info <ID> [--json]
# Create a new realtime server
sh0 realtime-servers create --name <NAME> [--project <PROJECT>]
# Delete a realtime server
sh0 realtime-servers delete <ID> [--yes]
# Start a realtime server
sh0 realtime-servers start <ID>
# Stop a realtime server
sh0 realtime-servers stop <ID>

sh0 fn

sh0 fn --help
# List all function servers
sh0 function-servers list [--json]
# Show function server details
sh0 function-servers info <ID> [--json]
# Create a new function server
sh0 function-servers create --name <NAME> [--project <PROJECT>]
# Delete a function server
sh0 function-servers delete <ID> [--yes]
# Start a function server
sh0 function-servers start <ID>
# Stop a function server
sh0 function-servers stop <ID>

sh0 mail

sh0 mail --help
# List all mail domains
sh0 mail list [--json]
# Show mail domain details
sh0 mail info <ID> [--json]
# Create a new mail domain
sh0 mail create --domain <DOMAIN> [--project <PROJECT>]
# Delete a mail domain
sh0 mail delete <ID> [--yes]
# Start a mail domain
sh0 mail start <ID>
# Stop a mail domain
sh0 mail stop <ID>
# Check DNS records for a mail domain
sh0 mail dns-check <ID> [--json]
# Create a mailbox on a mail domain
sh0 mail create-mailbox --email <EMAIL> --password <PASSWORD> <ID> [--display-name <DISPLAY_NAME>]
# Create an email alias on a mail domain
sh0 mail create-alias --source <SOURCE> --destination <DESTINATION> <ID>

sh0 storage

sh0 storage --help
# List all file storage instances
sh0 file-storage list [--json]
# Show file storage instance details
sh0 file-storage info <ID> [--json]
# Create a new file storage instance
sh0 file-storage create --name <NAME> [--project <PROJECT>]
# Delete a file storage instance
sh0 file-storage delete <ID> [--yes]
# Start a file storage instance
sh0 file-storage start <ID>
# Stop a file storage instance
sh0 file-storage stop <ID>
# Create a bucket in a storage instance
sh0 file-storage create-bucket --name <NAME> <ID>
# Create an access key for a storage instance
sh0 file-storage create-key <ID> [--json]
# Show storage usage statistics
sh0 file-storage usage <ID> [--json]

sh0 uptime

sh0 uptime --help
# List uptime checks
sh0 uptime list [--app <APP>] [--json]
# Show uptime check details
sh0 uptime info <ID> [--json]
# Create a new uptime check
sh0 uptime create --app <APP> --url <URL> [--interval <INTERVAL>] [--method <METHOD>] [--timeout <TIMEOUT>] [--expected-status <EXPECTED_STATUS>] [--failure-threshold <FAILURE_THRESHOLD>]
# Delete an uptime check
sh0 uptime delete <ID> [--yes]
# List uptime incidents for a check
sh0 uptime incidents <CHECK_ID> [--json]

Serveurs et panneau

Les nœuds distants et le domaine du panneau lui-même.

sh0 nodes

sh0 nodes --help
# List all server nodes
sh0 nodes list [--json]
# Show node details
sh0 nodes info <ID> [--json]
# Register a new server node
sh0 nodes create --name <NAME> --host <HOST> --ssh-user <SSH_USER> [--ssh-key <SSH_KEY>] [--password <PASSWORD>] [--port <PORT>]
# Remove a node from the cluster
sh0 nodes delete <ID> [--yes]
# Test SSH and Docker connectivity to a node
sh0 nodes test <ID> [--json]

sh0 panel-domain

sh0 panel-domain --help
# Domaine du panneau d'administration : le lire, le poser, le retirer.
sh0 panel-domain [COMMAND] [--data-dir <DATA_DIR>] [--db <DB>] [--caddy-data <CADDY_DATA>] [--jwt-secret-path <JWT_SECRET_PATH>] [--port <PORT>]
# Poser le domaine et attendre l'émission du certificat
sh0 panel-domain set <DOMAIN> [--no-wait]
# Retirer la route et le réglage
sh0 panel-domain clear

Administration du serveur

Ces commandes s'exécutent sur le serveur, en root, et agissent sur l'installation locale plutôt que par l'API. Quelques-unes impriment leur aide en français dans la version actuelle.

sh0 serve

sh0 serve --help
# Start the sh0 server
sh0 serve [OPTIONS]    # sh0 serve --help lists every option

sh0 setup

sh0 setup --help
# Run initial setup wizard
sh0 setup

sh0 install-dns-caddy

sh0 install-dns-caddy --help
# Install a Caddy that can answer the DNS-01 ACME challenge (ISSUE-158).
sh0 install-dns-caddy

sh0 users

sh0 users --help
# List all users (reads the local database when run on the server box, the API otherwise)
sh0 users list [--json] [--data-dir <DATA_DIR>] [--db <DB>]
# Invite a new user
sh0 users invite <EMAIL> [--password <PASSWORD>] [--role <ROLE>] [--display-name <DISPLAY_NAME>]
# Update a user
sh0 users update <ID> [--role <ROLE>] [--display-name <DISPLAY_NAME>]
# Remove a user
sh0 users remove <ID> [--yes]
# Reset a user's password locally (recovery path; run on the server box, no login required)
sh0 users reset-password <EMAIL> [--password <PASSWORD>] [--disable-2fa] [--data-dir <DATA_DIR>] [--db <DB>]

sh0 projects

sh0 projects --help
# List all projects
sh0 projects list [--json]
# Create a new project
sh0 projects create <NAME> [--description <DESCRIPTION>] [--color <COLOR>]
# Delete an empty project (refused while it still holds apps, databases or services)
sh0 projects delete <PROJECT> [--yes]
# List project members
sh0 projects members <PROJECT> [--json]
# Add a member to a project
sh0 projects add-member <PROJECT> <USER> [--role <ROLE>]
# Remove a member from a project
sh0 projects remove-member <PROJECT> <USER>

sh0 update

sh0 update --help
# Update sh0, or roll back to the previous version
sh0 update [--rollback] [--channel <CHANNEL>] [--force] [--yes]

sh0 doctor

sh0 doctor --help
# Préflight d'hôte : Docker, ports, disque, certificats, horloge.
sh0 doctor [COMMAND] [--json] [--db <DB>] [--data-dir <DATA_DIR>] [--caddy-data <CADDY_DATA>] [--port <PORT>]
# Count restore rows that migration 055 could not reach (ISSUE-086).
sh0 doctor backup-rows [--json] [--db <DB>]
# List host mounts that the bind whitelist would refuse today (ISSUE-176).
sh0 doctor bind-mounts [--json] [--db <DB>] [--all]

sh0 instance

sh0 instance --help
# Écrire un instantané de cette instance dans un fichier
sh0 instance backup [--data-dir <DATA_DIR>] [--out <OUT>] [--encrypt]
# Reposer une instance sauvegardée sur cette machine
sh0 instance restore --file <FILE> [--data-dir <DATA_DIR>] [--dry-run] [--force]
# Remplacer la clé maîtresse et rechiffrer tous les secrets de la base
sh0 instance rotate-key [--data-dir <DATA_DIR>] [--dry-run] [--yes] [--backup-out <BACKUP_OUT>]

sh0 uninstall

sh0 uninstall --help
# Uninstall sh0 (remove binary and optionally data)
sh0 uninstall [--purge]

sh0 destroy

sh0 destroy --help
# Destroy everything: stop and remove all containers, images, volumes, networks, data, and binary
sh0 destroy