Hi, I’m looking for a way to use Aria2 daemon (runlevel 5) when osmc start but it seems than update-rc.d doesn’t work…
Sorry for my english, I speak french
Use systemd unit instead.
Thank you, I’m not abble to do this
Try this. I assume you can edit files in Linux.
- In directory
/lib/systemd/system
create a file (using sudo) calledaria2.service
:
[Unit]
Description=Aria2 a lightweight multi-protocol & multi-source command-line download utility
After=network-online.target
[Service]
User=nobody
Type=simple
ExecStart=/usr/bin/aria2 -D # You will need to find the correct name yourself
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
2 Run sudo systemctl enable aria2
3 Run sudo systemctl start aria2
No guarantees!
Edit: It looks like you need the -D flag to run aria2 as a daemon, so I’ve adjusted the code above.
Thank you, yes I can edit files, I’ll try your method but right now I’m writing the .img on the Rpi.
In the /usr/bin folder is aria2c so I’ll change the code to :
ExecStart=/usr/bin/aria2c
but, -D
is for deamon ? Where can I find the correct name ?
Manualy I can start aria2 with :
aria2c --enable-rpc --rpc-listen-all --daemon
I found something like this :
If you want aria to start when the operating system starts, it will normally be run as a daemon.
See aria2c(1) — aria2 1.37.0 documentation
As you can see -D is the same as --daemon so either is correct. You’ll need to experiment with the ExecStart line.
Unfortunately, it doesn’t works. To resume the steps :
Lighttpd :
cd /var/www/
sudo rm -r html
sudo rm index.html
sudo git clone https://github.com/ziahamza/webui-aria2 html
Aria2 :
sudo -s
apt-get install aria2
Then
cd /lib/systemd/system
touch aria2.service
nano aria2.service
Then
[Unit]
Description=Aria2
After=network-online.target
[Service]
User=nobody
Type=simple
ExecStart=/usr/bin/aria2c --enable-rpc --rpc-listen-all -D
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
after this :
systemctl enable aria2
systemctl start aria2
While I do like to help out, I know nothing about aria - and this is, after all, an OSMC forum, not an aria forum.
First, you need to see if the aria daemon is running, using the command systemctl status aria2
. Then, if running, stop it with sudo systemctl stop aria2
and amend the ExecStart line in aria2.service using the parameters from the link in your post. Experiment by adding and removing options.
Then run
sudo systemctl daemon-reload
sudo systemctl start aria2
Unfortunately, I am unable to help you with any problems beyond getting aria to start.
Thank you even if you are unable to help me with this problem
I try to add and remove but it still doesn’t work … Maybe I’ll found the right way in a aria forum …
What was the result of systemctl status aria2
?
That didn’t start correctly.
Have a look at this [Solved] SystemD, aria2 as a daemon (not smartly) / System Administration / Arch Linux Forums
I have seen this before
My solution is :
cd /home/omsc/
mkdir scripts
cd /scripts
touch aria2.sh
#!/bin/sh
aria2c --enable-rpc --rpc-listen-all --daemon
sudo chmod +x aria2c.sh
sudo chmod 777 aria2c.sh #777 is for the test
cd /etc/init.d/
sudo touch aria2c.sh
sudo chmod 777 aria2c
sudo chmod +x aria2c
#!/bin/sh
set -e
case “${1:-}” in
start) /home/osmc/scripts/aria2c.sh& ;;
*) echo "Usage: ${0:-} {start}" >&2 exit 1 ;;
Manualy I start aria2 with
/etc/init.d/aria2c start
I try to use cron to start it at the boot
crontab -e
→
@reboot sh /home/osmc/scripts/aria2c.sh
…
This works for me:
[Unit]
Description=Aria2
After=network-online.target
[Service]
Type=forking
ExecStart=/usr/bin/aria2c
[Install]
WantedBy=multi-user.target
Type=forking is the key.
Excellent info! Did you find this somewhere or was it a matter of trial and error?
One observation. For security reasons, you might try running it with User=nobody, since it’s an internet-facing application. (I’m not saying it’ll work as nobody, but if it does it offers an additional level of protection.)
Good news ! I have an other solution :
edit : for me it dosen’t works
Make a service in etc/init.d/aria2
#! /bin/sh
# /etc/init.d/aria2
### BEGIN INIT INFO
# Provides: aria2cRPC
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c RPC init script.
# Description: Starts and stops aria2 RPC services.
### END INIT INFO
RETVAL=0
case "$1" in
start)
echo -n "Starting aria2c daemon: "
umask 0000
aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2.conf
umask 0000
aria2c --daemon=true --enable-rpc --rpc-listen-all -D --conf-path=/etc/aria2.conf
RETVAL=$?
echo
;;
stop)
echo -n "Shutting down aria2c daemon: "
/usr/bin/killall aria2c
RETVAL=$?
echo
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL
sudo chmod +x aria2
sudo chmod 777 aria2
sudo /etc/init.d/aria2 start #(manualy it works fine)
sudo update-rc.d aria2 defaults Help and Support (it doesn’t work for now)
it works for me
follow 4 steps:
sudo chmod 755 /etc/init.d/aria2
sudo chmod +x /etc/init.d/aria2
su
update-rc.d aria2 defaults
Where possible you should use the systemd service definition in the post by @rern on April 1st rather than the deprecated init.d method.