Skip to content

Shell API Reference

The Sanctum shell library provides a set of sanctum_* functions for reading instance configuration, querying node topology, and interacting with the Sanctum infrastructure from Bash scripts and LaunchAgent wrappers.

Source the config library at the top of any script:

Terminal window
source ~/.sanctum/lib/config.sh

For notification support, also source:

Terminal window
source ~/.sanctum/lib/notify.sh

Read any value from the instance config using dot-notation path.

Terminal window
sanctum_get <key_path>
ParameterDescription
key_pathDot-delimited path into instance.yaml

Returns: The value as a string. Empty string if the key does not exist.

Terminal window
# Read a scalar value
port=$(sanctum_get services.gateway.port)
echo "$port" # 18789
# Read the instance slug
sanctum_get instance.slug # manoir-nepveu
# Read a nested value
sanctum_get network.vm_ip # 10.10.10.10

Check whether a config path evaluates to true.

Terminal window
sanctum_enabled <key_path>

Returns: Exit code 0 if the value is true, non-zero otherwise.

Terminal window
if sanctum_enabled services.gateway.enabled; then
echo "Gateway is active"
fi
if sanctum_enabled services.signal_bridge.enabled; then
echo "Signal bridge is active"
else
echo "Signal bridge is disabled"
fi

Expand {{PLACEHOLDER}} tokens in a string using values from the instance config. Used primarily by generate-plists.sh for template rendering.

Terminal window
sanctum_expand <template_string>
Terminal window
expanded=$(sanctum_expand "User is {{users.mac}} at {{network.lan_ip}}")
echo "$expanded" # User is bert at 192.168.1.10

Return the Sanctum home directory.

Terminal window
sanctum_home

Returns: The path to ~/.sanctum.

Terminal window
config_dir=$(sanctum_home)
echo "$config_dir" # /Users/bert/.sanctum

Return the instance slug.

Terminal window
sanctum_slug
Terminal window
sanctum_slug # manoir-nepveu

Return the human-readable instance name.

Terminal window
sanctum_name
Terminal window
sanctum_name # Manoir Nepveu

Return the VM IP address.

Terminal window
sanctum_vm_ip
Terminal window
sanctum_vm_ip # 10.10.10.10

Return the Mac bridge IP (the Mac-side IP on the host-only network).

Terminal window
sanctum_mac_ip
Terminal window
sanctum_mac_ip # 10.10.10.1

Return the SSH alias for connecting to the VM.

Terminal window
sanctum_vm_ssh
Terminal window
ssh $(sanctum_vm_ssh) 'uptime'
# equivalent to: ssh openclaw 'uptime'

Return the VM username.

Terminal window
sanctum_vm_user
Terminal window
sanctum_vm_user # ubuntu

Return the current node identity (read from ~/.sanctum/.node_id).

Terminal window
sanctum_whoami
Terminal window
sanctum_whoami # manoir

Check if the current machine is a specific node.

Terminal window
sanctum_is_node <node_id>

Returns: Exit code 0 if the current node matches, non-zero otherwise.

Terminal window
if sanctum_is_node manoir; then
echo "Running on the hub"
fi

Return the node type of the current machine.

Terminal window
sanctum_my_type
Terminal window
sanctum_my_type # hub

These functions query the nodes section of the instance config. They accept a <node_id> argument (e.g., manoir, chalet).

Return the type of a node.

Terminal window
sanctum_node_type <node_id>
Terminal window
sanctum_node_type manoir # hub
sanctum_node_type chalet # satellite

Return the LAN hostname or IP of a node.

Terminal window
sanctum_node_host <node_id>
Terminal window
sanctum_node_host manoir # 192.168.1.10
sanctum_node_host chalet # chalet.local

Return the Tailscale IP of a node.

Terminal window
sanctum_node_ts_ip <node_id>
Terminal window
sanctum_node_ts_ip manoir # 100.112.178.25

Return the Tailscale device name of a node.

Terminal window
sanctum_node_ts_name <node_id>
Terminal window
sanctum_node_ts_name manoir # berts-mac-mini-m4-pro

Return the SSH username for a node.

Terminal window
sanctum_node_user <node_id>
Terminal window
sanctum_node_user manoir # bert

Check if a node is reachable (via Tailscale ping or LAN ping).

Terminal window
sanctum_node_online <node_id>

Returns: Exit code 0 if the node responds, non-zero otherwise.

Terminal window
if sanctum_node_online chalet; then
echo "Chalet is reachable"
fi

SSH to a node over the LAN.

Terminal window
sanctum_node_ssh <node_id> [command...]
Terminal window
# Interactive shell
sanctum_node_ssh chalet
# Run a remote command
sanctum_node_ssh chalet 'uptime'

SSH to a node over Tailscale (for remote/off-LAN access).

Terminal window
sanctum_node_ssh_ts <node_id> [command...]
Terminal window
sanctum_node_ssh_ts chalet 'df -h'

SSH to the VM on a specific node (if that node has a VM).

Terminal window
sanctum_node_vm_ssh <node_id> [command...]
Terminal window
sanctum_node_vm_ssh manoir 'systemctl --user status openclaw-gateway'

Check if a specific service is enabled on a node.

Terminal window
sanctum_node_enabled <node_id> <service_name>

Returns: Exit code 0 if the service is enabled on that node.

Terminal window
if sanctum_node_enabled chalet home_assistant; then
echo "Chalet runs HA"
fi

Get a service config value for a specific node.

Terminal window
sanctum_node_service <node_id> <service_name> <key>
Terminal window
sanctum_node_service manoir gateway port # 18789

Return the node ID of the hub node.

Terminal window
sanctum_node_hub
Terminal window
hub=$(sanctum_node_hub)
echo "$hub" # manoir

Source ~/.sanctum/lib/notify.sh for notification support.

Send a notification through configured channels (macOS Notification Center, agent message, etc.).

Terminal window
sanctum_notify <title> <message> [priority]
ParameterDescription
titleNotification title
messageNotification body
priorityOptional: low, normal (default), high
Terminal window
source ~/.sanctum/lib/notify.sh
sanctum_notify "Backup Complete" "All files backed up successfully"
sanctum_notify "Disk Warning" "Boot volume is 90% full" high

#!/bin/bash
source ~/.sanctum/lib/config.sh
source ~/.sanctum/lib/notify.sh
echo "Instance: $(sanctum_name) [$(sanctum_slug)]"
echo "Node: $(sanctum_whoami) ($(sanctum_my_type))"
echo "VM: $(sanctum_vm_user)@$(sanctum_vm_ip)"
if sanctum_enabled services.gateway.enabled; then
port=$(sanctum_get services.gateway.port)
echo "Gateway running on port $port"
fi
hub=$(sanctum_node_hub)
echo "Hub node: $hub ($(sanctum_node_host $hub))"
if sanctum_node_online chalet; then
sanctum_notify "Chalet Status" "Chalet node is online"
else
sanctum_notify "Chalet Status" "Chalet node is offline" high
fi