I started to setup a home server.
I'm studying to solve problem regarding systemD to start aria2c as a daemon (it's a download manager). This would give a managed way to get files downloaded, avoid overcrowded situation.
I found a script for aria2@ service
[Unit] Description=aria2 Service After=network.target [Service] Type=forking User=%i WorkingDirectory=/home/%i Environment=VAR=/var/%i ExecStart=/usr/bin/aria2c --conf-path=/home/%i/.aria2/aria2.conf [Install] WantedBy=multi-user.target
If I start like # systemctl start email@example.com it will report
lug 08 16:00:02 Desktop systemd: Starting aria2 Service... lug 08 16:00:02 Desktop aria2c: Configuration file /home/aria2/.aria2/aria2.conf is not found. lug 08 16:00:02 Desktop systemd: aria2.service: control process exited, code=exited status=1 lug 08 16:00:02 Desktop systemd: Failed to start aria2 Service. lug 08 16:00:02 Desktop systemd: Unit aria2.service entered failed state.
The Configuration file /home/aria2/.aria2/aria2.conf is set as 644.
Maybe I should change the config file position or maybe I should assign the startup to nobody user.
Last edited by TheSaint (2013-07-15 03:06:55)
Are owner and permissions set correctly for all components in the config path?
PS: When you get it working, I know a useful ui: https://github.com/ziahamza/webui-aria2
I'm already using it. So every family member can paste uri's to that point.
Double check the permissions of the directories forming the path to the configuration file (/home, /home/aria2, /home/aria2/.aria2) and be sure that the 'aria2' user can navigate them (ie, has read and execute permissions).
To the optimist, the glass is half full.
To the pessimist, the glass if half empty.
To the engineer, the glass is twice as big as it needs to be.
For what I made myself, I tried several configurations.
I removed aria2@, I can't imagine what is related to which user, therefore I don't need a daemon for only a particular user.
I check all the possible options regarding permissions, none is good.
Now I'm trying as root user and permissions set to that. still fail.
My suspects are about the command line ExecStart=/usr/bin/aria2c --conf-path=/home/%i/.aria2/aria2.conf. Maybe dashes are not interpreted correctly. I don't kwon how to set debug to higher level, in order to catch the error.
I read some page about systemD, I don't get what is Environment statement used for.
So my point should start aria2 daemon and allow some environment variable to change time to time in case the file destinations need to be changed, without changing the aria2.service file.
I'll try a different approaching method.
Partially working as follow:
create user and group aria2 (necessary to let aria2 to write its own files)
$ sudo /usr/sbin/useradd -d /var/aria2 -m -g aria2 -s /bin/bash aria2
write the service
[Unit] Description=aria2 Service Requires=network.target After=network.target [Service] Type=forking User=aria2 Group=aria2 EnvironmentFile=/etc/conf.d/aria2.conf WorkingDirectory=/var/aria2 ExecStart=/usr/bin/aria2c $ARIACMD ExecReload=/usr/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
save it in /usr/lib/systemd/system/aria2.service
#aria2c command line options AHOME=/var/aria2 ARIASESSION=$AHOME/aria2.session ARIACMD="--enable-rpc -D --rpc-allow-origin-all --rpc-listen-all \ --max-overall-download-limit=100k --max-overall-upload-limit=5k \ --min-split-size=1M --bt-min-crypto-level=arc4"
Adjust the setting for your own taste, but don't ad options which are mentioning file paths, because otherwise the launching will fail.
Last but not least, using XML-RP Calls, adjust the remaining options. It might be the web user interface as herein mentioned
The other options are probably loaded by adding them in /var/aria2/.aria2/aria2.conf
The obstacle now is that aria2 doesn't start a boot time. I suspect still miss something that is not ready during systemD boot.
Last edited by TheSaint (2013-07-12 18:59:02)
I managed to get the daemons running. It's said daemons here, because also minidlna is on the same boat.
Once assigned a home to aria2 user, as herein mentioned, we need a service script like this:
ExecReload=/usr/bin/kill -HUP $MAINPID
NOTE: the statements marked in bold face are those that makes the difference.
In the /etc/conf.d/aria2.conf I've put:
EXTRA_ARGS="--max-overall-download-limit=100k --max-overall-upload-limit=5k \
--rpc-allow-origin-all --rpc-listen-all --min-split-size=1M \
Those words marked here in bold face aren't used, just for future testing. Then, the last step is to put your liking in /var/aria2/.aria2/aria2.conf the setting statements that aria2 will read once started (see aria2 man page for details)
For minidlna daemon, I modified like this:
ExecStart=/usr/bin/minidlnad -P /run/minidlna/minidlna.pid
NOTE: the statements marked in bold face are those that makes the difference. None about After=dhcpcd.service above. Time maybe adjusted some little, but I don't have a rush to have daemons immediately after startup.