xybu / onedrived-dev

A Microsoft OneDrive client for Linux, written in Python3.
https://github.com/xybu/onedrived-dev
MIT License
706 stars 78 forks source link

systemd service #47

Open olegTarassov opened 7 years ago

olegTarassov commented 7 years ago

Unable to create a systemd service file.

Was there someone who was able to create on on RedHat or Fedora OS?

Thanks,

delvers commented 7 years ago

It seems no so easy to configure because onedrived needs access to the keyring. It looks like he couldn't find the keyring backend:

Jun 17 15:27:12 david-xps13 systemd[1]: Started A Microsoft OneDrive client for Linux, written in Python3..
Jun 17 15:27:13 david-xps13 onedrived[13067]: Starting onedrived ... OK
Jun 17 15:27:13 david-xps13 onedrived[13067]: [2017-06-17 15:27:13,224] ERROR: MainThread: Error loading session: No recommended backend was available. Install the keyrings.alt package if you want to use the non-recommended backends. See README.rst for details.. Try refreshing token.
Jun 17 15:27:13 david-xps13 python3[13074]: detected unhandled Python exception in '/home/david/.local/bin/onedrived'
Jun 17 15:27:14 david-xps13 onedrived[13067]: Traceback (most recent call last):
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_auth.py", line 23, in get_authenticator_and_drives
Jun 17 15:27:14 david-xps13 onedrived[13067]:     authenticator.load_session(key=od_api_session.get_keyring_key(account_id))
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_auth.py", line 98, in load_session
Jun 17 15:27:14 david-xps13 onedrived[13067]:     self.client.auth_provider.load_session(**args)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrivesdk/auth_provider.py", line 323, in load_session
Jun 17 15:27:14 david-xps13 onedrived[13067]:     self._session = self._session_type.load_session(**load_session_kwargs)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_api_session.py", line 40, in load_session
Jun 17 15:27:14 david-xps13 onedrived[13067]:     saved_data = keyring.get_password(OneDriveAPISession.KEYRING_SERVICE_NAME, load_session_kwargs[keyarg])
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/keyring/core.py", line 41, in get_password
Jun 17 15:27:14 david-xps13 onedrived[13067]:     return _keyring_backend.get_password(service_name, username)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/keyring/backends/fail.py", line 23, in get_password
Jun 17 15:27:14 david-xps13 onedrived[13067]:     raise RuntimeError(msg)
Jun 17 15:27:14 david-xps13 onedrived[13067]: RuntimeError: No recommended backend was available. Install the keyrings.alt package if you want to use the non-recommended backends. See README.rst for details.
Jun 17 15:27:14 david-xps13 onedrived[13067]: During handling of the above exception, another exception occurred:
Jun 17 15:27:14 david-xps13 onedrived[13067]: Traceback (most recent call last):
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/bin/onedrived", line 11, in <module>
Jun 17 15:27:14 david-xps13 onedrived[13067]:     load_entry_point('onedrived==2.0.0', 'console_scripts', 'onedrived')()
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/usr/lib/python3.5/site-packages/click/core.py", line 722, in __call__
Jun 17 15:27:14 david-xps13 onedrived[13067]:     return self.main(*args, **kwargs)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/usr/lib/python3.5/site-packages/click/core.py", line 697, in main
Jun 17 15:27:14 david-xps13 onedrived[13067]:     rv = self.invoke(ctx)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/usr/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
Jun 17 15:27:14 david-xps13 onedrived[13067]:     return _process_result(sub_ctx.command.invoke(sub_ctx))
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/usr/lib/python3.5/site-packages/click/core.py", line 895, in invoke
Jun 17 15:27:14 david-xps13 onedrived[13067]:     return ctx.invoke(self.callback, **ctx.params)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/usr/lib/python3.5/site-packages/click/core.py", line 535, in invoke
Jun 17 15:27:14 david-xps13 onedrived[13067]:     return callback(*args, **kwargs)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/daemonocle/cli.py", line 57, in subcommand
Jun 17 15:27:14 david-xps13 onedrived[13067]:     daemon.do_action(name)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/daemonocle/core.py", line 608, in do_action
Jun 17 15:27:14 david-xps13 onedrived[13067]:     func()
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/daemonocle/core.py", line 477, in start
Jun 17 15:27:14 david-xps13 onedrived[13067]:     self._run()
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/daemonocle/core.py", line 399, in _run
Jun 17 15:27:14 david-xps13 onedrived[13067]:     self.worker()
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_main.py", line 195, in main
Jun 17 15:27:14 david-xps13 onedrived[13067]:     all_accounts = get_repo_table(context)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_main.py", line 101, in get_repo_table
Jun 17 15:27:14 david-xps13 onedrived[13067]:     authenticator, drives = get_authenticator_and_drives(ctx, account_id)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_auth.py", line 27, in get_authenticator_and_drives
Jun 17 15:27:14 david-xps13 onedrived[13067]:     authenticator.refresh_session(account_id)
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrived/od_auth.py", line 89, in refresh_session
Jun 17 15:27:14 david-xps13 onedrived[13067]:     self.client.auth_provider.refresh_token()
Jun 17 15:27:14 david-xps13 onedrived[13067]:   File "/home/david/.local/lib/python3.5/site-packages/onedrivesdk/auth_provider.py", line 242, in refresh_token
Jun 17 15:27:14 david-xps13 onedrived[13067]:     before refreshing token.""")
Jun 17 15:27:14 david-xps13 onedrived[13067]: RuntimeError: Session must be authenticated
Jun 17 15:27:14 david-xps13 onedrived[13067]:                 before refreshing token.
Jun 17 15:27:14 david-xps13 onedrived[13067]: [2017-06-17 15:27:14,304] DEBUG: Dummy-1: Close <_UnixSelectorEventLoop running=False closed=False debug=True>
Jun 17 15:27:14 david-xps13 onedrived[13067]: All children are gone. Parent is exiting...
Jun 17 15:27:14 david-xps13 onedrived[13081]: WARNING: onedrived is not running 

onedrived.service:

 [Unit]
Description=A Microsoft OneDrive client for Linux, written in Python3.
Documentation=https://github.com/xybu/onedrived-dev

[Service]
Environment="NGROK=/home/david/bin/ngrok"
ExecStart=/home/david/.local/bin/onedrived start --debug
ExecStop=/home/david/.local/bin/onedrived stop
WorkingDirectory=/home/david
User=david

[Install]
WantedBy=multi-user.target
andyleadbetter commented 5 years ago

Is there anyone able to answer this, it's the only issue preventing me going forward.

derrix060 commented 5 years ago

@andyleadbetter worked fine on my branch: https://github.com/derrix060/onedriveClient/issues/20#issuecomment-426891709

andyleadbetter commented 5 years ago

I think my issue is due to there being no user session to unlock the key ring, this is a headless server, and so key rings don’t work or I don’t know how to unlock them from a systemd unit