0

As part of a system-provisioning process for Ubuntu 14.04, I would like to prevent user logins until my script has completed. I have an upstart job with the following contents:

start on (local-filesystems and net-device-up IFACE!=lo)
stop on [!12345]

script
    #launch the bash script that does install
    /bin/bash /path/to/provisioning-script.sh
end script

This script runs at startup, but it does not prevent users from logging in. I have also tried the start directive

start on starting lightdm

But:

  1. it doesn't prevent logins
  2. applies only to systems using lightdm. Some of our systems boot to command line only

I have achieved the results I want in ubuntu 16.04 (systemd) with the following code:

[Unit]
DefaultDependencies=no
After=network.target
Before=systemd-user-sessions.service

[Service]
Type=oneshot
ExecStart=/bin/bash /path/to/provisioning-script.sh
StandardOutput=journal+console
StandardError=journal+console

[Install]
RequiredBy=systemd-user-sessions.service

Thanks!

0

I answered the first part of the question. Instead of running the script in the started phase of the service, I want to run it in the prestart phase. To so this, I needed to add prestart in front of the script tag.

Essentially, the result is that the service is not considered started until the prestart commands are complete, and the lightdm service won't start until my service is started.

start on starting lightdm
stop on [!12345]

prestart script
    #launch the bash script that does install
    /bin/bash /path/to/provisioning-script.sh
end script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.