无法在启动时运行 Dropbox 守护程序

无法在启动时运行 Dropbox 守护程序

我按照以下说明在 ubuntu 16.04 上安装了 dropboxhttp://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment

使用 pyton 脚本启动服务器并链接到我的 dropbox 帐户。一切正常,我可以按预期同步我的文件。

fmf@kodi:~$ ls -al |grep dropbox-dist
drwxr-xr-x  3 fmf  fmf       4096 Aug  1 18:05 .dropbox-dist
fmf@kodi:~$

fmf@kodi:~$ ll .dropbox-dist/
total 20
drwxr-xr-x  3 fmf fmf 4096 Aug  1 18:05 ./
drwxr-xr-x 31 fmf fmf 4096 Aug  3 10:27 ../
-rwxr-xr-x  1 fmf fmf   99 Aug  1 18:05 dropboxd*
drwxr-xr-x  9 fmf fmf 4096 Aug  1 18:05 dropbox-lnx.x86_64-8.3.16/
-rw-r--r--  1 fmf fmf    6 Aug  1 18:05 VERSION
fmf@kodi:~$

fmf@kodi:~$ ./dropbox.py start
Starting Dropbox...Done!
fmf@kodi:~$ ./dropbox.py status
Up to date
fmf@kodi:~$

现在我想让它在启动时运行,因此在同一个网页中,我找到了创建 /etc/init.d/dropbox 并将 USER 设置为我的用户的说明。我运行 update-rc.d 并尝试重新启动。重新启动后,守护程序未运行。

所以我检查了一下:

fmf@kodi:~$ sudo journalctl -u dropbox
-- Logs begin at Wed 2016-08-03 10:25:51 CEST, end at Wed 2016-08-03 10:36:35 CEST. --
Aug 03 10:26:37 kodi systemd[1]: Starting LSB: dropbox service...
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Control process exited, code=exited status=203
Aug 03 10:26:37 kodi systemd[1]: Failed to start LSB: dropbox service.
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Unit entered failed state.
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Failed with result 'exit-code'.
fmf@kodi:~$

fmf@kodi:~$ systemctl status dropbox.service -l
● dropbox.service - LSB: dropbox service
   Loaded: loaded (/etc/init.d/dropbox; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2016-08-03 10:26:37 CEST; 10min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3147 ExecStart=/etc/init.d/dropbox start (code=exited, status=203/EXEC)

Aug 03 10:26:37 kodi systemd[1]: Starting LSB: dropbox service...
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Control process exited, code=exited status=203
Aug 03 10:26:37 kodi systemd[1]: Failed to start LSB: dropbox service.
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Unit entered failed state.
Aug 03 10:26:37 kodi systemd[1]: dropbox.service: Failed with result 'exit-code'.
fmf@kodi:~$

我究竟做错了什么?

答案1

我终于设法让 dropbox 在启动时启动。我发现 ubuntu 16.04 使用 systemd,所以我为 dropbox 编写了一个单元配置文件:

fmf@kodi:~$ cat /etc/systemd/system/dropbox.service
[Unit]
Description=Dropbox Service
After=network.target

[Service]
ExecStart=/bin/sh -c '/usr/local/bin/dropbox start'
ExecStop=/bin/sh -c '/usr/local/bin/dropbox stop'
PIDFile=${HOME}/.dropbox/dropbox.pid
User=fmf
Group=fmf
Type=forking
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

[Install]
WantedBy=multi-user.target
fmf@kodi:~$

然后我制作了一个链接到官方的python脚本来控制dropbox:

fmf@kodi:~$ sudo ln -sf /home/fmf/dropbox.py /usr/local/bin/dropbox

并启用服务:

fmf@kodi:~$ sudo systemctl enable dropbox.service

重启后,Dropbox 即可按预期运行。

相关内容