Prompting for input before tty1 with systemd?

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











up vote
0
down vote

favorite












I'm trying to understand systemd more and figure out how to modify the startup process. What I'm trying to do is prompt the user for an input before loading the login screen.
I went ahead and ran "systemctl list-dependencies getty@tty1.service" and got the below (not full output):



getty@tty1.service
├─system-getty.slice
└─sysinit.target


From what I understand, everything in the tree is either a hard/soft dependency, so I created a basic service unit file as such:



[Unit]
Description=Something to do

[Service]
ExecStart=/root/script.sh

[Install]
RequiredBy=getty@tty1.service


I went and enabled the service and re-checked the dependencies for getty@tty1.service and saw:



getty@tty1.service
├─system-getty.slice
├─wantedservice.service
└─sysinit.target


So I'm assuming now getty@tty1.service will not start until wantedservice is active (wantedservice is just a bash script asking for user input and then echoing it back out) due to the "RequiredBy" initiative, but it simply isn't the case; the login screen will still come up and when I check the status of wantedservice after login it just says inactive.



Here is "script.sh" just in case:



#!/bin/bash
echo "What is your name?"
read _name
echo "Hello $_name!"


So here are some questions I have:



1) How does systemd decide if a service is "active" (in my case, does it consider my service "active" after the script completes?"



2) I sometimes see my script pop up for a second before the login screen basically overtakes it, so it's loading, but its just not sticking around waiting for input, any idea what might be happening there?



I'm don't think it's relevant but all this is being done from a Debian 9 VM if it matters. Thanks all!









share







New contributor




vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I'm trying to understand systemd more and figure out how to modify the startup process. What I'm trying to do is prompt the user for an input before loading the login screen.
    I went ahead and ran "systemctl list-dependencies getty@tty1.service" and got the below (not full output):



    getty@tty1.service
    ├─system-getty.slice
    └─sysinit.target


    From what I understand, everything in the tree is either a hard/soft dependency, so I created a basic service unit file as such:



    [Unit]
    Description=Something to do

    [Service]
    ExecStart=/root/script.sh

    [Install]
    RequiredBy=getty@tty1.service


    I went and enabled the service and re-checked the dependencies for getty@tty1.service and saw:



    getty@tty1.service
    ├─system-getty.slice
    ├─wantedservice.service
    └─sysinit.target


    So I'm assuming now getty@tty1.service will not start until wantedservice is active (wantedservice is just a bash script asking for user input and then echoing it back out) due to the "RequiredBy" initiative, but it simply isn't the case; the login screen will still come up and when I check the status of wantedservice after login it just says inactive.



    Here is "script.sh" just in case:



    #!/bin/bash
    echo "What is your name?"
    read _name
    echo "Hello $_name!"


    So here are some questions I have:



    1) How does systemd decide if a service is "active" (in my case, does it consider my service "active" after the script completes?"



    2) I sometimes see my script pop up for a second before the login screen basically overtakes it, so it's loading, but its just not sticking around waiting for input, any idea what might be happening there?



    I'm don't think it's relevant but all this is being done from a Debian 9 VM if it matters. Thanks all!









    share







    New contributor




    vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to understand systemd more and figure out how to modify the startup process. What I'm trying to do is prompt the user for an input before loading the login screen.
      I went ahead and ran "systemctl list-dependencies getty@tty1.service" and got the below (not full output):



      getty@tty1.service
      ├─system-getty.slice
      └─sysinit.target


      From what I understand, everything in the tree is either a hard/soft dependency, so I created a basic service unit file as such:



      [Unit]
      Description=Something to do

      [Service]
      ExecStart=/root/script.sh

      [Install]
      RequiredBy=getty@tty1.service


      I went and enabled the service and re-checked the dependencies for getty@tty1.service and saw:



      getty@tty1.service
      ├─system-getty.slice
      ├─wantedservice.service
      └─sysinit.target


      So I'm assuming now getty@tty1.service will not start until wantedservice is active (wantedservice is just a bash script asking for user input and then echoing it back out) due to the "RequiredBy" initiative, but it simply isn't the case; the login screen will still come up and when I check the status of wantedservice after login it just says inactive.



      Here is "script.sh" just in case:



      #!/bin/bash
      echo "What is your name?"
      read _name
      echo "Hello $_name!"


      So here are some questions I have:



      1) How does systemd decide if a service is "active" (in my case, does it consider my service "active" after the script completes?"



      2) I sometimes see my script pop up for a second before the login screen basically overtakes it, so it's loading, but its just not sticking around waiting for input, any idea what might be happening there?



      I'm don't think it's relevant but all this is being done from a Debian 9 VM if it matters. Thanks all!









      share







      New contributor




      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I'm trying to understand systemd more and figure out how to modify the startup process. What I'm trying to do is prompt the user for an input before loading the login screen.
      I went ahead and ran "systemctl list-dependencies getty@tty1.service" and got the below (not full output):



      getty@tty1.service
      ├─system-getty.slice
      └─sysinit.target


      From what I understand, everything in the tree is either a hard/soft dependency, so I created a basic service unit file as such:



      [Unit]
      Description=Something to do

      [Service]
      ExecStart=/root/script.sh

      [Install]
      RequiredBy=getty@tty1.service


      I went and enabled the service and re-checked the dependencies for getty@tty1.service and saw:



      getty@tty1.service
      ├─system-getty.slice
      ├─wantedservice.service
      └─sysinit.target


      So I'm assuming now getty@tty1.service will not start until wantedservice is active (wantedservice is just a bash script asking for user input and then echoing it back out) due to the "RequiredBy" initiative, but it simply isn't the case; the login screen will still come up and when I check the status of wantedservice after login it just says inactive.



      Here is "script.sh" just in case:



      #!/bin/bash
      echo "What is your name?"
      read _name
      echo "Hello $_name!"


      So here are some questions I have:



      1) How does systemd decide if a service is "active" (in my case, does it consider my service "active" after the script completes?"



      2) I sometimes see my script pop up for a second before the login screen basically overtakes it, so it's loading, but its just not sticking around waiting for input, any idea what might be happening there?



      I'm don't think it's relevant but all this is being done from a Debian 9 VM if it matters. Thanks all!







      debian systemd





      share







      New contributor




      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 mins ago









      vng21092

      11




      11




      New contributor




      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      vng21092 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











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



          );






          vng21092 is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478128%2fprompting-for-input-before-tty1-with-systemd%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          vng21092 is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          vng21092 is a new contributor. Be nice, and check out our Code of Conduct.












          vng21092 is a new contributor. Be nice, and check out our Code of Conduct.











          vng21092 is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478128%2fprompting-for-input-before-tty1-with-systemd%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)