Red Hat Enterprise Linux 7
We have a custom service that starts a configuration script. We don't want the RHEL7 system to allow any logins (including ssh or local black & white ttys) until the script has finished. How?
How to disallow login in RHEL 7 until a SysV init script has finished?
Create a unit file for the service which must be started before logins are allowed
The file should be located in either <code>/usr/lib/systemd/system/</code> or <code>/etc/systemd/system/</code>1
A service unit named MYSERVICE would have file named <code>MYSERVICE.service</code>
Ensure the service definition2 meets AT LEAST the following conditions
Raw
<code>[Unit] Before=sshd.service systemd-logind.service [email protected] [Service] Type=oneshot ExecStart=/path/to/script "script args" "more script args" TimeoutStartSec=0 [Install] RequiredBy=sshd.service systemd-logind.service [email protected]</code>
After modifying (or creating) the service unit file, run the following commands, even if MYSERVICE was already enabled
<code>systemctl daemon-reload systemctl enable MYSERVICE.service</code>
Reboot and note that sshd and console login screens (not including serial) will fail to start until MYSERVICE has started