Sync single file

This commit is contained in:
Sven Seeberg 2020-10-29 18:21:54 +01:00
parent 1fac9d0564
commit ba3a862dad
Signed by: sven.seeberg
GPG key ID: 29559DD5A83806B5
2 changed files with 13 additions and 5 deletions

View file

@ -21,5 +21,7 @@ pgpkey = ID
rawpath = /path/to/json/dir
# path in which signed files will be stored
path = /path/to/dir
# if synccmd can be empty, if no synchronization command is needed
;synccmd = rclone /path/to/dir Remote:dir
# if synccmd can be empty, if no synchronization command is needed. Placeholders:
# %s - signed file
# %u - unsigned file
;synccmd = rclone %s Remote:dir

View file

@ -110,10 +110,16 @@ function create_text_file($cfg, $body) {
}
file_put_contents($file_path, "\n\n\n", FILE_APPEND);
shell_exec("gpg --yes --clearsign " . $file_path);
if (strlen($cfg["export"]["synccmd"]) > 0) {
shell_exec($cfg["export"]["synccmd"]);
}
sync_command($cfg, $file_path);
return trim(shell_exec("/usr/bin/sha256sum " . $file_path. ".asc | awk '{ print $1 }'"));
}
function sync_command($cfg, $file_path) {
$cmd = $cfg["export"]["synccmd"];
if (strlen($cmd) > 0) {
$cmd = str_replace("%s", $file_path . ".asc", $cmd);
$cmd = str_replace("%u", $file_path, $cmd);
shell_exec($cmd);
}
}
?>