From bfdb1f0946ea0f65e4248400ae285e57992ad1d9 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Sun, 21 Mar 2021 21:52:22 -0400 Subject: [PATCH] add systemd unit exemple --- README.md | 4 ++++ contrib/systemd/README.md | 11 +++++++++++ contrib/systemd/gitlabfs@.service | 9 +++++++++ 3 files changed, 24 insertions(+) create mode 100644 contrib/systemd/README.md create mode 100644 contrib/systemd/gitlabfs@.service diff --git a/README.md b/README.md index 41b731f..1e86981 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,10 @@ To stop the filesystem, use the command `umount /path/to/mountpoint` to cleanly If `gitlabfs` is not cleanly stopped, you might start seeing the error "transport endpoint is not connected" when trying to access the mountpoint, even preventing from mounting back the filesystem on the same mountpoint. To fix this, use `umount` as root user, eg: `sudo umount /path/to/mountpoint`. +### Running automatically on user login + +See [./contrib/systemd](contrib/systemd) for instructions on how to configure a systemd service to automatically run gitlabfs on user login. + ## Caching To reduce the number of calls to the Gitlab api and improve the responsiveness of the filesystem, `gitlabfs` will cache the content of the group in memory. If a group or project is renamed, created or deleted from Gitlab, these change will not appear in the filesystem. To force `gitlabfs` to refresh its cache, use `touch .refresh` in the folder to refresh to force `gitlabfs` to query Gitlab for the list of groups and projects again. diff --git a/contrib/systemd/README.md b/contrib/systemd/README.md new file mode 100644 index 0000000..a3ea9bc --- /dev/null +++ b/contrib/systemd/README.md @@ -0,0 +1,11 @@ +This unit file allows you to automatically start gitlabfs as a systemd unit. + +## Install +1. Install gitlabfs using `go get` +2. Copy **gitlabfs@.service** into **~/.config/systemd/user**. Create the folder if it does not exists. +3. Reload systemd: `systemctl --user daemon-reload` + +## Usage +1. Create your gitlabfs config file in **~/.config/gitlabfs** eg: **~/.config/gitlabfs/gitlab.com.yaml**. Make sure the config file name ends with **.yaml** and a mountpoint is configured in the file. +2. Start your service with `systemctl --user start gitlabfs@.service`. eg: `systemctl --user start gitlabfs@gitlab.com.service`. Omit the **.yaml** in the name of the service. +3. Enable your service start on login with `systemctl --user enable gitlabfs@.service`. eg: `systemctl --user enable gitlabfs@gitlab.com.service` diff --git a/contrib/systemd/gitlabfs@.service b/contrib/systemd/gitlabfs@.service new file mode 100644 index 0000000..0e8cdc4 --- /dev/null +++ b/contrib/systemd/gitlabfs@.service @@ -0,0 +1,9 @@ +[Unit] +Description=FUSE filesystem for gitlab groups and projects (%i) +After=network-online.target + +[Service] +ExecStart=%h/go/bin/gitlabfs -config %E/gitlabfs/%i.yaml + +[Install] +WantedBy=network-online.target \ No newline at end of file