Ask Your Question
1

Autostart dropbox daemon with Systemd

asked 2017-04-17 14:17:30 -0600

GeorgiY gravatar image

I have installed headless dropbox as described here

Also downloaded the Python management script and put it in /usr/local/lib as /usr/local/bin/dropbox

Created the following configuration file in my home directory - ~/.config/systemd/user/dropbox.service The content of the service is here - https://pastebin.com/uY7YiH0n

Then I enabled the service and started it and everything is fine.

The problem appeared when I reboot the machine and the service was not started.

systenctl --user status dropbox.service returns

● dropbox.service - Dropbox deamon Loaded: loaded (/home/georgi/.config/systemd/user/dropbox.service; enabled; vendor preset: enabled) Active: inactive (dead)

journalctl --user-unit dropbox.daemon returns https://pastebin.com/TjsfZK6x

I have no clue how to make the daemon start

edit retag flag offensive close merge delete

Comments

Is it possible, that after starting /usr/local/bin/dropboxd, the daemon detaches? If yes, try to make it not detach (see --help or man page). If you cannot stop the daemon from detaching, try changing the Type= option, e.g. to forking. See man systemd.service for details.

genodeftest gravatar imagegenodeftest ( 2017-04-17 16:17:55 -0600 )edit

thanks - it wasn't the type but rather the initial configuration and target. Check my answer.

GeorgiY gravatar imageGeorgiY ( 2017-04-18 13:15:02 -0600 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2017-04-18 13:13:30 -0600

GeorgiY gravatar image

Just managed to start the service. There two things to be changed in the initial configuration:

First - Enable auto start systemd for user:

sudo loginctl enable-linger username

Second - Change the target in the configuration - there is no multi-user or network target for systemd in user mode. To list the available targets use the following command:

systemctl --user list-units -t target

The target should be changed for the After= in the [Unit] section and WantedBy= [Install].

edit flag offensive delete link more
0

answered 2018-05-03 20:48:51 -0600

FeRDNYC gravatar image

In my experience this won't do the right thing, at least if you only want Dropbox to run during user sessions (without enabling linger, which keeps your systemd user session running even before and after you log out).

If you do want dropbox to run only at login, and be terminated upon logout, better to use this unit file:

[Unit]
Description=Dropbox Network Storage Daemon
After=graphical-session.target

[Service]
Type=forking
PIDFile=%h/.dropbox/dropbox.pid
ExecStart=/usr/bin/dropbox start
ExecStop=/usr/bin/dropbox stop

[Install]
WantedBy=default.target

The important change is to give it the location of dropbox's PIDFile= within your home directory, so that systemd can monitor the true dropbox process (${HOME}/.dropbox-dist/dropbox-lnx.x86_64-49.3.66/dropbox_py3 on my system, currently) while it's running, as well as confirm that it's correctly responded to start/stop commands.

Also, After=graphical-session.target ensures that it will only be started after Gnome Shell is running.

With this unit file installed and enabled, and dropbox.service started, systemd properly monitors the process and can manage it correctly:

$ systemctl --user --full --no-pager status dropbox.service
● dropbox.service - Dropbox Network Storage Daemon
   Loaded: loaded (XXXXXXXX/dropbox.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-05-03 21:35:41 EDT; 9min ago
  Process: 14805 ExecStart=/usr/bin/dropbox start (code=exited, status=0/SUCCESS)
 Main PID: 14889 (dropbox_py3)
   CGroup: /user.slice/user-1000.slice/user@1000.service/dropbox.service
           └─14889 /home/XXXXXXX/.dropbox-dist/dropbox-lnx.x86_64-49.3.66/dropbox_py3 /py3 /newerversion

May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: setting program path '/home/XXXXXXX/.dropbox-dist/dropbox-lnx.x86_64-49.3.66/dropbox_py3'
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: setting home path '/home/XXXXXXX/.dropbox-dist/dropbox-lnx.x86_64-49.3.66'
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: setting python path '/home/XXXXXXX/.dropbox-dist/dropbox-lnx.x86_64-49.3.66:/home/XXXXXXX/.dropbox-dist/dropbox-lnx.x86_64-49.3.66/python-packages-35.zip'
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: python initialized
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: running dropbox
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: setting args
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: applying overrides
May 03 21:35:41 HOSTNAME dropbox[14805]: dropbox: running main script
May 03 21:35:41 HOSTNAME dropbox[14805]: Done!
May 03 21:35:41 HOSTNAME systemd[1690]: Started Dropbox Network Storage Daemon.
edit flag offensive delete link more

Comments

Thanks, this is good. I would add: Restart=always. That solved a problem I had of Dropbox stopping for no apparent reason.

I'd also add that: the dropbox.service file can be created using:

systemctl edit --user --full --force dropbox.service

The --fulloption was needed due to https://github.com/systemd/systemd/is...

Robin gravatar imageRobin ( 2018-08-31 21:01:55 -0600 )edit

Hello,

how would you change the setup so that it starts the dropbox daemon for multiple users as soon as the machine comes up, with no need for any one of them to log in? Or is that not possible? I would like to use my workstation (brand new to Fedora) as the dropbox server for another Linux server, which is no longer dropbox compatible. Thanks!

hfrenzel gravatar imagehfrenzel ( 2018-10-19 16:50:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-04-17 14:17:30 -0600

Seen: 987 times

Last updated: May 03