linuxunixsystemdsystemctl

How to add user input when starting a service in systemd


I have a service configured in systemd that runs a binary file and it runs constantly. The problem is that after running this binary file, you have to confirm Terms&Conditions by typing y in the terminal and validating it by click Enter. I cannot run this file through this, because the systemctl status appears to me as failed, because of lack of validation. Does anyone know how I can run this service and automatically accept Terms in terminal?


Solution

  • I figured it out in such a way: I created .sh file in usr/bin with this content:

    #!/usr/bin/bash
    yes | /home/marek/webcash/webminer
    

    Then I created config file in systemd with ExecStart: /path/to/file.sh

    and now it works - systemd is running correctly, the logs are logging, the answer "yes" was typed only once in binary file when the user prompt appeared.