Skip to content

Commit

Permalink
gsync: Add systemd service configuration | Update readme with require…
Browse files Browse the repository at this point in the history
…d steps
  • Loading branch information
Akianonymus committed Jun 25, 2020
1 parent 74ef510 commit 9cc0d4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- [Synchronisation](#synchronisation)
- [Basic Usage](#basic-usage)
- [Sync Script Custom Flags](#sync-script-custom-flags)
- [Background Sync Job](#background-sync-jobs)
- [Uninstall](#Uninstall)
- [Reporting Issues](#reporting-issues)
- [Contributing](#contributing)
Expand Down Expand Up @@ -633,6 +634,42 @@ Note: Flags that use pid number as input should be used at last, if you are not

</details>

#### Background Sync Jobs

There are basically two ways to start a background, first one we already covered in the above section.

It will indefinitely run until and unless the host machine is rebooted.

Now, a systemd service service can also be created which will start sync job after boot.

1. Install the systemd unit file `sudo cp -v gsync.service /etc/systemd/system/`

1. Open `/etc/systemd/system/gsync.service` with an editor of your choice and modify the following:

- line 7, line 10 : User and ExecStart

Change `user` to your username where gupload is installed

- line 10 : ExecStart

Change foldername to the local folder which will be synced

Add additional flags like -d for gdrive_folder, etc as per the requirements, use whatever supported by gsync

- line 11 : ExecStop

Add everything which was added in line 10 ( ExecStart ) and add --kill to the end.

e.g: If ExecStart was `ExecStart=/home/user/.google-drive-upload/bin/gsync /home/user/foldername -d drive_folder`, then ExecStop will be `ExecStart=/home/user/.google-drive-upload/bin/gsync /home/user/foldername -d drive_folder --kill`

1. Reload the systemctl daemon so it can see your new systemd unit `sudo systemctl daemon-reload`

1. Start the service `sudo systemctl start gsync`

This is same as starting a sync job with command itself as mentioned in previous section.

1. If you want the bot to automatically start on boot, run `sudo systemctl enable gsync`

## Uninstall

If you have followed the automatic method to install the script, then you can automatically uninstall the script.
Expand Down
15 changes: 15 additions & 0 deletions gsync.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=google-drive-upload synchronisation service
After=network.target

[Service]
Type=simple
User=user
Restart=always
RestartSec=1
ExecStart=/home/user/.google-drive-upload/bin/gsync /home/user/foldername -d drive_folder
ExecStop=/home/user/.google-drive-upload/bin/gsync /home/user/foldername -d drive_folder --kill

[Install]
WantedBy=multi-user.target

0 comments on commit 9cc0d4a

Please sign in to comment.