How to add user input when starting a service in systemd - linux

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?

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.

Related

su log file location

I prompted a failed su attemp in order to observe the log.
However, I couldn't find where su writes its logs.
My box is Kali 2019.
I commented out the SULOG section in my /etc/login.defs file
# If defined, all su activity is logged to this file.
#
SULOG_FILE /var/log/sulog
Despite having done that I still don't have sulog file in /var/log.
I created one manually and made the wrong attempt again but nothing.
I am missing something?
Thank you all in advance.
many times, login attempts or request for a new login shell are logged into os mailbox and/or on your system log.
It depend on your os default configs.
Try to check file:
/var/spool/mail/
or try:
journalctl -r
to see all your system log starting by newest

Error autostarting Linux service after reboot if condition is met: "Path in condition not absolute, ignoring"

I have a service named MyService that needs to auto-start a NodeJS process only if "Configured!" can be found inside of a configuration file. The MyService.service file contains the following in the Service section:
ExecStart=/usr/bin/sh -c "if grep -q 'Configured!' /path/to/configuration/file.conf; then /usr/bin/node /path/to/node/process.js; fi"
However, the problem is that the NodeJS process does not auto-start. In fact, when I look in journalctl, I see the following error message:
Path in condition not absolute, ignoring: "/path/to/configuration/file.conf"
How can I please change ExecStart to successfully auto-start the NodeJS process when the condition has been met? This is very puzzling because when I run the ExecStart command on the command line, it works correctly. Also, the path to the configuration file is an absolute path.
(Also, please note that since this machine is running an old version of systemd, I am not able to use ExecCondition.)
The issue is with double quotes in :
"/path/to/configuration/file.conf"
which makes systemd think it's not a absolute path.

Freeradius problem reading google_authenticator secrets Centos 7

I have a freeradius server setup with google authenticator to provide a basic working multi-factor setup.
Everything works when I run radiusd in debug mode as root. If I start it as a service, logons fail and this messages is recorded when processing messages:
radiusd(pam_google_authenticator)[1115]: Failed to read "/home/user#domain.com/.google_authenticator" for "user#domain.com"
I think this must be a permissions issue since it works fine when run as root.
I don't really want to edit the permissions on each secret file for every user.
I have tried specifying root in
/etc/raddb/radiusd.conf
user = root group = root
but still the service fails unless run from the command line as root. Does anyone have a nice elegant solution to this conundrum?
I think you should check out your systemd service file for radiusd. It might look something like:
https://github.com/ipfire/ipfire-3.x/blob/master/freeradius/systemd/freeradius.service
You can add User= and Group= in the [Service] section of the .service file if needed. See
https://unix.stackexchange.com/questions/347358/how-to-change-service-user-in-centos-7
and
https://serverfault.com/questions/806617/configuring-systemd-service-to-run-with-root-access
It would be a good idea to put the contents of the .service file for radiusd in your post.

Nagios is not reading values from a file of another server

i have written a bash script. If I run this script manually on same server then its output is
CRITICAL:Something really bad is happening on server.CPU load of Process id: 11109
for user: root with command: java is 76.5
Then I configured its alert on nagios, and nagios is reading its output like
CRITICAL:Something really bad is happening on server.CPU load of Process id:
for user: with command: is
Means values are missing driven from file.
That's most likely happening because generally Nagios uses a user "nagios" or "nrpe" to execute the script plugins and that user is not able to view all processes like root does or does not have the permission to read the file you are asking it to read. You should give the nrpe user permission to read via "sudo" to solve your issue. Please note that in order to run sudo with a user that does not log in(as the Nagios user), you also nees to commebt out the Require tty parameter from /etc/sudoers file.

No lock file found in /usr/local/nagios/var/nagios.lock

I followed the instructions at this link which I found here on EE...http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html
Well after trying to stop nagios with command service nagios stop and after that to see its status with service nagios status the following message appears: "No lock file found in /usr/local/nagios/var/nagios.lock". How do I resolve it.
Thanks.
This is not a bug. "No lock file found in /usr/local/nagios/var/nagios.lock" means that it isn't running.
If you run an echo $? directly after service nagios status while it isn't running, you'll notice that the exit code is 3.
3 is the correct value return code for that status as documented in the Linux Standard Base.
Some Sources:
https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
http://ftp.novell.hu/pub/mirrors/ftp.novell.com/forge/library/SUSE%20Package%20Conventions/spc_init_scripts.html
Just run:
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
UPDATE:
The error: "No lock file found in /usr/local/nagios/var/nagios.lock" simply means that nagios is not running.
Running the command above simply starts the nagios daemon and points it to a specific config file. The advantage to running this command manually over systemd is that when you run "service nagios start" this typically calls the /etc/rc.d/init.d/nagios script which contains a line with parametrized environment variables:
$NagiosBin -d $NagiosCfgFile
Because every system is different, not specifying either the bin nor config directories could lead to nagios breaking (stopping) when it tries to start using the default installation directory paths

Resources