Crates.io | rincron_mini |
lib.rs | rincron_mini |
version | 0.3.0-rc1 |
source | src |
created_at | 2023-05-29 08:09:22.482552 |
updated_at | 2023-08-30 17:02:34.402992 |
description | A replacement for incron written in Rust |
homepage | |
repository | https://github.com/nevermille/rincron-mini |
max_upload_size | |
id | 876999 |
size | 81,813 |
Rincron-mini is a software written in Rust who aims to be a replacement for incrontab. This software is compatible with Linux and only Linux since inotify doesn't exist on other platforms.
Use cargo to install rincron-mini:
cargo install rincron_mini
Rincron-Mini uses JSON files as configuration files. You can use a single file or you can use multiple files inside a directory. Here you have expected paths :
Single file | Multiple files | |
---|---|---|
root | /etc/rincron-mini.json |
/etc/rincron-mini/*.json |
user | $HOME/.config/rincron-mini.json |
$HOME/.config/rincron-mini/*.json |
Each JSON file must contain an array of objects. This is the minimal format:
[
{
"path": "/tmp",
"events": [
"CREATE",
"MOVED_TO"
],
"command": "echo \"Event on $#/$@\""
},
{
"path": "/dev/null",
"events": ["IN_ACCESS"],
"command": "echo \"Event on $#/$@\""
}
]
path
: Can be a file or a directory, this is what will be watchedevents
: One or more inotify events, you can strip the IN_
from event namecommand
: A command to executeIf you want to contextualize the command line, you can use a few wildcards:
$@
: The watched file/directory (copies the path
parameter)$#
: The file or directory name where the event was triggered$$
: A $
characterWhen you use rincron-mini for executing commands on moved, copied or uploaded files, you may want to execute the command only if the copy/move/upload is finished. In this case, you can add a check_interval
parameter with an integer representing the time (in seconds) between two size checks. Once the file size hasn't changed between two checks, the command will be executed
In this example, the file will be checked every 5 seconds:
[
{
"path": "/tmp",
"events": [
"CREATE",
"MOVED_TO"
],
"command": "echo \"Event on $#/$@\"",
"check_interval": 5
}
]
Sometimes, you want to execute a command only on one file type. You can do this with the file_match
command. You can use the ?
and *
wildcards.
Example with a check on zip files:
[
{
"path": "/tmp",
"events": [
"CREATE",
"MOVED_TO"
],
"command": "echo \"Event on $#/$@\"",
"file_match": "*.zip"
}
]
This sofware is unfortunately not a full incrontab replacement. There are some limitations:
$%
and $&
are not implementedI'll try to improve the software, to make it more powerfull.