How to start a service upon the output of a command?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I would like to start a specific service after another one has completely started. Specifically, I need an OpenVPN service to be up and have completed its startup to start another service.



I would normally use After= but it does not work as intended with OpenVPN, which informs that it has started right after launch and before its setup is completed.



A solution to this would be to constrain the start of my service to the output or exit status of a script(*) (or to the existence of a file which would be crated by the said script).



Is this possible with systemd?




(*) The script would ping a host known to be accessible only via the VPN tunnel and exit once connectivity is achieved (or drop a file)







share|improve this question




















  • unix.stackexchange.com/questions/388586/…
    – jasonwryan
    Oct 15 '17 at 18:00














up vote
0
down vote

favorite












I would like to start a specific service after another one has completely started. Specifically, I need an OpenVPN service to be up and have completed its startup to start another service.



I would normally use After= but it does not work as intended with OpenVPN, which informs that it has started right after launch and before its setup is completed.



A solution to this would be to constrain the start of my service to the output or exit status of a script(*) (or to the existence of a file which would be crated by the said script).



Is this possible with systemd?




(*) The script would ping a host known to be accessible only via the VPN tunnel and exit once connectivity is achieved (or drop a file)







share|improve this question




















  • unix.stackexchange.com/questions/388586/…
    – jasonwryan
    Oct 15 '17 at 18:00












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I would like to start a specific service after another one has completely started. Specifically, I need an OpenVPN service to be up and have completed its startup to start another service.



I would normally use After= but it does not work as intended with OpenVPN, which informs that it has started right after launch and before its setup is completed.



A solution to this would be to constrain the start of my service to the output or exit status of a script(*) (or to the existence of a file which would be crated by the said script).



Is this possible with systemd?




(*) The script would ping a host known to be accessible only via the VPN tunnel and exit once connectivity is achieved (or drop a file)







share|improve this question












I would like to start a specific service after another one has completely started. Specifically, I need an OpenVPN service to be up and have completed its startup to start another service.



I would normally use After= but it does not work as intended with OpenVPN, which informs that it has started right after launch and before its setup is completed.



A solution to this would be to constrain the start of my service to the output or exit status of a script(*) (or to the existence of a file which would be crated by the said script).



Is this possible with systemd?




(*) The script would ping a host known to be accessible only via the VPN tunnel and exit once connectivity is achieved (or drop a file)









share|improve this question











share|improve this question




share|improve this question










asked Oct 15 '17 at 17:19









WoJ

366113




366113











  • unix.stackexchange.com/questions/388586/…
    – jasonwryan
    Oct 15 '17 at 18:00
















  • unix.stackexchange.com/questions/388586/…
    – jasonwryan
    Oct 15 '17 at 18:00















unix.stackexchange.com/questions/388586/…
– jasonwryan
Oct 15 '17 at 18:00




unix.stackexchange.com/questions/388586/…
– jasonwryan
Oct 15 '17 at 18:00










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You can configure the service unit with



Type=notify
NotifyAccess=all


and make the last script (or a child of that) which is started by OpenVPN during initialization (wait for the desired logging output and then) call systemd-notify.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398258%2fhow-to-start-a-service-upon-the-output-of-a-command%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You can configure the service unit with



    Type=notify
    NotifyAccess=all


    and make the last script (or a child of that) which is started by OpenVPN during initialization (wait for the desired logging output and then) call systemd-notify.






    share|improve this answer
























      up vote
      0
      down vote













      You can configure the service unit with



      Type=notify
      NotifyAccess=all


      and make the last script (or a child of that) which is started by OpenVPN during initialization (wait for the desired logging output and then) call systemd-notify.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        You can configure the service unit with



        Type=notify
        NotifyAccess=all


        and make the last script (or a child of that) which is started by OpenVPN during initialization (wait for the desired logging output and then) call systemd-notify.






        share|improve this answer












        You can configure the service unit with



        Type=notify
        NotifyAccess=all


        and make the last script (or a child of that) which is started by OpenVPN during initialization (wait for the desired logging output and then) call systemd-notify.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 4 '17 at 16:25









        Hauke Laging

        53.6k1282130




        53.6k1282130



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398258%2fhow-to-start-a-service-upon-the-output-of-a-command%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?