Systemd service dependencies

Assume I have a food (the "foo" daemon -- couldn't resist) that occasionally requires access to a running mysql database server.
Can I express this somehow using systemd, so that when I say:
> systemctl start food
systemd will check first whether mysqld is running, and if not, start it?
(This is not about food or mysqld, it's a question about systemd.)
A more complex version of the same question could be bard (the bar daemon) depending on a locally running mail server, without specifying which particular one.
Thanks,
Johannes.

Ah! Thank you. I never reached that man page.
So I would have food.service Requires or Wants or BindsTo mysqld.service, and possibly also an After, so I'm sure that by the time food arrives, mysqld is ready. Great!
Add-on: now let's assume that food requires a particular MySQL configuration setting (like, say, binary logs being on). Manually, I would do this:
1. Edit MySQL config file, e.g. using perl -pi, so that the setting is on
2. If MySQL is not running, start it
3. If MySQL is running, restart it
4. Start my actual daemon
So the Wants and Requires and all that lets me elegantly deal with the case where MySQL isn't running yet. But what if it is, and MySQL needs to be restarted? Does systemd somehow support that use case as well, and I (again) didn't find the documentation for it? (If so, I'm very sorry and appreciate all pointers)
Side note: Systemd does not seem to like a "systemd restart xyz" invocation from within another systemd start invocation, so I cannot write the above four steps into a food.service script. (Apparently the "inner" systemctl invocation waits for the previous one to finish before proceeding, i.e. deadlock)

Similar Messages

  • [SOLVED] systemd service dependencies

    Hi,
    I've just setup a new arch install, using a pure systemd setup.
    I have two services, tinc and tinyproxy. In my case tinyproxy will only bind to an interface that tinc sets ups. So I have to make sure that tinyproxy startup depends on tinc. Now, I could edit the service file installed by the tinyproxy package, but I'd like to know if there is a better way to do that. With the old rc.conf sysinit I simply made sure to have the demons in the correct order and everything worked
    So, is there a better way to add custom dependencies between systemd services besides manually editing the service files?
    kind regards
    Last edited by nomenquis (2012-09-27 08:00:56)

    WorMzy wrote:Don't edit the package-provided .service file, it'll be overwritten when the package gets updated.
    Yea, that's why I was afraid / didn't want to edit them :)
    WorMzy wrote:Instead, copy it to /etc/systemd/system, and edit it there.
    There's no other dependency mechanism as far as I know.
    Ahh, didn't know that /etc/ files would override the ones provided in /usr/lib/...
    I suspected there was some simple mechanism but seem to have missed that one.
    Thanks a lot!
    kind regards

  • Systemd service to run command before stopping connman.service?

    [This is my first time creating a thread, I apoligize if there is a more suitable category]
    Hello,
    I would like to run a command at shutdown before stopping a specific service (connman). I need the command to finish before stopping connman as well.
    Is there a good way to do this? I tried searching, but it seems systemd is a bit finnicky when it comes to shutdowns.
    I'd like to achieve this without modifying connman.service (Though this would probably work for me)
    What is the best way to do this?
    Thanks,
    Jacob
    Last edited by frash23 (2014-12-21 13:59:03)

    Hi
    I'm not sure if it would work, but from logic, creating a service file for your command with an "After=" dependency to connman might do it. Assuming that systemd passes the dependencies in reverse order when shutting down...
    Plus use "ExecStop=" to make your command execute at stopping.
    You gotta try this out.
    Regards
    Edit: To test/debug you can probably simply stop connman and see if it pulls the dep (instead of shutting down completely).
    Edit2: Maybe better better use "ExecStop=" inside the connman service files. As you mentioned you copy the original service file from /usr/lib/systemd/system to /etc/systemd/system and make your modifications there. This is the correct way to modify service files.
    Or then do it with a "config" directory, analog to how it's done here: https://wiki.archlinux.org/index.php/au … al_console
    Reference 'man systemd.service':
    ExecStop=
    Commands to execute to stop the service started via ExecStart=. This argument takes
    multiple command lines, following the same scheme as described for ExecStart= above. Use of
    this setting is optional. After the commands configured in this option are run, all
    processes remaining for a service are terminated according to the KillMode= setting (see
    systemd.kill(5)). If this option is not specified, the process is terminated immediately
    when service stop is requested. Specifier and environment variable substitution is
    supported (including $MAINPID, see above).
    Evtl. make sure your links in the .wants directory reference to the correct service file. (Disable and reenable once.)
    Last edited by rebootl (2014-12-21 16:51:18)

  • Several systemd services failed on fresh installation

    Hi, I installed Arch with the latest iso a few weeks ago.
    Now I saw services failing.
    I disabled everything that refers to krb (kerberos), because I don't need it yet.
    But there are 2 failed services left, I don't know how to solve them loading. Or If it is a good idea to disable them too, because I don't know what they are for:
    mdadm.service
    systemd-journal-upload.service
    Thank you for your help.
    JD

    mdadm is for RAID. And for all systemd services, you can read the relevant man page to see what it does.
    Not a Sysadmin issue, moving to NC....

  • [SOLVED] Launching systemd service as non-root user

    I need to launch a systemd service as a non-root user. I've looked at this but I'm fairly confused. I don't have xorg or any desktop environment installed (this is a remote server I SSH into) but when I run
    systemctl --user status
    I get
    Failed to get D-Bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    What am I doing wrong?
    Last edited by gsingh93 (2013-12-01 07:29:29)

    I was going in the wrong direction. All I had to do was add 'User=username' and 'Group=groupname' in the [Service] section.

  • Getting sasc-ng to work properly with systemd service files [SOLVED]

    This thread is intended for getting the following AUR packages to work with each other with systemd service scripts:
    https://aur.archlinux.org/packages/open-sasc-ng-dkms/
    https://aur.archlinux.org/packages/open-sasc-ng/
    https://aur.archlinux.org/packages/oscam-svn/   (this is a related package as it must properly execute prior to sasc-ng)
    So my server is now on a fresh Arch install with systemd. All is well (& very fast) except I cannot get sasc-ng to function with systemd service init files. Prior to systemd the system worked fine with the rc initscripts & was very stable with the following setup:
    rc.local
    /etc/rc.d/oscam start
    sleep 15
    /etc/rc.d/sasc-ng start
    sleep 4
    /etc/rc.d/mythbackend start
    /etc/conf.d/sasc-ng.conf
    SASCNG_ARGS="-j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGDIR="/home/mythtv/logs/"
    CAMDIR="/etc/camdir"
    /etc/camdir/cardclient.conf
    camd35:localhost:15050:1/0000/0000:mythtv:mythtv
    I'll leave out the oscam stuff as that loads fine and doesn't appear to be a part of the problem
    I've tried this with the systemd service file that comes with the open-sasc-ng-dkms package and when it was not sucessful I tried a bunch of variants including using "Type=simple" ect. "Type=Forked" seems to be only option that actually tries to start the processes. I also "hardcoded" the service files for the 2 sasc-ng components to find a few issues with the EnvironmentFile variables. The log variable has been removed for now as this seems to cause a fatal error but the rest of the variables load fine now. I also tested spliting up the DVB loopback module from the sasc-ng binary but this also gives similar results as the following script stands now. Running them manually with systemctl start commands doesn't make a difference but that is not surprising. The service file I'm fiddling with now which I feel has the best potential become working is:
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng -D $SASCNG_ARGS --cam-dir=$CAMDIR
    TimeoutSec=4
    [Install]
    WantedBy=multi-user.target
    Mythbackend always runs fine (even without DTV via sasc-ng) with the following mythbackend.service:
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    oscam.service taken mostly from AUR package also seems fine. I added the TimeoutSec=15 to give time for oscam to load the SC and client protocol before moving on or else sasc-ng fails
    Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    [Install]
    WantedBy=multi-user.target
    Below is the output of the systemctl status commands. Despite the noise in the sasc-ng binary status, it is the loopback module that is " inactive (dead)" and there are no virtual DVB devices being created:
    [mythtv@server ~]$ sudo systemctl status oscam.service
    oscam.service - An Open Source Conditional Access Module software
    Loaded: loaded (/usr/lib/systemd/system/oscam.service; enabled)
    Active: active (running) since Tue, 2012-11-27 21:10:17 CET; 1min 7s ago
    Process: 338 ExecStart=/usr/bin/oscam $OSCAM_ARGS (code=exited, status=0/SUCCESS)
    Main PID: 377 (oscam)
    CGroup: name=systemd:/system/oscam.service
    ├ 377 /usr/bin/oscam -b -c /etc/oscam
    └ 378 /usr/bin/oscam -b -c /etc/oscam
    Nov 27 21:10:17 server systemd[1]: Started An Open Source Conditional Acces...e.
    [mythtv@server ~]$ sudo systemctl status loopback.service
    loopback.service - Sasc-ng DVB Loopback Module
    Loaded: loaded (/etc/systemd/system/loopback.service; enabled)
    Active: inactive (dead) since Tue, 2012-11-27 21:10:28 CET; 1min 27s ago
    Process: 907 ExecStart=/sbin/modprobe dvbloopback num_adapters=3 (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/loopback.service
    Nov 27 21:10:28 server systemd[1]: Started Sasc-ng DVB Loopback Module.
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 1min 45s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclien...nf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=...6)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded f...m!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (...2)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=92...6)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, co.../a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 2min 9s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/smartcard.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/cardslot.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/SoftCam.Key: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclient config from /etc/camdir/cardclient.conf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=921, tid=140074379712256)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded for softcam!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (pid=921, tid=140074371319552)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=921, tid=140074379712256)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, code=exited, status=255/n/a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$
    Any ideas?
    Last edited by wdirksen (2012-12-10 19:54:43)

    After some head scratching it seems to be all good now. Considering there have been no replies to this I've come to wonder if I might be the only one with this issue. I could get it working somewhat using service files but never ideal, ex. sasc-ng only using a few of the entitlements from oscam because it started too quick etc. Anyway this might help a few and I'm hoping the linux savvy who find what I'm writing here painfully newbie like or flawed will reply and educate me a bit if what's provided here needs some sharpening up:
    1) Systemd was confusing the sasc-ng binary shorthand arguments with Linux init arguments and a few were misinterpreted if they were not nested into the environment specifiers. So the -l (log) was causing problems and -b (buffer) wasn't loading. To be safe I'm using only the sasc-ng longhand specifiers from now on (two "--" and more verbose) so that they can never be confused even if safely nested in an environment parameter. That means that /etc/conf.d/sasc-ng will also need to be changed to reflect this. I also decided to simplify the LOGFILE parameter to include the whole argument syntax.
    2) Oscam.service needs to be initiated with oneshot and RemainAfterExit=yes to make sure the delay (15 seconds in my config) gets counted out before sasc-ng initiates.
    [EDIT 12/12/2012: Initially I had a second TimeoutSec=2 after ExecStart in sasc-ng.service but this had no function. Turns out that it almost always does work without this delay but not always with my setup. Adding TimeoutSec=2 to mythbackend.service prior to ExecStart command does function and makes things init more consistant]
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=simple
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng $SASCNG_ARGS --cam-dir $CAMDIR --log $LOGFILE
    [Install]
    WantedBy=multi-user.target
    /etc/conf.d/sasc-ng
    SASCNG_ARGS="--join 0:3 --join 1:4 --join 2:5 --buffer 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGFILE="/home/mythtv/logs/sasc-ng.log"
    CAMDIR="/etc/camdir"
    oscam.service
    [Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    RemainAfterExit=yes
    [Install]
    WantedBy=multi-user.target
    mythbackend.service
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    TimeoutSec=2
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    I will make the related changes to the open-sasc-ng AUR package which I currently maintain
    Last edited by wdirksen (2012-12-23 14:40:43)

  • [solved] systemd service files don't allow quotes

    Why is it not possible to use quotes in
    ExecStart=
    section of systemd service files?
    For example, I can't use service file like this
    [Unit]
    Description=Pacman mirrorlist update
    [Service]
    Type=oneshot
    ExecStart=wget -O /etc/pacman.d/mirrorlist.backup "https://www.archlinux.org/mirrorlist/?country=DE&country=NL&country=PL&protocol=http&ip_version=4" && cp /etc/pacman.d/mirrorlist.backup /etc/pacman.d/mirrorlist && reflector --verbose -l 50 -p http --sort rate --save /etc/pacman.d/mirrorlist
    because systemd will not run it because of presence of quotes:
    Feb 26 08:48:36 nanoBox systemd[1]: [/etc/systemd/system/reflector.service:7] Executable path is not absolute, ignoring: wget -O /etc/pacman.d/mirrorlist.backup "URL=http...
    Feb 26 08:48:36 nanoBox systemd[1]: reflector.service lacks both ExecStart= and ExecStop= setting. Refusing.
    I can remove quotes and then the service will run, but the URL parsed to the command will be cut in half, ie it will stop on the first "&" sign and only DE mirrors will be probed.
    Is there some way around it other than creating a separate executable file and calling it from the service? I don't want to multiply unnecessary files if there's way around it.
    Last edited by Lockheed (2015-02-26 09:37:25)

    Lockheed wrote:
    Raynman wrote:"from command line" is you feeding a (command) string to a shell. Your assumption is that systemd will treat whatever you put in ExecStart exactly the same as your shell would.
    Not "is" but "was". Disappearance of that assumption was precisely the reason of starting this thread.
    I had to read this a few times, but I think you mean it as follows. You assumed you could copy from the shell to the service file and it would work the same way. Then you got an error (about the abolute path) so that assumption "disappeared". So far so good. But you didn't exactly figure out what was different, you formed a new assumption and based your thread on that:
    "systemd service files don't allow quotes" (title)
    "Why is it not possible to use quotes in ExecStart= section of systemd service files"
    "because systemd will not run it because of presence of quotes:"
    Like frank604 says, quotes were never the issue (in fact, they are one of the few things with special meaning for both the shell and systemd), yet you still seem to think they were:
    Lockheed wrote wrote:The actual wrong assumption on my part was that this command would run without quotes as service. It does not.
    It is a shame you only quote the first part of my last reply and ignore the questions in the second part. You did almost the same thing with my reply before that and I suspect you also didn't read the man page I mentioned the first time. You basically give me the impression that you think you have it all figured out (even though you come here looking for help) and my follow-up questions aren't worth your time. That usually makes me "move along" pretty quickly, but I'm trying one last time, because even though "The service now works", I'd like to see that you actually understand why it didn't work before.
    The only thing you really answered was "Changing paths to absolute made no difference.", but that shouldn't be, so when you mentioned empirical evidence, I basically repeated the question asking for some of this evidence (as in exact error messages for one or more modified ExecStart lines).
    When I take your service file and give wget an absolute path, systemd happily executes wget, but then wget complains because it gets "&&" and "cp" and "--save" etc. as arguments. Those errors are what I see in systemctl status/journal, no longer anything about an absolute path. This is because "&&" has no special meaning. You can use semicolons (";") to separate commands instead (explained in the man page section on command lines) or multiple ExecStart lines like frank604 used (which is cleaner IMO).

  • Cannot start mpd as systemd service

    Hi all,
    I have installed mpd. If I run
    mpd
    from a terminal, then everything is normal; I can open
    a client and use mpd. However, if I try to start it as a systemd service I get errors. That is, once I do
    sudo systemctl enable mpd
    and reboot, then
    jorge@flamingo:~$ systemctl status mpd
    ● mpd.service - Music Player Daemon
    Loaded: loaded (/usr/lib/systemd/system/mpd.service; enabled)
    Active: failed (Result: signal) since Thu 2014-09-25 22:01:48 EDT; 2min 20s ago
    Main PID: 1647 (code=killed, signal=ABRT)
    Sep 25 22:01:48 flamingo mpd[1647]: ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
    Sep 25 22:01:48 flamingo mpd[1647]: ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned erro...rectory
    Sep 25 22:01:48 flamingo mpd[1647]: ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
    Sep 25 22:01:48 flamingo mpd[1647]: ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
    Sep 25 22:01:48 flamingo mpd[1647]: alsa_output: Error opening default ALSA device: No such file or directory
    Sep 25 22:01:48 flamingo mpd[1647]: output: Attempting to detect a oss audio device
    Sep 25 22:01:48 flamingo mpd[1647]: oss_output: Error opening OSS device "/dev/dsp": No such file or directory
    Sep 25 22:01:48 flamingo mpd[1647]: oss_output: Error opening OSS device "/dev/sound/dsp": No such file or directory
    Sep 25 22:01:48 flamingo mpd[1647]: output: Attempting to detect a pulse audio device
    Sep 25 22:01:48 flamingo mpd[1647]: Assertion 'm' failed at pulse/thread-mainloop.c:236, function pa_threaded_mainloo...orting.
    Hint: Some lines were ellipsized, use -l to show in full.
    or,
    jorge@flamingo:~$ sudo systemctl start mpd
    [sudo] password for jorge:
    jorge@flamingo:~$ systemctl status mpd
    ● mpd.service - Music Player Daemon
    Loaded: loaded (/usr/lib/systemd/system/mpd.service; enabled)
    Active: failed (Result: signal) since Thu 2014-09-25 22:09:13 EDT; 8s ago
    Process: 2056 ExecStart=/usr/bin/mpd --no-daemon (code=killed, signal=ABRT)
    Main PID: 2056 (code=killed, signal=ABRT)
    Sep 25 22:09:13 flamingo mpd[2056]: ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
    Sep 25 22:09:13 flamingo mpd[2056]: ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned erro...rectory
    Sep 25 22:09:13 flamingo mpd[2056]: ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
    Sep 25 22:09:13 flamingo mpd[2056]: ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
    Sep 25 22:09:13 flamingo mpd[2056]: alsa_output: Error opening default ALSA device: No such file or directory
    Sep 25 22:09:13 flamingo mpd[2056]: output: Attempting to detect a oss audio device
    Sep 25 22:09:13 flamingo mpd[2056]: oss_output: Error opening OSS device "/dev/dsp": No such file or directory
    Sep 25 22:09:13 flamingo mpd[2056]: oss_output: Error opening OSS device "/dev/sound/dsp": No such file or directory
    Sep 25 22:09:13 flamingo mpd[2056]: output: Attempting to detect a pulse audio device
    Sep 25 22:09:13 flamingo mpd[2056]: Assertion 'm' failed at pulse/thread-mainloop.c:236, function pa_threaded_mainloo...orting.
    Hint: Some lines were ellipsized, use -l to show in full.
    Here is the mpd config file:
    jorge@flamingo:~$ cat ~/.mpd/mpd.conf
    music_directory "/home/jorge/Multimedia/Audio/Music"
    playlist_directory "/home/jorge/.mpd/playlists"
    db_file "~/.mpd/mpd.db"
    log_file "~/.mpd/mpd.log"
    pid_file "~/.mpd/mpd.pid"
    state_file "~/.mpd/mpdstate"
    audio_output {
    type "alsa"
    name "MPD"
    restore_paused "yes"
    follow_inside_symlinks "no"
    Any ideas what I'm doing wrong here?
    Thanks in advance.
    Last edited by geo909 (2014-09-26 02:12:30)

    Scimmia wrote:Yeah, you're out of date. Update your system and everything should work.
    *facepalm*
    Oh dear.. An update fixed the problem indeed, thank you.
    HilmTye wrote: if you're starting mpd as a system service, then your user's config won't be used
    You're right.. I just read the wiki more carefully. Indeed, I would like to run it for my user, so systemd is not
    the best option for me. But I still have trouble.. The problem is that I can't autostart it the way it mentions
    in the wiki. My mpd files are as follows:
    jorge@flamingo:~$ ls ~/.mpd
    mpd.conf mpd.db mpd.log mpd.pid mpdstate playlists
    I tried this as per the wiki:
    jorge@flamingo:~$ cat ~/.profile
    # MPD daemon start (if no other user instance exists)
    [ ! -s ~/.mpd/mpd.pid ] && mpd
    but it didn't work. mpd was not running after reboot.
    Then I tried /etc/profile:
    jorge@flamingo:~$ cat /etc/profile
    # /etc/profile
    #Set our umask
    umask 022
    # Set our default path
    PATH="/usr/local/sbin:/usr/local/bin:/usr/bin"
    export PATH
    # Load profiles from /etc/profile.d
    if test -d /etc/profile.d/; then
    for profile in /etc/profile.d/*.sh; do
    test -r "$profile" && . "$profile"
    done
    unset profile
    fi
    # Source global bash config
    if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
    . /etc/bash.bashrc
    fi
    # Termcap is outdated, old, and crusty, kill it.
    unset TERMCAP
    # Man is much better than us at figuring this out
    unset MANPATH
    export GPODDER_HOME="/home/jorge/Applications/Application Data/gpodder"
    # MPD daemon start (if no other user instance exists)
    [ ! -s ~/.mpd/mpd.pid ] && mpd
    but it didn't work either.
    In both cases, if I try to run mpd again from the terminal, I get:
    jorge@flamingo:~$ mpd
    server_socket: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)
    and then mpd works.
    Any ideas on how to startup mpd automatically on boot without systemd?
    Last edited by geo909 (2014-09-26 04:03:15)

  • Doh! How do I make a simple systemd service...? [SOLVED]

    I've procrastinated long enough.
    I have a few symbolic links from various locations that all lead to directories in /tmp or /dev/shm.  These directories were simply created by mkdir in rc.local, and I've forgotten about it sometime ago.
    I want systemd to do something like:
    mkdir -p /tmp/foo/bar
    chmod -R o+rw /tmp/foo/bar
    everytime I start up my computer.   I used to have it all in rc.local and it's far simpler than what most people's startup scripts look like.
    I tried making this service file, but I'm doing something wrong (due to my lack of understanding, please forgive me).  It shows up as a static service.
    [Unit]
    Description=rc.local ported to systemd
    [Service]
    Type=oneshot
    ExecStart=/usr/local/bin/rc.local
    The rc.local file referenced was simply copied before initscripts were removed.  It contains the series of mkdir and chmod commands (and nothing more).
    -ak
    Last edited by akspecs (2013-02-18 03:27:43)

    cfr wrote:I *think* the way to do this is with temp files but I've never actually had to use these myself. Bound to be in the wiki, though.
    the manpage for this is tmpfiles.d (5).

  • [invalid] Run systemd service after specific device is initialized

    Hi.
    Is there any way to run systemd service only after specific device is initialized/kernel module is loaded?
    The task I'm trying to solve is applying trackpoint speed and sensitivity settings on boot in my X220.
    Service code (trackpoint.service) is quite simple
    [Unit]
    Description=Trackpoint configuration
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/conf.d/trackpoint.conf
    ExecStart=/bin/sh -c 'echo ${sensitivity} > /sys/devices/platform/i8042/serio1/serio2/sensitivity'
    ExecStart=/bin/sh -c 'echo ${speed} > /sys/devices/platform/i8042/serio1/serio2/speed'
    [Install]
    WantedBy=graphical.target
    The issue is that trackpoint.service gets executed before trackpoint device gets initialized and thus fails.
    Jun 14 23:12:10 xi sh[414]: /bin/sh: /sys/devices/platform/i8042/serio1/serio2/sensitivity: No such file or directory
    Jun 14 23:12:10 xi systemd[1]: Unit trackpoint.service entered failed state.
    Jun 14 23:12:18 xi kernel: psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
    Jun 14 23:12:18 xi kernel: input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio1/serio2/input/input13
    What have I tried already
    1. Specified systemd-modules-load in After= and Requires= directives and added psmouse module to /etc/modules-load.d
    2. Tried path activation (perhaps, I did it wrong) by creating i8042.path
    [Path]
    PathExists=/sys/devices/platform/i8042
    Unit=trackpoint.service
    However, this changed nothing.
    I don't know what else should I try.
    Please suggest solution for this.
    Thanks in advance.
    Last edited by eDio (2013-06-15 13:28:36)

    Thank you very much.
    I've finally managed this to work
    $ cat /etc/udev/rules.d/10-trackpoint.rules
    SUBSYSTEM=="input", KERNEL=="event13", ACTION=="add", RUN+="/usr/bin/trackpoint_apply"
    $ cat /etc/conf.d/trackpoint.conf
    speed=255
    sensitivity=255
    $ cat /usr/bin/trackpoint_apply
    #!/usr/bin/env sh
    . /etc/conf.d/trackpoint.conf
    /usr/bin/echo $speed > /sys/devices/platform/i8042/serio1/serio2/sensitivity
    /usr/bin/echo $sensitivity > /sys/devices/platform/i8042/serio1/serio2/speed

  • [SOLVED] A custom systemd service doesn't execute a specific command

    I have made a custom service which should set screen brightness.
    file: /etc/systemd/system/backlight100.service
    [Unit]
    Description=Set screen brightness
    [Service]
    Type=oneshot
    ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness
    ExecStart=/usr/bin/beep
    [Install]
    WantedBy=multi-user.target
    (beep is there so I can know for sure that the script runs)
    The problem is, when I run "# systemctl start backlight100.service" I can hear the beep but it doesn't change the brightness. When I run "/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness" in terminal it does change the brightness... but not when I start or restart the service.
    Here's the output of systemctl status backlight100.service after starting it
    backlight100.service - Set screen brightness
    Loaded: loaded (/etc/systemd/system/backlight100.service; enabled)
    Active: inactive (dead) since Fri 2013-04-05 20:17:32 AMT; 3min 19s ago
    Process: 27698 ExecStart=/usr/bin/beep (code=exited, status=0/SUCCESS)
    Process: 27696 ExecStart=/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness (code=exited, status=0/SUCCESS)
    Apr 05 20:17:32 work systemd[1]: Starting Set screen brightness...
    Apr 05 20:17:32 work echo[27696]: 100 > /sys/class/backlight/intel_back...ss
    Apr 05 20:17:32 work systemd[1]: Started Set screen brightness.
    What am I doing wrong here? Any help appreciated.
    Last edited by axper (2013-04-05 18:35:24)

    msthev wrote:$ man systemd.service
    ExecStart=
    Note that this setting does not directly support shell command
    lines. If shell command lines are to be used they need to be passed
    explicitly to a shell implementation of some kind. Example:
    ExecStart=/bin/sh -c 'dmesg | tac'
    Thanks, changing ExecStart line to
    ExecStart=/bin/bash -c '/bin/echo 100 > /sys/class/backlight/intel_backlight/brightness'
    solved the issue. Though I can recall seeing ExecStart lines with direct shell commands.
    Raynman wrote:
    You should look at tmpfiles.d.
    https://wiki.archlinux.org/index.php/Sy … rary_files
    I'll do that, thanks!

  • [SOLVED] Trying to write HLDS systemd service file

    Hey,
    I want to write a systemd service file for my HLDS AUR package: https://aur.archlinux.org/packages/hlds/
    My environment file looks like this:
    HLDS_USER=root
    HLDS_WORKINGDIR=/opt/hlds
    HLDS_PARAMS="-game cstrike"
    HLDS_LOGFILE=/var/log/hlds_cstrike
    The service file like this:
    After=network.target
    [Service]
    #EnvironmentFile=/etc/conf.d/hlds
    #User=${HLDS_USER}
    #WorkingDirectory=${HLDS_WORKINGDIR}
    ExecStart=/opt/hlds/hlds_run -game cstrike
    ExecStop=/bin/kill $MAINPID
    [Install]
    WantedBy=multi-user.target
    But systemd fails to start the service:
    hlds.service - Half-Life Dedicated Server
              Loaded: loaded (/usr/lib/systemd/system/hlds.service; disabled)
              Active: failed (Result: exit-code) since Thu, 2013-01-03 06:20:49 CET; 2s ago
             Process: 567 ExecStop=/bin/kill $MAINPID (code=exited, status=1/FAILURE)
             Process: 564 ExecStart=/opt/hlds/hlds_run -game cstrike (code=killed, signal=INT)
              CGroup: name=systemd:/system/hlds.service
    Jan 03 06:20:49 playground systemd[1]: Starting Half-Life Dedicated Server...
    Jan 03 06:20:49 playground systemd[1]: Started Half-Life Dedicated Server.
    Jan 03 06:20:49 playground hlds_run[564]: Invalid game type 'cstrike' sepecified.
    Jan 03 06:20:49 playground hlds_run[564]: Thu Jan  3 06:20:49 CET 2013: Server Failed
    Jan 03 06:20:49 playground kill[567]: usage: kill [ -s signal | -p ] [ -a ] pid ...
    Jan 03 06:20:49 playground kill[567]: kill -l [ signal ]
    Jan 03 06:20:49 playground systemd[1]: Unit hlds.service entered failed state
    Running
    /opt/hlds/hlds_run -game cstrike
    manually works quote well
    Someone knows how to proceed? Thanks
    Last edited by onny (2013-01-03 05:43:49)

    Solved. It didn't recognized the workingdir correctly ...

  • How to make a systemd service for a bash script with pipes?

    I haven't been able to make a successful systemd service from this script.
    The script itself works (in terminal and xdg autostart), but systemd doesn't run anything after the first pipe (neither sed nor spd-say execute).
    Here's my service:
    [Unit]
    Description=Speak kernel and userspace messages
    [Service]
    Type=simple
    ExecStart=/usr/local/sbin/dmesg-speak
    [Install]
    WantedBy=multi-user.target
    Systemd says the script starts successfully, but only dmesg is started; it's output is not piped through sed or spd-say.
    I've also tried Type=forking without much success.
    Is there something I can do other than switching to sysv-init?
    Do I need IgnoreSIGPIPE=false?
    Last edited by quequotion (2015-02-12 17:07:21)

    fsckd wrote:The linked script appears to lack a hashbang. No hashbang = arbitrary interpretor.
    Yeah, that should probably be there. Since last post I've employed /usr/bin/bash in the service and added a hasbang, but sdp-say still does not run as a systemd service.
    I didn't test either option individually; the key seems to be finding an audio output accessible before user login. I am not certain:
    ccoffey wrote:If a pulseaudio session exists at all
    I am curious to try this:
    ccoffey wrote:run pulseaudio and dbus via XVFB.
    Setting DISPLAY as root would then allow you play audio.
    Still, it seems to me that ALSA would be available at some stage during boot, as is speech-dispatcher (for working with speakup!). If espeak were configured to play audio for root to ALSA, there would be a sound outlet for it (espeak can be used in pipeline mode without speech-dispatcher if need be), and pulseaudio would be probably be OK with that whenever it got around to starting (audio passed through alsa gets piped through, regardless of its source right?).
    I have tried the script with espeak instead of spd-say without success.
    Last edited by quequotion (2015-02-26 03:06:24)

  • [SOLVED] systemd : services failing to start on boot

    I have removed sysvinit completely as per the systemd wiki pages.
    I don't usually re-boot very often so I'm not sure exactly when the problem started.
    I only noticed this problem about 4 or 5 days ago.
    But now whenever I reboot my machine 2 services fail consistently.
    adsl.service
    colord.service
    They both start flawlessly once I can log in at a console.
    I'm using kde and in the last couple of days, while trying to fix my problem, the kdm service has failed to start a couple of times too - saying there is no X server.
    Before switching to systemd I never had any of these problems using the old rc.conf method. My DAEMONS array had the adsl service start after the network service.
    I need some help and advice to find out what is causing the problem and how to fix it.
    Last edited by bhrgunatha (2012-10-25 05:44:22)

    Thanks. That seems plausible. So I've been snooping at the journal.
    journalctl -ab
    Oct 25 17:06:13 starch systemd[1]: Started Trigger Flushing of Journal to Persistent Storage.
    Oct 25 17:06:14 starch systemd[1]: Started Recreate Volatile Files and Directories.
    Oct 25 17:06:14 starch systemd[1]: Starting System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Reached target System Initialization.
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Listening on CUPS Printing Service Sockets.
    Oct 25 17:06:14 starch systemd[1]: Starting Console System Startup Logging...
    Oct 25 17:06:14 starch systemd[1]: Starting Restore Sound Card State...
    Oct 25 17:06:14 starch systemd[1]: Starting CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Started CUPS Printer Service Spool.
    Oct 25 17:06:14 starch systemd[1]: Starting D-Bus System Message Bus Socket.
    Oct 25 17:06:16 starch ntpd[381]: ntpd [email protected] Tue Aug 21 15:06:24 UTC 2012 (1)
    Oct 25 17:06:16 starch ntpd[413]: proto: precision = 0.156 usec
    Oct 25 17:06:17 starch ntpd[413]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
    Oct 25 17:06:17 starch ntpd[413]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen and drop on 1 v6wildcard :: UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 2 lo 127.0.0.1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: Listen normally on 3 lo ::1 UDP 123
    Oct 25 17:06:18 starch ntpd[413]: peers refreshed
    Oct 25 17:06:18 starch ntpd[413]: Listening on routing socket on fd #20 for interface updates
    Oct 25 17:06:18 starch dbus[384]: [system] Activating systemd to hand-off: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:06:18 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.systemd1'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:03 starch dbus[384]: [system] Activating via systemd: service name='org.freedesktop.ColorManager' unit='colord.service'
    Oct 25 17:07:03 starch dbus[384]: [system] Successfully activated service 'org.freedesktop.ColorManager'
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:03 starch systemd[1]: Starting Manage, Install and Generate Color Profiles...
    Oct 25 17:07:03 starch systemd[1]: Started Manage, Install and Generate Color Profiles.
    Oct 25 17:07:03 starch systemd[1]: colord.service: main process exited, code=killed, status=6
    Oct 25 17:07:03 starch systemd[1]: Unit colord.service entered failed state.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link down
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    Oct 25 17:07:04 starch kernel: PPP generic driver version 2.4.2
    Oct 25 17:07:04 starch cupsd[380]: Unknown directive DefaultAuthType on line 26.
    Oct 25 17:07:04 starch kernel: r8169 0000:02:00.0: eth0: link up
    Oct 25 17:07:04 starch kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Oct 25 17:07:04 starch pppoe-start[382]: TIMED OUT
    Oct 25 17:07:04 starch kernel: NET: Registered protocol family 24
    Oct 25 17:07:04 starch pppoe-start[382]: /usr/sbin/pppoe-start: line 193: 394 Terminated $CONNECT "$@" > /dev/null 2>&1
    That seems to confirm your theory.
    eth0 link is not up when attempting to start colord and adsl
    So the $64,000 question:
    How do I defer them until eth0 is ready?
    Or how can I force the eth0 link to be up before colord or adsl try to use it?
    Last edited by bhrgunatha (2012-10-25 01:33:36)

  • [SOLVED] Help with systemd .service script

    Hello,
    I have been using ArchLinux (ARM version) on some “plug computers” for over a year and love it.  Recently I forced myself to move to systemd by upgrading all my computers from scratch.  I migrated all my applications and learned new ways of doing things but am having trouble with one last migration.  I run a c++ communication program that monitors a TCP port for traffic.  In the past I started this program (daemon) from an entry in rc.conf.  I have read all I can about systemd’s new approach to starting daemons (https://wiki.archlinux.org/index.php/Systemd and https://wiki.archlinux.org/index.php/Systemd/Services)
    So far I created what I thought is the correct systemd .service file listed below.
    [Unit]
    Description=EQBCS
    After=network.target
    [Service]
    Type=simple
    ExecStart=/home/public/EQBCS/eqbcs -p 12947 -d &> /dev/null
    [Install]
    WantedBy=multi-user.target
    I put this file in /usr/lib/systemd/system/eqbcs.service.  I then ran the following commands in the following order:
    systemctl daemon-reload
    systemctl enable eqbcs.service (created a link in /etc/systemd/system/multi-user.target.wants)
    systemctl start eqbcs.service
    Here is output from systemctl (status)
    eqbcs.service                                 loaded failed failed    EQBCS
    I thought this would start the service but no luck.  I also thought maybe a reboot would work but no luck.  I verified I can start the daemon manually if I run /home/public/EQBCS/eqbcs -p 12947 -d &> /dev/null from the command line.
    I think I am close, but after several hours of looking at examples of .service files and other posts, I am at a loss.  I am not one of those types who posts a question without taking the time to read the wealth of information on these boards, but I am truly out of ideas and can’t figure out what to do next.  I sincerely could use some help/advice.
    Last edited by calzon65 (2013-06-01 21:18:20)

    Thank you for the suggestions, I believe I am getting closer to success. When I run systemctl start eqbcs.servcie it starts the service but the only way I can get out of systemctl is to ^c out.
    Here is my current .service file:
    [Unit]
    Description=EQBCS
    After=network.target
    [Service]
    ExecStart=/home/public/EQBCS/eqbcs -p 12947
    Type=forking
    [Install]
    WantedBy=multi-user.target
    Output from systemctl status eqbcs:
    eqbcs.service - EQBCS
       Loaded: loaded (/etc/systemd/system/eqbcs.service; enabled)
       Active: failed (Result: timeout) since Sat 2013-06-01 12:48:43 PDT; 2min 11s ago
      Process: 427 ExecStart=/home/public/EQBCS/eqbcs -p 12947 (code=killed, signal=TERM)
    Main PID: 396 (code=killed, signal=KILL)
       CGroup: name=systemd:/system/eqbcs.service
    Jun 01 12:47:13 alarm systemd[1]: Starting EQBCS...
    Jun 01 12:47:13 alarm eqbcs[427]: WARNING: Running as root NOT recommended.
    Jun 01 12:47:13 alarm eqbcs[427]: EQ Box Chat Server 10.12.18
    Jun 01 12:47:13 alarm eqbcs[427]: Waiting for connections on port: 12947...
    Jun 01 12:48:43 alarm systemd[1]: eqbcs.service operation timed out. Terminating.
    Jun 01 12:48:43 alarm systemd[1]: Failed to start EQBCS.
    Jun 01 12:48:43 alarm systemd[1]: Unit eqbcs.service entered failed state.
    Are there any other suggestions for settings in my .service file?

Maybe you are looking for

  • Can we have a query like

    Hi friends, I would like to know if this could be possible we have some 20 business like bus_ind, bus_usa, bus_jap... I have to do the below query each of the business for bus_ind SELECT COUNT(*) FROM bus_ind WHERE workdate BETWEEN TO_DATE('01/01/200

  • I backed my pictures from my phone to my iphoto and my iphoto stopped working

    It takes like 5 minutes to load and nothing happens it just says that there was a problem.

  • Aspect ratio changing on export

    Hi all. I'm working at a company producing content for a rolling news channel. We've just started editing using Premiere Pro CC and exporting via Dalet Xtend. Much of the archive footage is 4:3 and has to be conformed and scaled up; however, after ex

  • Jakarta Datagrid Taglibs and Servlet 2.4

    Dear All, Please help me with this situation we would require to have this Jakarta Datagrid taglib (with the servlet 2.2 support) in my web application, but my web-applications uses servlet 2.4 version. If we change my servlet version to 2.2 for the

  • Would appreciate some help concerning Bluetooth...

    I have just recently bought a Bluetooth USB for my laptop so I can easily transfer files to and from my BlackBerry and Laptop. My partners Samsung Tocco connected and transfered files fine. My BlackBerry finds the Laptop's Bluetooth and enter both pa