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 / init.d autostart script #152

Open
mzuenni opened this issue May 18, 2016 · 31 comments

Comments

@mzuenni
Copy link

commented May 18, 2016

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)

@acmodeu

This comment has been minimized.

Copy link

commented May 19, 2016

This is what I did, maybe it will help.

@maksis

This comment has been minimized.

Copy link
Collaborator

commented May 19, 2016

The pid file is also located inside the config directory.

#38 😉

@maksis maksis added the question label May 19, 2016

@stevenmirabito

This comment has been minimized.

Copy link

commented May 20, 2016

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.

@mzuenni

This comment has been minimized.

Copy link
Author

commented May 29, 2016

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)

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Jun 29, 2016

I tried that script and it works fine for me. Are you still having problems?

@mzuenni

This comment has been minimized.

Copy link
Author

commented Jun 30, 2016

yes it works now for me too. i dont know what caused the problem for me ^^

@KipourosV

This comment has been minimized.

Copy link

commented Mar 13, 2017

Normally I run airdcppd with the -d switch and nothing else.
How would I write the ExecStart= ??

Do I keep the -d switch?

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Mar 15, 2017

Based on the previous comments, I wouldn't keep that switch

@KipourosV

This comment has been minimized.

Copy link

commented Mar 15, 2017

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...

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Mar 15, 2017

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.

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Mar 23, 2017

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.

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

Could you paste the full script that you are using?

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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?

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

Can you find anything useful from /var/log/syslog?

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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.

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

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?)

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

Are you able to try running the app as the other user without using systemd to see if it works?

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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.

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

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++/?

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

Can run the app with the wanted user and group from terminal by using the runuser command?

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

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.

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

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

@ghost

This comment has been minimized.

Copy link

commented Apr 17, 2017

Or is it bad ide too have it as a root user?

@maksis

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2017

It means that you are expected to run the command as root

@ghost

This comment has been minimized.

Copy link

commented Apr 20, 2017

Hi i got it to work. I think the problem was that i encrypted the home dir. :P Thx for the help

@Kcchouette

This comment has been minimized.

Copy link
Contributor

commented May 7, 2017

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/

@maksis maksis added the examples label May 16, 2017

@KipourosV

This comment has been minimized.

Copy link

commented Mar 22, 2018

[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.

@cirojr82

This comment has been minimized.

Copy link

commented Aug 4, 2018

I'm not SO pro as you guys are...I just set it in CRONTAB to after every boot run airdc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.