[solved] run program before network is available and stop boot on fail

Hi everyone,
Let's say I have an program that is absolutely essential to my system, and I want it to run before netctl even tries initialising my network connection (in fact, I want the network to be unavailable until the program has finished its execution). I _always_ want to see the program's output on the console, and if it exits with a non-zero exit code, I want the whole boot process to be aborted (or at least all of netctl's units to be disabled). Is this possible in systemd?
Last edited by popoffka (2014-04-18 13:07:09)

popoffka wrote:Hi everyone,
Hi.
popoffka wrote:Let's say I have an program that is absolutely essential to my system, ...
Sure.
popoffka wrote:and I want it to run before netctl even tries initialising my network connection (in fact, I want the network to be unavailable until the program has finished its execution).
Use 'Before=' in your unit file. Make sure it does not fork.
popoffka wrote:I _always_ want to see the program's output on the console,
Pipe it's output to /dev/console directly. Maybe there is a cleaner why, I'm not sure. SystemD actually supports the redirect directive in it's native language (nice).
popoffka wrote:and if it exits with a non-zero exit code, I want the whole boot process to be aborted (or at least all of netctl's units to be disabled)
Use 'RequiredBy=' in your unit file. That could be used to prevent netctl from starting. Preventing the whole boot isn't a bit drastic isn't it?
popoffka wrote:. Is this possible in systemd?
Yes. Consult the systemd.service and systemd.unit manpages.

Similar Messages

  • Trying to run program off network location using GPO with Power shell script.

    Hello All,
    Not much of a script writer. I am giving it a shot.  My issue is that I need to run a application update across our network and I am trying to do it with as little hands on as possible. So I was planning to push a GPO with a power shell script in it
    to run the program with elevated privileges. 
    Little background:
    We are running on a domain and end users do not have admin rights.
    The application is stored on a share on our network that is open to all domain users.
    The installer user name and password is a temp one and will only be valid for the 30 min window when everyone logs in at the beginning of the day.
    So this is what I have so far.
    $username = "USER"
    $password = "PASSWORD"
    $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
    Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDirectory \\Server\Folder\Folder1\Folder2\filder3\PSQLv11sp3_x32\
    But for some reason I keep getting :
    Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
    At line:10 char:1
    + Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDir ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    Any help you could give would be great.
    Thanks,
    jdfmonkey

    Hi jdfmonkey,
    Has anyone provided an answer to your original question?  I am trying to use Start-Process to launch a process using another logged in user's credentials, and am not able to get it working:
    $cred=Get-Credential
    start-process Process.exe-WorkingDirectoryC:\Scripts-Credential$cred
    I get the same error that you mentioned:
    start-process : This command cannot be run due to the error: The system cannot find the file specified.
    At C:\Scripts\Process.ps1:2 char:1
    + start-process Process.exe -WorkingDirectory C:\Scripts -Credential ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    When I leave off the credentials:
    start-processProcess.exe-WorkingDirectoryC:\Scripts
    It works correctly.  Does anyone have a solution to make this work correctly?
    Please ask your own question.  You issue is nothing like the current thread.  You clearly are using a user account that has no access to the folder.  It is a permissions issue.  It is not a scripting issue.
    If you need further help please start your own question.
    ¯\_(ツ)_/¯

  • [solved]Running programs after extracting from a tarball

    Hi, I'm wondering if it's possible to run a program after extraction from the tarball archive? I know that you can use the official packages, the AUR, or build your own package, but I'm just curious. I downloaded the firefox nightly 64bit linux tar.gz file and extracted it to my /home folder. Double clicking the firefox executable simply brings up a prompt that tells me to choose an application to open it, and in bash it says that command is not found, even though I went to the correct directory. Any ideas?
    Last edited by boogerlad (2013-05-03 13:08:12)

    boogerlad wrote:Hi, I'm wondering if it's possible to run a program after extraction from the tarball archive? I know that you can use the official packages, the AUR, or build your own package, but I'm just curious. I downloaded the firefox nightly 64bit linux tar.gz file and extracted it to my /home folder. Double clicking the firefox executable simply brings up a prompt that tells me to choose an application to open it, and in bash it says that command is not found, even though I went to the correct directory. Any ideas?
    1. You probably need to give it executable permissions. 2. The title of this thread is misleading, I thought you were going to ask if you could run a program from inside a tarball (which I don't believe is possible, but I don't know). 3. This is a bad idea; just install it using the AUR or write a PKGBUILD yourself.
    Keeping programs around in your ~ is silly.
    All the best,
    -HG

  • Run program wihtout all of NIDaq and NIMotion

    One of our former developers wrote a LV 8.2 exe that controls an NIDaq card and an NIMotion card and stores the results in an SQL table.  We now have people that do not have the full hardware setup wanting to see the results with this program.  We installed the EXE and the LV 8.2 Runtime on their computer however we get promted by the program that it cannot find "nilvaiu.dll" and "FlexMotion32.dll" which are part of NI Motion and NI Daq.
    When I install NI Daq and Motion on the test stations that have the hardware a ton of junk seems to get installed allong with it.  I don't want the computers in the non-production areas clogged up with a bunch of junk that it does not need so what is the minimum I have to install of NI Daq and NI Motion. 

    You might consider putting in a conditional disable about your daq and motion code and simulate these actions in the NOHARDWARE== TRUE case.  I always have simulated cases to allow for testing without the hardware.
    If you dont disable the code the daq and motion will need to be loaded, there is not an easy way of putting in support for a small subset of the driver's features.  disabling calls will not require any drivers
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • HT1212 iPad2 3G - MTN - "no service" or "searching" - have restored, have tested 3G in other iPad - working fine.  Tried another 3G card, same error.  Reset network settings, restarted and hard boot, changed apn settings, reset apn settings ......  Sugges

    iPad2 - no 3G signal
    "no service" or "searching"
    Have restored iPad, have reset network settings, have tried turning on aeroplane mode and off again.  Changed apn settings.
    Tried another 3G card - same error.
    Tried this 3G card on another iPad - working fine - no problems.

    UPDATE #2:
    I chatted with Ashley from Apple Support yesterday and she suggested me to restore the phone and set it up AS NEW, NOT restore from backup.
    And it worked!
    Of course, you have to back up everything, but I have my contacts, notes, and pictures on iCloud. All I did was merge them back to the phone from iCloud Setting.
    One downside: you'll lose all text messages. But it's worth it.
    So, thank you, Ashley!

  • [SOLVED] Running a startup script as a user at boot once

    Hello!
    So, as the title suggests, I am trying to start a script as a specific user at boot. To avoid accidentally starting it multiple times, I don't want it to run every time to user logs in. So far I've looked into creating a custom systemd service to call a script as root then using 'sudo -u user script' to run said script.
    This almost worked, the script must have executed but, because it was starting a new task in a screen, it created a dead screen. Although I'm not entirely sure why (I suspect it has something to do with not running screen as the logged in user), I figured I would ask if anyone knew of a better way to do this. My solution so far is pretty convoluted.
    Side notes: This is running on a GUI-less server (hence the possibility of a user logging in multiple times or having multiple sessions open at once)
    Last edited by Lindenk (2013-07-09 15:33:45)

    Sure,
    Here's essentially the unit file -
    [Unit]
    Description=Runs a script to run a script to start a script to start a server
    [Service]
    ExecStart=/absolute/path/to/a/rootScript.sh
    [Install]
    WantedBy=multi-user.target
    And the root script
    #!/bin/bash
    #This script will run another script as the user 'server'
    sudo -u server /path/to/userScript.sh
    And the user script
    #insert possible setup stuff here
    screen -S serv -d -m /path/to/server/start.py
    #insert possible cleanup stuff here
    Also as a side note, I did already allow root to run commands as server without a password.
    EDIT: Another side note, the root script and user script do in fact work as intended when started individually. When running through systemd (at boot or not), the screen created is dead.
    Last edited by Lindenk (2013-07-09 14:36:54)

  • Hi, I am running the latest version of Firefox and at times it fails to connect to the internet. This is a intermittent problem. It also (sometimes) take very long to open after I open Firefox?

    Firefox does not always connect to the internet or is very slow to open. It is not with specific sites and when it does happen I have to either wait or shut down and restart the computer. It does not happen with my other browsers. (Google chrome)

    I have been having the same problem, it's as if Firefox's internet connection is broken at intermittent intervals. I tried disabling all my plugins, creating a new profile, everything on the page below and even updated to version 8, but nothing helped. I think it's been happening for a weeks or so, maybe since an update(?) but it seemed a lot worse today. It's not my connection as I've been using Chrome as an alternative which works fine. I have not tried rebooting my machine.
    http://support.mozilla.com/en-US/kb/Firefox%20cannot%20load%20websites%20but%20other%20programs%20can

  • [SOLVED]Grub-Install can't Find Kernel and/or initrd, mkinitcpio Fails

    Hi all,
    I have recently installed Arch on my new build (with UEFI firmware). I successfully set up xorg, alsa/pulseaudio, xfce, etc... things were looking pretty good. Then, I tried to blacklist the pcspkr in order to silence the annoying beep every time I selected "Log Out" inside xfce. I executed
    mkinitcpio -p linux
    and was presented with the following errors:
    ==> Building image from preset: 'default'
    -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
    ==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux'
    ==> Building image from preset: 'fallback'
    -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
    ==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux`
    There were no such files anywhere on /boot. I tried doing
    find / -name vmlinuz-linux
    and nothing was found. I wasn't quite sure why that was happening, but I tried uninstalling/reinstall grub (grub-common and grub2-efi-x86_64). I installed grub to /boot using
    grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot --bootloader-id="Arch Linux" --boot-directory=/boot --recheck --debug
    and then generated /boot/grub/grub.cfg. I tried rebuilding the initramfs again but got the same error. I was tired and frustrated so I removed the old grub efi entry with
    efibootmgr -b 0 -B
    and then went to sleep.
    I didn't have the chance to turn the computer back on until tonight... I was then presented with a grub2 shell. Since I didn't know where the kernel/initrd were located I tried
    set root=(hd1,gpt1)
    chainloader +1
    but grub told me
    error: invalid EFI file path
    So that's about it. It appears that grub-mkconfig is having trouble locating the kernel/initrd so it doesn't make any entries, dropping me right into a shell. I've tried booting up with my installation USB and chrooting in and reinstalling grub again but nothing seems to work. So what I'd like to try to do is just boot up into my system and then modify add the grub boot entries entries I want... but I just can't figure out what's causing all these issues.
    Sorry if I mess up any terminology... still learning the ropes here. Thanks for any input.
    Last edited by cogeary (2012-09-17 05:35:51)

    DSpider wrote:
    ==> ERROR: specified kernel image does not exist: `/boot/vmlinuz-linux'
    Probably because you have a separate boot partition (not just the 512 MB "UEFISYS" FAT32 partition), which you forgot to mount (in fstab).
    Post your /etc/fstab.
    Thank you for your reply!
    However, I do not have a separate boot partition apart from the "UEFISYS" partition. Here is my fstab:
    # UUID=3ec307aa-0ead-4d33-b292-42bbe783d6ee
    /dev/sda2 / ext4 rw,relatime,data=ordered 0 1
    # UUID=B192-6C57
    /dev/sda1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2
    When I first looked at the fstab I saw that both of the entries repeated themselves. This was because I had even tried reformatting /boot so I had to generate a new fstab, but for some reason I used ">> /mnt/etc/fstab" rather than "> ..."
    So I executed
    genfstab /mnt > /mnt/etc/fstab
    and reinstalled grub, but still no difference... mkinitcpio fails and I reboot to a grub shell.
    Last edited by cogeary (2012-09-16 18:15:51)

  • [SOLVED] Mega 180 + AGP additional card = beeps and no boot

    Hy, I've just got a mega 180 that works just fine ... with no agp card ...
    If I plug an additional card into it, like the basic 6600, the pc won't boot and beeps will be heared.
    These are : beeep (1-2 sec), ... (2 or 3 sec), beep, ..., and so on ...
    Again, if there is no additional card, it works just fine.
    I've tried it with an old xentor 2 card --> same result.
    Is there any bios setup ?
    Anything to do ?
    Plz help ! :-)
    Config :
    bios v3.5
    sempron 2500+
    2*256 corsair high speed
    80Go HD
    Leadtek 6600TD 128Mo

    Quote from: VieuxEd on 22-April-05, 18:11:09
    3. Can you get into the bios, and change the settings to not use the onboard (don't remember the exact words, but it's somewhere in there, see the manual if you cant find it).
    I've been looking at it but could not find it ! --> can you please tell me the right setup ?
    Is it anyway possible to make the mega pc 180 work with the onboard Graphic card and an additional one at the same time ?
    Because right now, with the beeps, I don't have access to the bios.
    So I will have to setup first the bios with no additional agp card (setup not to use onboard) and then turn it off and then plug the agp card
    Coul it be possible for the agp plug to be broken ?
    It's not impossible that the AGP slot is broken, but I would try other things first.
    As you say, you can change the BIOS to use AGP card, shut it down, plug in the AGP card, and power on.
    Chapter 3.8 in the manual (avaible @ http://www.msi.com.tw). Please work with me... 
    You can also try to fiddle around a bit with the other AGP settings and see what happens....

  • [SOLVED]Help! bootchard caused the system to stop booting

    Hello,
    I've installed bootchard and  followed the instructions in the archwiki specifically where it says
    Open up /boot/grub/menu.lst, and copy/paste the entry you want to log. Append "init=/sbin/bootchartd"
    I did that and now the computer wont boot correctly. I get an error that sbin/bootchard was not found and that i'm on my own now? What am I'm supposed to do? I'm now using the Ubuntu LiveCD to post this.
    EDIT: I've copied the actual error down and this is what it says.
    Error: root revice mounted successfully, but sbin/bootchard does not exist. Bailing out, you are on your own, good luck .
    Last edited by aluser (2011-02-12 19:05:21)

    Do as Varg said and you should be fine.
    Your boot kernel entry should look something like this:
    kernel /boot/vmlinuz26 root=/dev/sdb1 ro init=/sbin/bootchartd
    Since bootchartd is not something you don't normally want to run on every boot, you might want to create a separate entry for it like so:
    # (0) Arch Linux
    title Arch Linux
    root (hd0,0)
    kernel /boot/vmlinuz26 root=/dev/sdb1 ro fastboot logo.nologo quiet ipv6.disable=1
    initrd /boot/kernel26.img
    # (1) Bootchart
    title Arch Linux Bootchart
    root (hd0,0)
    kernel /boot/vmlinuz26 root=/dev/sdb1 ro fastboot logo.nologo quiet ipv6.disable=1 init=/sbin/bootchartd
    initrd /boot/kernel26.img
    Lose "fastboot logo.nologo quiet ipv6.disable=1" if you don't want these options and make sure that "root" is set correctly for your system.

  • 11.3 and FTF1 boot device failed

    Hi,
    I upgraded the system from 11.2 to 11.3 and applied the last patch FRU1 11.3.0.37267 FTF Roll Up 1. 400 computers are waiting for deployment bundles on boot device and nothing is working anymore. Boot device installation always working normally. I found a couple thread about this bug on this Forum since March 2014, 11.3 have this problem.
    Problem :
    Boot device installation is not working and the agent gives me always "not installed" on each bundle.
    1. system Windows 7, 64 bits and 32 bits
    2. 11.3 without Patch and with Patch fru1
    3. The Schedule time is working to deploy sofware
    4. 11.2.2 and 11.2.3 always working for boot device bundles.
    Some People opened SR and it's suppose to be fixed on fru1 but is not working
    http://www.novell.com/support/kb/doc.php?id=7014812
    http://www.novell.com/support/kb/doc.php?id=7014789
    Thanks!
    PP

    Oh and Shaun's issue is something a little different.
    We have not gotten to the root of his issue yet, but something else is
    going on.
    At this point, there is not any confirmed issue with Boot Bundles.
    An Official Service Request could get someone digging deeper.
    However, my 1st course of order would be to simply a test environment.
    Make sure a Device does not inherit any bundles - put it somewhere else.
    Create a Simple Bundle that runs on boot that does something very simple
    such as create a directory on the Root of C:
    Then refresh to make sure the device sees it and then reboot.
    I strongly suspect you may have an issue with one more of your bundles
    that is in retry and holding everything up. You would not have seen
    that in 11.2 due to the lack of ordering and haphazard execution of the
    bundles.
    On 6/5/2014 7:22 AM, CRAIGDWILSON wrote:
    > There could be a number of issues between 11.2 and 11.3 that cause
    > things to fail.
    >
    > In particular if you are trying to push that many bundles.
    > Newer versions of ZCM will auto-order things and introduce retries etc..
    > etc...
    >
    > Quite possible a bundle if failing and has many retries so everything
    > gets blocked.
    >
    > Instead of having 300 Bundles on Device Boot it would be much better to
    > try and configure a Master - "Std Bundles" bundle that called other
    > bundles. This way once it ran, it would be done and ZCM would only need
    > to check the status of 1 and not 300 bundles on boot.
    >
    > There are some other things you can do as well to reduce the overhead.
    >
    > On 6/4/2014 10:46 PM, ppcroteau wrote:
    >>
    >> Craig Wilson and shaunpond, for your information I keep the server on
    >> 11.3 ftf1 and for the workstation windows7 32bit or 64bits I reinstalled
    >> my old agent 11.2 and all 300 bundle are working on event "device boot"
    >> perfectly... it's a real agent bug with 11.3.
    >>
    >>
    >
    >
    Craig Wilson - MCNE, MCSE, CCNA
    Novell Technical Support Engineer
    Novell does not officially monitor these forums.
    Suggestions/Opinions/Statements made by me are solely my own.
    These thoughts may not be shared by either Novell or any rational human.

  • How to schedule a service to run before network goes down

    Hi
    I wrote a new smf service and added it to the repository.
    When running with "stop" (when the system goes down) it sends an alert to another machine.
    My question is :
    How can I schedule that service to run just before network services go down?
    another question, how can I schedule another service to run just BEFORE system is getting down?
    Many Thanks
    --me2unix                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Dependencies appear to be really written and tested on the boot side, but they should work properly going down as well.
    My first assumption is that you'd make a dependency on the network for your service. So it should be started after the network starts, and will wait for your service to quit before trying to shut down the network.
    Now this would only apply to normal shutdowns. Also, there are mulitple services on the box that have network affects. You may need to read through several to understand their purpose and interaction to pick the correct one for your use. Probably the milestone/network will be the best choice.
    Darren

  • Keep getting message "none of your preferred networks are available"

    Whenever I start mny iMac running 10.6.3 I keep getting the message ""none of your preferred networks are available" and my wifi won;'t connect. This never happened before yesterday. Help! What do I do?

    OK, well let's start. First thing to try is a SMC Reset Please read the instructions carefully as they cover multiple models of Mac's you want to use the one for Intel iMacs.
    After you done your SMC reset please report what happened.

  • How to start and stop a progress-bar thread before/after the main thread

    hi. I would appreciate any kind of help on my request.
    I have this as my main() function
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable(){
                   public void run(){                              
                        Options op = new Options();
                        OdessaClient oc = new OdessaClient(op);     
                        oc.setVisible(true);                    
         }Whenever I try to start a simple JFrame with an indeterminate progress bar on it just before the main function and stop it somewhere after I get a StackOverFlow error
    Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
         at com.client.CylonBar.hide(CylonBar.java:25)
         at java.awt.Component.show(Component.java:1302)
         at java.awt.Component.setVisible(Component.java:1253)
    ...and so on...How must I implement something like it?

    Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().

  • "None of your preferred networks are available" But they are!

    This is the one problem that most bugs me with my MBP, i was hoping that 10.5.2 would fix it, but it does not.
    I use my MBP on two wireless networks. They are both airport expresses with different SSIDs.
    The first (work) is one airport express and my MBP will connect to it when ever it is in range happily. The second (home) is an airport express with another airport express extending the first. The only one in range on my laptop is the extension. Every time I wake the laptop it will tell me that "None of your preferred networks are available" and show the name of my network in the list - it has the password stored and has been told to remember the network... and yet it still refuses to connect.
    Clicking the network shows that it knows the password as it displays it. I have rest both airport expresses and made the network from scratch, I have also deleted all references to the network in keychain and airport preferences, and yet it still does it.
    There are a couple of other threads on this topic, but none of them have been resolved (That i have found) and they seem to have a slightly different problem to me, so I have posted my own question.
    Does anyone know what is wrong?
    Thanks.

    I don't have the answer, I have the problem...
    I'm also in one of the other threads about 10.5.2 messing up connection to my Apple Airport Extreme (melted marshmallow), but I also have the "None of your preferred networks are available" problem.
    My network configuration looks like this: http://tijil.org/LAN_06.jpg
    I have: Hard reset Airport, re-loaded firmware, re-done all settings, powered up and down numerous times, changed channels, etc. to no avail.
    For me the Airport Base continues to work just fine with the other two computers connected to it wirelessly, but my 3 week old MacBook with 10.5.2 will no do so automatically, and once it does, even though the signal is strong and the S/N ratio is good, the connection is usually much slower than either of the other machines, has difficulty sustaining a large upload, and frequently drops out - for the MacBook only.
    This did not happen with 10.5.0 or 10.5.1 and does not happen with the machines running 10.4.x.
    The Airport Extreme Base is set to use 802.11b/g as one of the older machines can only handle 'b'...
    I have MAC screening set up and also WAP. Network is NOT 'hidden.'
    Airport Utility on the MacBook also has difficulty finding the base even when the MacBook is actually connected to it and using it to download mail. sigh
    The problem is something that changed in 10.5.2.
    Hope Apple gets this sorted soon!
    Tom

Maybe you are looking for