Skip to content

Instantly share code, notes, and snippets.

@sentience
Forked from Detavern/README.md
Last active January 19, 2025 09:47
Show Gist options
  • Save sentience/b034ef703e6a373556ed793b2261dbe7 to your computer and use it in GitHub Desktop.
Save sentience/b034ef703e6a373556ed793b2261dbe7 to your computer and use it in GitHub Desktop.
MEGAcmd startup on Synology DSM

Last verified on Synology DSM 7.0.1.

Prerequisites

  • install MEGAcmd package in DSM package center
  • enable user home service (Control Panel → User & Group → Advanced → User Home)
  • set up MEGAcmd so you can run mega-cmd-server from your Synology terminal prompt and see the server start (then use Ctrl-C to stop it)

Set up sysctld service for MEGAcmd server

  • Edit the provided mega-cmd-server.service file to replace username (in User and WorkingDirectory) with your Synology user name
  • Place the file in /etc/systemd/system (e.g. sudo mv mega-cmd-server.service /etc/systemd/system)
  • Make sure the file is owned by the root user (e.g. sudo chown root:root /etc/systemd/system/mega-cmd-server.service)
  • Reload your systemd daemon files: sudo systemctl daemon-reload
  • Start the service: sudo systemctl start mega-cmd-server
  • Verify the server is running by checking its status and log output: sudo systemctl status mega-cmd-server
  • Enable the service to be started automatically at startup: sudo systemctl enable mega-cmd-server

Reboot to check if it works. Enjoy!

[Unit]
Description=MEGAcmd server
After=syslog.target network-online.target
AssertFileIsExecutable=/usr/local/bin/mega-cmd-server
[Service]
User=username
Group=users
Type=simple
WorkingDirectory=/var/services/homes/username
ExecStart=/usr/local/bin/mega-cmd-server
Restart=always
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mega-cmd-server
[Install]
WantedBy=multi-user.target
@apriliars3
Copy link

Works with DSM 7.2.2? Thanks

@Scel17
Copy link

Scel17 commented Jan 19, 2025

To my experience it works on DSM 7.2.2.

However my NAS mounted /var/packages (and thus /usr/local/bin) with noexec, causing the AssertFileIsExecutable check in the systemd unit to fail. My fix was to comment out the AssertFileIsExecutable=/usr/local/bin/mega-cmd-server line in /etc/systemd/system/mega-cmd-server.service.

After that the sync started properly however I received some errors about missing jid-files:

<user>/.megaCmd/jid'): sysstat() failed: error code: 0: Success
<user>/.megaCmd/apiFolder_0/jid'): sysstat() failed:...r directory
<user>/.megaCmd/apiFolder_1/jid'): sysstat() failed:...r directory
<user>/.megaCmd/apiFolder_2/jid'): sysstat() failed:...r directory
<user>/.megaCmd/apiFolder_3/jid'): sysstat() failed:...r directory
<user>/.megaCmd/apiFolder_4/jid'): sysstat() failed:...r directory

Although this seems not to be an issue in regard of the sync, I added the missing files manually

touch /var/services/homes/<user>/.megaCmd/jid
touch /var/services/homes/<user>/.megaCmd/apiFolder_0/jid
touch /var/services/homes/<user>/.megaCmd/apiFolder_1/jid
touch /var/services/homes/<user>/.megaCmd/apiFolder_2/jid
touch /var/services/homes/<user>/.megaCmd/apiFolder_3/jid
touch /var/services/homes/<user>/.megaCmd/apiFolder_4/jid

I'm sure there are more elegant ways to solve this, but I'm not a Linux pro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment