Dv4cfg

Haixin Pang February 25, 2025 #PRO

Usage

Config

Basic

namenecessitytypedefaultdescriptiontodo
idoptstringuse to distinguish different vault
localoptlocal_devicelocal device config
sshopt[ssh_device]ssh device config
groupopt[task_group]execution unit
autoopt[auto_task]some daemon services or autostart applications
copyopt[copy_task]copy files/directories between devices
appopt[app_task]device package management
execopt[exec_task]exec_desc">execute commands/script

Device Config

Each device is composed of ordinary users and super users. Currently, users only have the current user and ssh users.

Current user (local) config as follows

namenecessitytypedefaultdescriptiontodo
uidoptstringthisuse to distinguish different user
mountoptpath~/.config/dvrelative path expansion in copy_task

ssh user (ssh_user) config as follows

namenecessitytypedefaultdescriptiontodo
uidmuststringuse to distinguish different user
hostmuststringThe Host field in the ssh_config file is used to find the ssh configuration
passwdoptstringssh user passwd

Local device config (local_device) as follows

namenecessitytypedefaultdescriptiontodo
hidmuststringlocaluse to distinguish different user
usermustlocalcurrent user config
systemoptssh_userlocal device super user(administrator)Temporarily reuse ssh, and may write a general agent in the future

ssh device config (ssh_device) as follows

namenecessitytypedefaultdescriptiontodo
hidmuststringuse to distinguish different user
osoptmanjaro|alpine|...remote device os
usersopt[ssh_user]ssh user config
systemoptssh_userremote device super user(administrator)

Basic Task

Each task has basic attributes (task_attr) as follows

namenecessitytypedefaultdescriptiontodo
idmuststringuse to distinguish different user
nextopt[string]indicates the topological relationship between tasks

Currently, only the next relationship is supported between tasks, and more relationships may be supported in the future.

The task target (target) type is as follows

namenecessitytypedefaultdescriptiontodo
src_uidoptstringoperation source
dst_uidoptstringoperation destination

Auto start service (auto_task)

namenecessitytypedefaultdescriptiontodo
attrmusttask_attrbasic attributes
uidoptstringoperation destination
namemuststringservice name
actionmustsetup|reloadoperation

File copy (copy_task)

namenecessitytypedefaultdescriptiontodo
attrmusttask_attrbasic attributes
targetopttargetoperation destination
pairmust[(string,string)]the path of the file to be copied

App management (app_task)

namenecessitytypedefaultdescriptiontodo
attrmusttask_attrbasic attributes
uidoptstringoperation destination
pkgsmust[string]apps need to be installed

Execute command (exec_task)

namenecessitytypedefaultdescriptiontodo
attrmusttask_attrbasic attributes
uidoptstringoperation destination
shelloptstringthe shell used to execute command
commandmuststringcommands

Task Group

Cite (cite)

namenecessitytypedefaultdescriptiontodo
attrmusttask_attrbasic attributes
targetopttargetrelated users

The id of the basic attribute of the task to be referenced is the same as the id of the referenced task. You can reference task groups or individual tasks. target will fill the target of the referenced task, and dst_uid will fill the uid of the referenced task.

Task group (task_group)

namenecessitytypedefaultdescriptiontodo
idmuststringuse to distinguish different user(group)
targetopttargetrelated users
citesopt[cite]Other tasks referenced (groups)
auto(see previous)
copy(see previous)
app(see previous)
exec(see previous)

The grouped taget is the same as above, passed down level by level

Command

Simple CLI to use dv-api with toml/yaml/json

Usage: dv4cfg [OPTIONS] <COMMAND>

Commands:
  full-config  Print example config [aliases: fc]
  exec         Execute plan [aliases: e]
  help         Print this message or the help of the given subcommand(s)

Options:
  -d, --directory <DIRECTORY>  [default: /home/$USER/.config/dv/]
  -c, --config <CONFIG>        
  -h, --help                   Print help
  -V, --version                Print version
Print example config

Usage: dv4cfg full-config [EXTENSION]

Arguments:
  [EXTENSION]  

Options:
  -h, --help  Print help

EXTENSIONopt,used to specify the configuration file format (toml/yaml/json)

Execute plan

Usage: dv4cfg exec [OPTIONS] [PLAN_ID]

Arguments:
  [PLAN_ID]  

Options:
  -n, --dry-run  
  -h, --help     Print help