This will let you run or build something when sync is complete!

Greetings fellow syncthing users!

I hope i’m posting in the right place!

I just wanted to share this amazing little piece of opensource software written by the amazing aengl called Syncthing-hooks

Basically, if you run it or daemonize it on a machine running syncthing, it will watch any specified folders, and anytime these folders are done synchronizing new content they will run a little shell script of your likings.

Syncthing-hook comes as is, and doesn’t contain any scripts to do anything particular for you, so it takes a bit of technological skills (mainly shell scripting) to get it to do what ever it is you want it to do. But this also leaves it open to do more or less anything you can imagine.

As an example, i have made a system for my musician-friends, so that they can drop their properly ID3 tagged original-creations in mp3 in a folder synchronized with my raspberry-pi, and pifpafpuf, it adds the audio-file to a website in an HTML5 player using the ID3 embedded image, title, etc… Drag’n’drop creative commons publication, just like that!

Or why not create your own self hosted instagram-like website, with a synchronized picture folder on your phone? Syncstagram!

You will find the tool here:

Aengl is my good friend, and we’d be happy if you would let us know here if you use it for something! We’d love to see what the community can come up with!

Sincerely, Sakrecoer

edit: apparently, i’m not allowed to post links yet… understandable. :slight_smile: I hope I’m not making anyone upset if I post this formatted as i did now… It doesn’t feel quite right to write comments to posts without having a sincere reason to do so, just to unlock that feature :confused:

7 Likes

Upgraded and linkified. :+1:

2 Likes

Many thanks @calmh :slight_smile:

If someone could explain in detail…? or write a basic tutorial of syncthing hooks pls… it would be so great full

Sorry for the late response, @Samanosuke. Welcome to the Syncthing forum!

Did you look at the readme file on github?

Did it not help you?

Maybe if you tell me where you are stuck i can help you. Note that this hasn’t been upgraded in a while. And given how fast the node.js ecosystem is moving, it is unclear if it still works. I’m currently not using this tool anymore… But maybe i should… your ping certainly got me inspired to rethink it… :thinking:

I came across this post when searching for “syncthing hooks”. I am looking for similar tools to run a script after a folder completes syncing.

Aside from syncthing-hooks, I also came across stfed on github, which is similar. Alternatively, I also came across the syncthing docs for the event api… but not sure which is easier.

I just want to run a script after a completed sync of my pictures.

Unfortunately, without any specifics, which one option is easier is going to vary a lot:

  • Types of devices, including operating system?
  • Your scripting skills?
  • Direction of sync?

My setup is with Phone ↔ Raspberry Pi.

The direction of sync is both ways, but I’m mainly running a script on the Pi to add some metadata to photos synced on the phone.

I’m pretty confident with my scripting skills…

Some links I found are as follows: (Broke the links as I’m only allowed 2 links max as a new forum user).

  • \https://forum.syncthing.net/t/about-rest-api-event/17828
    • This gave me a good idea of the syntax of the curl command needed. Reading the docs also helped.
  • \https://forum.syncthing.net/t/syncthing-event-api-intended-usage-and-efficiency/20404/
    • Perfect, thank you. Implemented as a shell script

      • Unfortunately the script link is no longer working :frowning:
  • \https://forum.syncthing.net/t/help-creating-a-simple-script-foldercompletion-copy-files/15768
    • This is basically what I want, but change copy to a separate script to modify exif data

From my findings, I kinda figured out a rough idea of what is needed to make a script. I’d like to stick with bash, but I could just use the python link above as well…

If there’s only one Syncthing folder configured, a basic no frills Bash script could be done in just a few lines, calling cURL for Syncthing’s Event API and something like Exiv2 for manipulating image file metadata. But if there are other Syncthing folders in addition to the pictures, it’ll require just a bit more parsing of Syncthing’s JSON feed.