-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
[Unit]
Description=RClone mount of users remote %i using filesystem permissions
Documentation=http://rclone.org/docs/
After=network-online.target
[Service]
Type=simple
Environment=REMOTE_NAME="%i"
Environment=REMOTE_PATH="/"
Environment=MOUNT_DIR="%h/%i"
Environment=POST_MOUNT_SCRIPT=""
Environment=RCLONE_CONF="%h/.config/rclone/rclone.conf"
#Check that rclone is installed
ExecStartPre=/usr/bin/test -x /usr/bin/rclone
#Check the mount directory
ExecStartPre=/usr/bin/test -d ${MOUNT_DIR}
ExecStartPre=/usr/bin/test -w ${MOUNT_DIR}
#Check the rclone configuration file
ExecStartPre=/usr/bin/test -f "${RCLONE_CONF}"
ExecStartPre=/usr/bin/test -r "${RCLONE_CONF}"
#Mount rclone fs
ExecStart=/usr/bin/rclone mount \
--config="${RCLONE_CONF}" \
--dir-cache-time 720h \
--poll-interval 30s \
--buffer-size 2M \
--poll-interval 30s \
--buffer-size 2M \
--vfs-cache-mode writes \
--vfs-cache-max-age 1h \
--vfs-read-chunk-size 128K \
--vfs-read-chunk-size-limit 2M \
--vfs-read-ahead 16M \
--max-read-ahead 1M \
--no-checksum \
--ignore-size \
--use-mmap \
--vfs-fast-fingerprint \
${REMOTE_NAME}:${REMOTE_PATH} ${MOUNT_DIR}
#Execute Post Mount Script if specified
ExecStartPost=/bin/sh -c ${POST_MOUNT_SCRIPT}
# Perform lazy unmount
ExecStop=/usr/bin/fusermount -zu ${MOUNT_DIR}
# Restart the service whenever rclone exists with non-zero exit code
Restart=always
RestartSec=10
[Install]
# Autostart after reboot
WantedBy=default.target