Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd service configuration issue: MEGAcmd WebDAV server not starting automatically on reboot #1025

Open
jbo-tech opened this issue Jan 28, 2025 · 4 comments

Comments

@jbo-tech
Copy link

jbo-tech commented Jan 28, 2025

Hello,

Environment

  • OS: Debian 12
  • MEGAcmd version: 1.7.0.4

Current Configuration

I want to use webdav with Megacmd automatically on reboot.
I have created a systemd service at /etc/systemd/system/mega-cmd-server.service:

[Unit]
Description=MEGAcmd systemd service
After=network.target network-online.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=on-failure
RestartSec=1
User=jbo
ExecStart=/usr/bin/mega-cmd-server
ExecStart=/usr/bin/mega-cmd-server mega-webdav '/Mini me cloud/Kids'

[Install]
WantedBy=multi-user.target

I have enabled and start the service
systemctl enable mega-cmd-server.service
systemctl start mega-cmd-server.service

$ systemctl status mega-cmd-server.service
○ mega-cmd-server.service - MEGAcmd systemd service
     Loaded: bad-setting (Reason: Unit mega-cmd-server.service has a bad unit file setting.)
     Active: inactive (dead)

Some logs:

janv. 21 16:38:26 zimaboard mega-cmd-server[47452]: Another instance of MEGAcmd Server is running. Execute with --skip-lock-check to force running (NOT RECOMMENDED)
janv. 21 16:38:32 zimaboard mega-cmd-server[47462]: Another instance of MEGAcmd Server is running. Execute with --skip-lock-check to force running (NOT RECOMMENDED)

Current Behavior

  • The mega-cmd-server service doesn't appears to start
  • The WebDAV functionality neither

Expected Behavior

Both the MEGAcmd server and WebDAV server should start automatically on system reboot

Questions

  • How can I configure the service to automatically start the WebDAV server on boot?
  • Will the WebDAV URL remain consistent across reboots to be reused?

Thank you in advance for the help.

@picaronin
Copy link

picaronin commented Jan 29, 2025

You should log in before mega-webdav

Replace this:

ExecStart=/usr/bin/mega-cmd-server
ExecStart=/usr/bin/mega-cmd-server mega-webdav '/Mini me cloud/Kids'

With this:

ExecStart=/usr/bin/mega-login USER "PASSWORD"
ExecStart=/usr/bin/mega-webdav '/Mini me cloud/Kids'

And test it.

Note: And to make sure there is no previous instance started, you could try like this:

ExecStart=/usr/bin/mega-logout
ExecStart=/usr/bin/mega-login USER "PASSWORD"
ExecStart=/usr/bin/mega-webdav '/Mini me cloud/Kids'

@jbo-tech
Copy link
Author

jbo-tech commented Jan 29, 2025

Thank you @picaronin for the answer.
I logged in before the reboot.
What I understand from your answer is that I can't keep the same session after each reboot, can I?

And i have to disable two-factor authentication.

@picaronin
Copy link

Sessions remain active unless they are expressly deactivated.
See mega-killsession --help
What is essential is to start an instance with the account you want to work with, either by providing the username and password or with the session ID.
See mega-login --help

@jbo-tech
Copy link
Author

I try to start without webdav to begin.
The service is enabled.
But i get some errors:

$ cat /home/jbo/.megaCmd/megacmdserver.log
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/jid'): sysstat() failed: error code: 2: No such file or directory
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/apiFolder_0/jid'): sysstat() failed: error code: 2: No such file or directory
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/apiFolder_1/jid'): sysstat() failed: error code: 2: No such file or directory
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/apiFolder_2/jid'): sysstat() failed: error code: 2: No such file or directory
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/apiFolder_3/jid'): sysstat() failed: error code: 2: No such file or directory
[API:err: 21:24:02] Unable to FileAccess::fopen('/home/jbo/.megaCmd/apiFolder_4/jid'): sysstat() failed: error code: 2: No such file or directory
[info: 21:24:02] Listening to petitions ... 
[info: 21:24:02] Resuming session...
[API:err: 21:24:02] Failed to open('/home/jbo/.megaCmd/jid'): error 2: No such file or directory
[API:err: 21:24:02] [MegaClient::JourneyID::resetCacheAndValues] Unable to remove local cache file
[API:err: 21:24:02] [MegaClient::JourneyID::loadValuesFromCache] Unable to load values from the local cache
[info: 21:24:02] Fetching nodes ... 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants