Systemd service, make it response to network changes

I'm using netctl and I'm trying to make my own service. The idea is that my service is restarted if I do a
systemctl restart netctl@net0
or if I unplug and plug again the network cable with the service netctl-ifplugd@net0 enabled. First case is easy, but I don't find a solution for both cases, any suggestions?

I wrote service like this:
[Unit]
Description=Service on interface %I
Wants=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/project/my_script.sh start %I
ExecStop=/usr/lib/project/my_script.sh stop %I
[Install]
WantedBy=multi-user.target
What I want is restart this service if I do a restart of the network, with 'netctl restart mynetwork' or automatically via the 'netctl-ifplugd@mynetwork' service. Ideally my service restart would be independent from netctl and only dependent of the network interface.

Similar Messages

  • Systemd services seem to ignore "After=network.target" with NM

    Hey, I've been having some trouble with services that require the network to be up running too early in the boot sequence. I'm running NetworkManager.
    Looking at the journal shows them running before networkmanager starts the interfaces, and failing since there's no interface available yet.
    For now I've discovered that running "systemctl enable NetworkManager-wait-online.service" seems to have solved it, but is this how it is supposed to work or is something going wrong?

    MisterAnderson wrote:The service isn't exiting, it's that other services are starting whilst NetworkManager is starting, so the interfaces are initialised and named yet. After=network.target appears to only make other services wait until NetworkManager starts, not until it's finished.
    OK. I guess the problem is that NM.service is Type=dbus. so systemd doesn't wait on it to finish but only for the dbus socket to appear (?). That's why you have to insert an additional ordering point NM-online.service which delays the start of network.target. I wonder though if you can avoid that by using type-forking and removing "--no-daemon" argument...

  • Systemd services starting before network is up

    I have a couple services that need the network to be up before they start. I have After=network.target in my .service unit. I have also tried After=netctl@ovh_net_eth0.service both did not work. Services error because no network when they are started. I have tried Google and searching the forums here and I am stumped.
    Services
    systemctl --type=service
    UNIT LOAD ACTIVE SUB DESCRIPTION
    cronie.service loaded active running Periodic Command Scheduler
    dbus.service loaded active running D-Bus System Message Bus
    [email protected] loaded active running Getty on tty1
    kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
    netctl@ovh_net_eth0.service loaded active exited A basic static ethernet connection
    sshd.service loaded active running OpenSSH Daemon
    systemd-backlight@backlight:acpi_video0.service loaded active exited Load/Save Screen Backlight Brightness of backlight:acpi_video0
    systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
    systemd-journald.service loaded active running Journal Service
    systemd-logind.service loaded active running Login Service
    systemd-modules-load.service loaded active exited Load Kernel Modules
    systemd-random-seed.service loaded active exited Load/Save Random Seed
    systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
    systemd-sysctl.service loaded active exited Apply Kernel Variables
    systemd-timesyncd.service loaded active running Network Time Synchronization
    systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
    systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
    systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
    systemd-udevd.service loaded active running udev Kernel Device Manager
    systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
    systemd-user-sessions.service loaded active exited Permit User Sessions
    systemd-vconsole-setup.service loaded active exited Setup Virtual Console
    [email protected] loaded active running User Manager for UID 1000
    UNIT LOAD ACTIVE SUB DESCRIPTION
    proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
    sys-devices-pci0000:00-0000:00:02.0-backlight-acpi_video0.device loaded active plugged /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0
    sys-devices-pci0000:00-0000:00:1c.0-0000:01:00.0-net-eth0.device loaded active plugged 82574L Gigabit Network Connection
    sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded active plugged INTEL_SSDSA2CT040G3 1
    sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loaded active plugged INTEL_SSDSA2CT040G3 swap-sda2
    sys-devices-pci0000:00-0000:00:1f.2-ata1-host0-target0:0:0-0:0:0:0-block-sda.device loaded active plugged INTEL_SSDSA2CT040G3
    sys-devices-platform-serial8250-tty-ttyS2.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS2
    sys-devices-platform-serial8250-tty-ttyS3.device loaded active plugged /sys/devices/platform/serial8250/tty/ttyS3
    sys-devices-pnp0-00:08-tty-ttyS1.device loaded active plugged /sys/devices/pnp0/00:08/tty/ttyS1
    sys-devices-pnp0-00:09-tty-ttyS0.device loaded active plugged /sys/devices/pnp0/00:09/tty/ttyS0
    sys-module-configfs.device loaded active plugged /sys/module/configfs
    sys-subsystem-net-devices-eth0.device loaded active plugged 82574L Gigabit Network Connection
    -.mount loaded active mounted /
    dev-hugepages.mount loaded active mounted Huge Pages File System
    dev-mqueue.mount loaded active mounted POSIX Message Queue File System
    run-user-1000.mount loaded active mounted /run/user/1000
    sys-kernel-config.mount loaded active mounted Configuration File System
    sys-kernel-debug.mount loaded active mounted Debug File System
    tmp.mount loaded active mounted Temporary Directory
    systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Watch
    systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
    session-c2.scope loaded active running Session c2 of user concopa
    cronie.service loaded active running Periodic Command Scheduler
    dbus.service loaded active running D-Bus System Message Bus
    [email protected] loaded active running Getty on tty1
    kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kern
    netctl@ovh_net_eth0.service loaded active exited A basic static ethernet connection
    sshd.service loaded active running OpenSSH Daemon
    systemd-backlight@backlight:acpi_video0.service loaded active exited Load/Save Screen Backlight Brightness of backlight:acpi_video0
    systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
    systemd-journald.service loaded active running Journal Service
    systemd-logind.service loaded active running Login Service
    systemd-modules-load.service loaded active exited Load Kernel Modules
    systemd-random-seed.service loaded active exited Load/Save Random Seed
    systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
    systemd-sysctl.service loaded active exited Apply Kernel Variables
    systemd-timesyncd.service loaded active running Network Time Synchronization
    systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
    systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
    systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
    systemd-udevd.service loaded active running udev Kernel Device Manager
    systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
    systemd-user-sessions.service loaded active exited Permit User Sessions
    systemd-vconsole-setup.service loaded active exited Setup Virtual Console
    [email protected] loaded active running User Manager for UID 1000
    -.slice loaded active active Root Slice
    system-getty.slice loaded active active system-getty.slice
    system-netctl.slice loaded active active system-netctl.slice

    I tried adding "Requires=" still not working as planned. OVH dedicated box that had networking installed out of the box. I wonder if I need to do some tweaking there.  I just looked at boot log and services are starting before the network is up. Removed some lines to make it more readable. Dec 29 15:35:52 systemd[254]: Starting autodl screen irssi... is what I need to wait for network to be up before starting.
    Dec 29 15:35:52 systemd[254]: pam_unix(systemd-user:session): session opened for user by (uid=0)
    Dec 29 15:35:52 systemd[254]: Starting Paths.
    Dec 29 15:35:52 systemd[254]: Reached target Paths.
    Dec 29 15:35:52 systemd[254]: Starting Timers.
    Dec 29 15:35:52 systemd[254]: Reached target Timers.
    Dec 29 15:35:52 systemd[254]: Starting -.slice.
    Dec 29 15:35:52 systemd[254]: Created slice -.slice.
    Dec 29 15:35:52 systemd[254]: Starting Sockets.
    Dec 29 15:35:52 systemd[254]: Reached target Sockets.
    Dec 29 15:35:52 systemd[254]: Starting Basic System.
    Dec 29 15:35:52 systemd[254]: Reached target Basic System.
    Dec 29 15:35:52 systemd[254]: Starting autodl screen irssi...
    Dec 29 15:35:52 systemd[254]: Started autodl screen irssi.
    Dec 29 15:35:52 systemd[254]: Starting Default.
    Dec 29 15:35:52 systemd[254]: Reached target Default.
    Dec 29 15:35:52 systemd[254]: Startup finished in 156ms.
    Dec 29 15:35:57 network[294]: Starting network profile 'ovh_net_eth0'...
    Dec 29 15:35:57 kernel: IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    Dec 29 15:35:58 kernel: e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
    Dec 29 15:35:58 kernel: e1000e 0000:01:00.0 eth0: 10/100 speed: disabling TSO
    Dec 29 15:35:58 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Dec 29 15:36:00 network[294]: Started network profile 'ovh_net_eth0'

  • Error: there is a problem connection to the GPRS service in your registered home network, error trying to make data connection. this may be casued by a voice call, a wired activesync connection or inncorrect network setting

    like 2 weeks ago i called in to att to see how much is the data plan and it would end up costing $30.
    so i was like screw that. well they figured that i got a new phone replacing the LG shine. so they asked
    for to call this number so they can recieve data which would updated the system that i have a plam treo 750.
    ever since this conflict i can't send picture messages. i get that problem. everytime i attempt to send a picture
    i recieve this.
    - there is a problem connection to the GPRS service in your registered home network.
    - then i get a test that says error trying to make data connection. this may be casued by a voice call,
    a wired activesync connection or inncorrect network setting.
    please someone help me.
    btw. hard reset and soft reset did not work for me.
    Post relates to: Treo 750 (AT&T)

    problem fix, i had to call in. customer serivce. and when i called to ask about the plan. they blocked it. so i had to unblock my internet.
    Post relates to: Treo 750 (AT&T)

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

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

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

  • Run custom systemd service before NetworkManager

    Hi, I am trying to write a systemd service that runs and completes before NetworkManager.service starts.
    I tried this:
    [Unit]
    Description=Custom service test
    Before=NetworkManager.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/echo Custom service test 1
    ExecStart=/usr/bin/sleep 5
    ExecStart=/usr/bin/echo Custom service test 2
    [Install]
    WantedBy=network.target
    While the custom service does start, I got this rather strange output:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:48 localhost kernel: NVRM: GPU at 0000:02:00: GPU-(snip)
    ... some unrelated messages (acpid, kdm, etc) ...
    Jan 22 00:12:49 localhost systemd-logind[1170]: Linked /tmp/.X11-unix/X0 to /run/user/1000/X11-display.
    Jan 22 00:13:13 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:50 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:50 localhost systemd[1]: Starting Network Manager...
    As you can see, while everything appears in the expected order in the log, the timestamps look very wrong. The "Custom service test 2" says "00:13:13", yet it is in the middle of "00:12:49" and "00:12:50". What gives?
    Also, notice that the first echo was at 00:12:46, but NetworkManager started at 00:12:50, which is only 4 seconds later. The "sleep" in the custom services should have made it start at 00:12:51 at the earliest. I don't understand why things are not being respected.
    The output I'd expect to see is something like this:
    Jan 22 00:12:46 localhost echo[1166]: Custom service test 1
    Jan 22 00:12:51 localhost echo[1254]: Custom service test 2
    Jan 22 00:12:51 localhost systemd[1]: Started Custom service test.
    Jan 22 00:12:51 localhost systemd[1]: Starting Network Manager...
    I have also made sure that it shows up in NetworkManager.service's After list:
    $ systemctl show -p After NetworkManager.service
    After=mycustomservice.service syslog.target systemd-journald.socket dbus.socket basic.target

    falconindy wrote:Sooooo this begs the question: what are you really trying to do?
    I'm trying to write a script that changes the interface's MAC address before NetworkManager gets a chance to take over the network interface. I'm aware that there's a page about exactly that on the wiki. I started with the systemd service from the bottom of the page, which says "Before=dhcpcd@%i.service". I changed that line to use "NetworkManager.service", and I changed the ExecStart line to "/usr/bin/macchanger -A myinterface" in order to get a random MAC address, instead of setting a fixed one like the example shows. Then I saw that macchanger's output was being mixed with NetworkManager's output in the journal, so I decided to try and write a custom service just for testing, making it start before NetworkManager, in order to see if it really was systemd's fault or if it was something macchanger-specific. Then I noticed the strange behavior described in the OP, didn't really know what to do about it, so I posted this topic. That's the story so far...
    Last edited by WindPower (2013-01-23 00:13:22)

  • [SOLVED] Systemd service files: sourcing other service files?

    Is there a way to "source" one systemd service file from another, so that the service inherits all settings from the other file? The purpose would be to override or append select fields as a quasi-patch of the other file, e.g.
    <source foo.service>
    [section]
    key=new_value
    I was sure that I had seen this somewhere, but I can't find it. Did I make this up, or is my search-fu simply weak?

    I don't know that it is actually documented at this point in time.  At least I haven't seen any.  The only reason I know about it is beacuse I subscribe to [systemd-devel].  But it was briefly touched on in the announcement when it was first introduced. 
    I know that the .include method is documented very briefly in one of the man pages, but it doesn't really go into depth about how to use it.  I do seem to recall a nice write up about it on Lennart's blog though.  But it seems as though the intent of the systemd.unit.d (what they are calling "drop-in" modifications/replacements) is intended to replace the .include way.  Though I am basing that statement off of the general attitude toward each on the mailing list, and I have seen no official word on this.
    The nice thing about using .include is that you can use systemd-delta to see the changes made using that method.  And while the systemd.unit.d changes are noted in that output, it is nothing more than simply indicating that there has been modification.  The .include stuff actually has a full "diff -u" style output.

  • Is it possible to make this type of network with router i have?

    I have Linksys WRT54GC router at home and i share internet to all my PCs through the router.
    Is it possible to share internet firstly through my PC, and then through this router to all other pcs? If it is possible how i should configure my router? If not - do i have to buy some kind of switch to make this type of network?
    Example scheme:
    (Net)
    ---------------------------- PC1 (with 2 NIC)
    (routing) /
    router ------/
    | |___ PC2
    \___ PC3
    I have now this configuration of my PC's and router, but internet on PC2 is not working, but PC2 and router see each other. But ping between PC1 and router (192.168.0.1 192.168.0.2) says "no response":
    MY FIRST PC:
    http://www.improx.info/mypc.JPG
    http://www.improx.info/mypc_2.JPG
    Router:
    http://www.improx.info/router_1.JPG
    http://www.improx.info/router_2.JPG
    http://www.improx.info/router_3.JPG
    PC2:
    http://www.improx.info/pc2.JPG
    or i tried this:
    http://www.improx.info/pc2_var2.JPG
    http://www.improx.info/router_var2.JPG
    Sorry for bad english.
    Best regards,
    Arnas
    Message Edited by imuk on 12-19-2007 07:24 AM

    It is not clear to me what the exact problem is. The screenshots show that everything is correct. The second PC should have internet with this setup. PC1 won't be able to ping the router on 192.168.0.2 if you block ICMP (anonymous WAN requests) on the router. That setting should be on the Security tab.
    I would suggest to set up the WRT as simple wireless access point. That way you still have full LAN connectivity between all your computers. To do that, you have to temporarily wire a computer to a LAN port of the router. Unplug the gateway computer from the router! There is only a single computer connected to the WRT at the moment.
    Open http://10.10.10.1/ or whatever LAN IP address you have set on the WRT at the moment. On the Setup tab, change the internet connection type to "Automatic/DHCP", change the LAN IP address from 10.10.10.1 to 192.168.0.2, disable the DHCP server. Now press the save settings button. You'll loose the connection to the router. That's OK.
    Now rewire the router. Connect a LAN port of the router to the gateway computer. Do not use the internet port on the WRT! That is the basic setup.
    Now wired computers connected to the remaining 3 LAN ports on the WRT should have LAN and internet access. In the same way, wireless clients connect into the ICS LAN and have internet.

  • Network change notification

    We are getting a error alert on our Mac mini OS X 10.7.5 of
    Network change notification for "servername1". the host name of "servername1" has changed to "servername1". some service may not work correctly unitl they have been updated to use the new configuration.
    what error is this, how do we fix this. please need your assistant

    Hello, since some days I encounert the same issue! As my MAC mini server has loads aof I/O Errors, I am wondering if this is a possible root cause for this? On the other hand, why? What happens and what has the change of the Hostname to do with I/O-Problems? Many thanks in advance for any response! Best rgds, Martin

  • Airport Extreme Network - Changing from Verizon DSL to Fios (with TV)

    I am currently using Verizon DSL for internet access. My present network is stable with an Airport Extreme Base (New version) and two Airport Express running MDS for range extension, providing wireless access for a Macbook and a PC laptop (my wife's connection to her office/Exchange server via VPN). Two G4 desktop Macs are occasionally connected to the network. One AE provides network access to a shared printer. I routinely use Back to My Mac. The network also provides remote (internet) access to an old model iSight camera and to an inexpensive wireless camera which are served by Evocam software.
    I have ordered Verizon Fios bundled services (TV-Internet-Phone) for installation on October 18. The service make sense for many reasons, BUT! A multitude of posts on various boards are telling horror stories about setup problems and failure of certain services to work with Fios, particularly in newer installations that include TV.
    My question is this: Am I about to step into an inescapable swamp? Should I cancel the order.

    Yup, this is expected behavior.  What printer model? What operating system?
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • How can I make OSX index a network share for spotlight?

    How can I make OSX index a network share for spotlight?
    I am using a QNAP NAS with SMB network shares, which I mount with OS X Mavericks. They are not searchable, as far as I know because of the indexing of network share is by default not activated.
    To force the OS to index them I activated this via mdutils. But this is no solutions. This makes spotlight to index the share once. But I want spotlight to index it always and keep it up to date. I have a huge amount of documents & fotographs, which is very difficult to manage without being searchable.
    Unfortunately the only solution I found in the www was the mdutils-way, which seems not to work, maybe only works not for me.
    I would appreciate any assistance,
    Thank you,
    Stefan

    My thanks to everyone who has contributed to solving this problem here.
    It appears that there still is NOT a good, reliable solution.  Please correct me if I'm wrong.
    I did find this on http://jonathansblog.co.uk/how-to-enable-spotlight-indexing-on-a-network-drive:
    ===================================
    To enable spotlight indexing on a network drive:
    # mdutil /Volumes/name -i on
    To disable the indexing of a connected network drive:
    # mdutil /Volumes/name -i off
    To check the status of indexing on a connected network drive:
    # mdutil /Volumes/name -s
    ===================================
    And, I found this on the Synology NAS forums:
    cd /Volumes
    mdutil shareName -i on
    mdimport -Vp ./shareName
    where shareName = name of your share
    I have used the mdutil /Volumes/name -i on, and it seems to work.
    But, if I understand it correctly, it is a one-time indexing -- the index is NOT keep up-to-date with changes.
    So, how can we keep the index up-to-date?
    My thought was to schedule a Terminal file to execute each night with the mdutil code.
    Would this work?  If so, how would you setup a scheduled run?
    Would it have to be done on each Mac that accesses the Share?

  • Stop systemd.service by other systemd.service (nfs)

    Hi there,
    I'm currently tweaking my nfs setup.
    What do I want
    Mount my exported directories via bind to export, when the nfs-server starts. And unmount the directories on stop of the nfs-server
    Approach
    /etc/systemd/system/nfs.target
    [Unit]
    Description=Network File System Server
    Wants=export-daten.mount export-daten-Downloads.mount export-portage.mount export-root.mount export-root-boot.mount
    Requires=nfs-server.service
    BindsTo=nfs-server.service
    [Install]
    WantedBy=multi-user.target
    /etc/systemd/system/export-daten.mount
    [Unit]
    Description=/home/blubb/Daten nach /export/daten
    BindsTo=nfs-server.service
    StopWhenUnneeded=true
    [Mount]
    What=/home/blubb/Daten
    Where=/export/daten
    Options=bind
    [Install]
    WantedBy=nfs.target
    ls nfs.target.wants
    export-daten-Downloads.mount export-daten.mount export-portage.mount export-root-boot.mount export-root.mount
    nfs-server.service is the original one shipped by Arch in /usr/lib/systemd/system.
    Current behaviour
    start nfs.target: mounts directories, starts nfs-server
    stop nfs.target: unmounts directories,  doesn't stop nfs-server
    start nfs-server.service fails, because can't export /export/daten/Downloads, which doesn't exist, because the mount-units were not processed.
    stop nfs-server.service: umount directories (due to the BindsTo directive) and stops the nfs.target.
    Desired behaviour
    The current behaviour works, but isn't very clean. Would be nice, if nfs.target stops the nfs-server.service too. I don't want nfs-server.service copy to /etc and modify as I will miss any updates of the original unit in /usr/lib.
    Is it possible to stop nfs-server.service in/by nfs.target?

    Tanks, works so far. One problem is left.
    For some reason, nfs option nohide doesn't work. So I have to export other filesystems in subtree too. My 2 units:
    export-daten.mount
    [Unit]
    Description=/home/sm/Daten nach /export/daten
    BindsTo=nfs-server.service
    StopWhenUnneeded=true
    [Mount]
    What=/home/sm/Daten
    Where=/export/daten
    Options=bind
    [Install]
    WantedBy=nfs.target
    and the filesystem, which is mounted in there:
    export-daten-Downloads.mount
    [Unit]
    Description=/home/sm/Daten/Downloads nach /export/daten/Downloads
    BindsTo=nfs-server.service
    Requires=export-daten.mount
    StopWhenUnneeded=true
    [Mount]
    What=/home/sm/Daten/Downloads
    Where=/export/daten/Downloads
    Options=bind
    [Install]
    WantedBy=nfs.target
    According to the Manpage I'm not sure, if the Requires option is even recognized. Mounting works. But when I stop my nfs-server, I get this message:
    journalctl
    Feb 12 07:23:53 Nas systemd[1]: Stopping Network File System Server.
    Feb 12 07:23:53 Nas systemd[1]: Stopped target Network File System Server.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-daten-Downloads.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-portage.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-root-boot.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unmounting /boot nach /export/root/boot...
    Feb 12 07:23:53 Nas systemd[1]: Unit export-root.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unmounting /var/portage nach /export/portage...
    Feb 12 07:23:53 Nas systemd[1]: Stopping NFS server and services...
    Feb 12 07:23:53 Nas systemd[1]: Unmounting /home/sm/Daten/Downloads nach /export/daten/Downloads...
    Feb 12 07:23:53 Nas systemd[1]: Unit export-daten.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-root-home-sm-Daten-Downloads.mount entered failed state.
    Feb 12 07:23:53 Nas kernel: nfsd: last server has exited, flushing export cache
    Feb 12 07:23:53 Nas systemd[1]: Unmounted /boot nach /export/root/boot.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-root.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Unmounted /var/portage nach /export/portage.
    Feb 12 07:23:53 Nas systemd[1]: Unmounted /home/sm/Daten/Downloads nach /export/daten/Downloads.
    Feb 12 07:23:53 Nas systemd[1]: Unit export-daten.mount is not needed anymore. Stopping.
    Feb 12 07:23:53 Nas systemd[1]: Stopped NFS server and services.
    Feb 12 07:23:53 Nas systemd[1]: Stopping NFS Mount Daemon...
    Feb 12 07:23:53 Nas rpc.mountd[21709]: Caught signal 15, un-registering and exiting.
    Feb 12 07:23:53 Nas systemd[1]: Unmounting /home/sm/Daten nach /export/daten...
    Feb 12 07:23:53 Nas systemd[1]: Unmounting / nach /export/root...
    Feb 12 07:23:53 Nas systemd[1]: Stopped NFS Mount Daemon.
    Feb 12 07:23:53 Nas systemd[1]: Unmounted /home/sm/Daten nach /export/daten.
    Feb 12 07:23:53 Nas systemd[1]: Unmounted / nach /export/root.
    Manpage:
    If a mount point is beneath another mount point in the file system hierarchy, a dependency between both units is created automatically.
    It seems, that works for mounting, but not for the umount.
    Can I do something to unmount that stuff cleaner?

Maybe you are looking for

  • Setup wireless network for mac and pc with Airport Express?

    Mac Mini/OSX/10.8.2/Airport Express Question, I have my AIrPort Express setup for my Mac Mini and I have dell computer that I want to share the wireless network. Is it possible to setup a wireless network with my mini and the pc using only the AirPor

  • Games apps just downloading and installing

    My Ipad 2 io5 just installs new game apps automatically, is there a way for me to block this?

  • Display and use Invoice Percentg in POC on Milestones.

    Hi Expert Does anyone know is it possible? We use PS and POC in Milestones. Invoice Percentg is now displaied and triggered by Percentage, like if it is 60%, it is supposed to be chargeable. Then, it is possible making it triggered by not percentage

  • How to delete jdev preferences on mac

    Hi, I want to delete preferences data of jdeveloper on mac(like system folder in windows) since its still referring to old location after uninstall/reinstall because of that iam unable to install extensions properly. I have tried by uninstalling and

  • Something Strange Has Happened

    Hello Forum Over the past few days and without (I believe) any help from a novice like myself, I have found that I cannot use Bold, Underlining and Spell Check in BT Yahoo Mail.  My OS is Windows 7 Home Premium and version 11 of IE. Can anyone help a