airdcpp-webclient
airdcpp-webclient copied to clipboard
Systemd / init.d autostart script
Hey another enhancement would be to automatically install and give the user the ability to activate a Systemd or/and init.d script. In my time i want to start it at boot time (like an apachi server) i already tried to write an Systemd script my self but nothing happens...
[Unit]
Description = airdcppd daemon
After = NetworkManager-wait-online.service network.target network-online.target
Wants = display-manager.service NetworkManager-wait-online.service network-online.target
[Service]
Type = simple
PIDFile = /var/run/airdcppd.pid
ExecStart = /usr/local/bin/airdcppd -d
[Install]
WantedBy = multi-user.target
i also tried the -c option because i dont know as which user the program start/where the configuration needs to be but even then nothing happens... (if i use the start command manually it works)
This is what I did, maybe it will help.
The pid file is also located inside the config directory.
https://github.com/airdcpp-web/airdcpp-webclient/issues/38 :wink:
This works for me:
[Unit]
Description=A peer-to-peer file sharing client with web user interface
After=network.target
[Service]
User=airdcpp
Group=media
ExecStart=/usr/local/bin/airdcppd -c=/var/lib/airdcpp
[Install]
WantedBy=multi-user.target
I'm running AirDC++ under its own user (airdcpp), so modify accordingly to suit your setup. Because the daemon doesn't fork or do anything weird, systemd will keep track of the process automatically.
hello i also tried your script but still it does nothing... my script currently looks like this:
[Unit]
Description=airdcppd daemon
After=network.target
[Service]
User=zuenni
Group=users
ExecStart=/usr/local/bin/airdcppd -c="/media/data/airdcpp/config" -web-resources="/media/data/airdcpp/webUI"
[Install]
WantedBy=multi-user.target
and the file is located at "/etc/systemd/system/airdcppd.service" then i run :
sudo systemctl enable airdcppd.service
sudo systemctl start airdcppd.service
to test it but the program doesnt start but i dont get any feedback.... (if i manually run the ExecStart line manually everything works like expected)
is there anything i should do? (its the first time i an using systemd)
I tried that script and it works fine for me. Are you still having problems?
yes it works now for me too. i dont know what caused the problem for me ^^
Normally I run airdcppd with the -d switch and nothing else. How would I write the ExecStart= ??
Do I keep the -d switch?
Based on the previous comments, I wouldn't keep that switch
There is a guide on creating the system scripts for deluge on their site. They also use the -d switch for deluge and have the switch in their scipt example...
It should be easy to test whether the option works. Have you tried to run the script? It will spam the typical console messages to syslog when not using the -d option but there are other ways to disable such output if needed.
You may get strange errors when the application is launched on system startup before network connectivity is available.
According to this article, After=network.target
is almost meaningless.
I replaced After=network.target
with After=network-online.target
and based on a few test reboots, it seemed to have fixed the issue for me.
Hi i need abit of help i cant get this to autostart. This works great
sudo systemctl enable airdcppd.service sudo systemctl start airdcppd.service
But it wont start even if i change to After=network-online.target
Could you paste the full script that you are using?
This is what i use in /etc/systemd/system/airdcppd.service
[Unit] Description=A peer-to-peer file sharing client with web user interface After=network-online.target
[Service] User=airdcpp Group=shareDC ExecStart=/usr/local/bin/airdcppd
[Install] WantedBy=multi-user.target
Im new at linux so maybe something basic i missed?
Can you find anything useful from /var/log/syslog
?
i got this that where red but dont think it have something to whit it
Apr 17 15:35:59 share kernel: [ 0.000000] Build-time adjustment of leaf fanout to 64. Apr 17 15:35:59 share kernel: [ 0.000000] RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids$
also
Apr 17 15:36:05 share airdcppd[1121]: Starting. Apr 17 15:36:05 share airdcppd[1121]: Failed to create PID file /home/airdcpp/.airdc++/airdcppd.pid$ Apr 17 15:36:05 share systemd[1]: airdcppd.service: Main process exited, code=exited, status=1/FAIL$ Apr 17 15:36:05 share systemd[1]: airdcppd.service: Unit entered failed state. Apr 17 15:36:05 share systemd[1]: airdcppd.service: Failed with result 'exit-code'. Apr 17 15:36:06 share iscsid: iSCSI daemon with pid=1131 started! Apr 17 15:36:08 share systemd[1]: Created slice User Slice of airdcpp. Apr 17 15:36:08 share systemd[1]: Starting User Manager for UID 1001... Apr 17 15:36:08 share systemd[1]: Started Session 1 of user airdcpp.
Apr 17 15:36:05 share airdcppd[1121]: Failed to create PID file /home/airdcpp/.airdc++/airdcppd.pid$
That very much explains it. You should check the permissions of the directory /home/airdcpp/.airdc++/
and its content (is the directory owned by a different user?)
hmm det owner is airdcpp but should it be that i ecryptfs the home dir :P and the grp is airdcpp and shareDC but the user airdcpp is member in both
Are you able to try running the app as the other user without using systemd to see if it works?
yep systemctl start, stop and status works thats why i dont get it. Dont have other path to config. Been looking for it in the airdc++ folder and web.
yep systemctl start, stop and status works thats why i dont get it.
systemctl won't detect such permission issues. What's the output of ls -la /home/airdcpp/.airdc++/
?
airdcpp@share:~/.airdc++$ ls -la /home/airdcpp/.airdc++/ total 4748 drwxrwxr-x 10 airdcpp airdcpp 4096 Apr 17 17:35 . drwx------ 7 airdcpp airdcpp 4096 Apr 17 15:37 .. -rw-r--r-- 1 airdcpp shareDC 101 Apr 17 15:35 ADLSearch.xml drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 15 22:03 Bundles drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 15 22:03 Certificates -rw-r--r-- 1 airdcpp shareDC 3174 Apr 17 15:35 DCPlusPlus.xml -rw-r--r-- 1 airdcpp shareDC 1183 Apr 17 13:32 Favorites.xml -rw-r--r-- 1 airdcpp airdcpp 1183 Apr 17 16:48 Favorites.xml.bak drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 17 16:48 FileIndex drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 15 22:03 FileLists -rw-rw-r-- 1 airdcpp airdcpp 1082230 Apr 15 22:04 GeoIP.dat -rw-rw-r-- 1 airdcpp airdcpp 620142 Apr 15 22:04 GeoIP.dat.gz -rw-rw-r-- 1 airdcpp airdcpp 1981979 Apr 15 22:04 GeoIPv6.dat -rw-rw-r-- 1 airdcpp airdcpp 984800 Apr 15 22:04 GeoIPv6.dat.gz drwxrwxr-x 2 airdcpp airdcpp 32768 Apr 17 17:35 HashData drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 15 22:03 HubLists drwxrwxr-x 3 airdcpp airdcpp 4096 Apr 17 00:11 Logs -rw-rw-r-- 1 airdcpp airdcpp 625 Apr 16 17:16 Recents.xml -rw-r--r-- 1 airdcpp airdcpp 0 Apr 17 16:48 RUNNING drwxrwxr-x 2 airdcpp airdcpp 4096 Apr 17 16:49 ShareCache -rw-r--r-- 1 airdcpp shareDC 317 Apr 17 15:35 WebServer.xml
Can run the app with the wanted user and group from terminal by using the runuser
command?
Apr 17 15:36:05 share airdcppd[1121]: Failed to create PID file /home/airdcpp/.airdc++/airdcppd.pid$
There's also more text on the right, that will show the exact error message.
Apr 17 16:06:33 share airdcppd[1107]: Failed to create PID file /home/airdcpp/.airdc++/airdcppd.pid: No such file or directory
but airdcpp is a root user
dont get the runuser command
airdcpp@share:/var/log$ runuser -l airdcpp -c airdcpp runuser: may not be used by non-root users
Or is it bad ide too have it as a root user?
It means that you are expected to run the command as root
Hi i got it to work. I think the problem was that i encrypted the home dir. :P Thx for the help
I'm doing a autostart using screen su --command="screen -dmS ${user}-airdcpp airdcpp" "${user}"
and a init.d script I've put in /etc/init.d/
[Unit] Description=airdcppd daemon After=network-online.target
[Service] Type=simple User=airdcppd Group=media UMask=007 PIDFile = /root/.airdc++/airdcppd.pid ExecStart = /usr/local/bin/airdcppd
Restart=on-failure
TimeoutStopSec=300
[Install] WantedBy=multi-user.target
This works for me.
FYI: The umask is the mask for permissions on files created by airdcpp (new downloads) 007 means the created files get 770.