Skip to content

Instantly share code, notes, and snippets.

@thunfischbrot
Created February 20, 2018 10:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thunfischbrot/0b6a21a84f166c4fa74fc5df4a470b17 to your computer and use it in GitHub Desktop.
Save thunfischbrot/0b6a21a84f166c4fa74fc5df4a470b17 to your computer and use it in GitHub Desktop.
Unison systemd service
# /etc/systemd/system/unison@.service
# Starts unison with the .prf-config of your choice
# Create a unison .prf-config such as
# https://gist.github.com/thunfischbrot/3efbd4a87785615a61e4f5fd875f2699
# Set the HOME Environment variable below to the user's home dir
# Reload systemd services
# systemctl daemon-reload
# Start service with name of your .prf
# systemctl start unison@20Documents
# systemctl status
# If it is working, add to startup
# systemctl enable unison@20Documents
[Unit]
Description=Unison File Synchronization
After=network.target
[Service]
Type=simple
Environment="PATH=/usr/local/bin:/usr/bin"
# Change to home directory of your user in which the .unison/*.prf files are located
Environment="HOME=/root"
ExecStart=/usr/local/bin/unison %i
Restart=always
RestartSec=7
[Install]
WantedBy=default.target
@kovkev
Copy link

kovkev commented Mar 20, 2018

I'm trying to see if I can use unison with systemd. I'm reading up on systemd but have not encountered the following aspect yet. What if unison finds a conflict and asks the user to chose between the remote or the local version of a file? Is there a way to interact with the systemd unison service to tell it to chose e.g. the remote version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment