init
Initialize the xrat config directory, config file, and database.
xrat init [--dry-run]
Flags
| Flag | Description |
|---|---|
--dry-run | Print planned actions without creating anything |
Behavior
- Creates the app root directory (
$HOME/.config/xrat/or$XRAT_PATH) - Writes a default
config.tomlwith sensible defaults if not already present - Creates the SQLite database and runs all pending migrations
- Creates subdirectories:
runtime/,logs/,mmdb/ - Prints a summary of what was created and what was already present
Idempotent: safe to run multiple times. Existing files are never
overwritten. If config.toml exists and has been customized, it is left
untouched.
Example: first-time setup
xrat init
xrat initialized successfully.
Created:
/home/user/.config/xrat/
/home/user/.config/xrat/config.toml (written default template)
/home/user/.config/xrat/runtime/
/home/user/.config/xrat/logs/
/home/user/.config/xrat/mmdb/
Already present:
/home/user/.config/xrat/db.sqlite (database ready)
Next steps:
xrat import <subscription-url>
xrat list configs
Example: dry run
xrat init --dry-run
--- dry run: no files written ---
Would create (if absent):
/home/user/.config/xrat/
/home/user/.config/xrat/config.toml
/home/user/.config/xrat/db.sqlite
/home/user/.config/xrat/runtime/
/home/user/.config/xrat/logs/
/home/user/.config/xrat/mmdb/
State paths
| Path | Purpose | Override |
|---|---|---|
$HOME/.config/xrat/ | App root | XRAT_PATH env var |
$HOME/.config/xrat/config.toml | Configuration | --config flag |
$HOME/.config/xrat/db.sqlite | SQLite database | --database flag |
$HOME/.config/xrat/runtime/ | Daemon socket, session state | — |
$HOME/.config/xrat/logs/ | Runtime logs | [runtime.log].dir |
$HOME/.config/xrat/mmdb/ | GeoIP data | [mmdb].dir |
Default config.toml
xrat init writes a fully documented config file: common settings are active
with inline descriptions, and advanced features are present but commented out so
the file doubles as offline reference. Default local ports use the 1820x block
(SOCKS 18200, HTTP 18201, Shadowsocks 18202, API server 18203).
[runtime]
engine = "xray"
replace_active_session = true
[runtime.socks]
enabled = true
host = "0.0.0.0"
port = 18200
udp = true
[runtime.http]
enabled = false
host = "0.0.0.0"
port = 18201
[runtime.log]
enabled = true
level = "warning"
[testing]
concurrency = 0
[server]
enabled = false
host = "127.0.0.1"
port = 18203
See Config File for full reference.
Related
- Quickstart
- Configuration
- daemon install — install as a background service (systemd/launchd/rc.d)