0

I have a script that I want to run at boot, and whilst it runs I would like it to pause the boot process.

I have tried the systemd service

[Unit]
Description=setup script
Before=default.target

[Service]
Type=oneshot
ExecStart=/my/setup/script

[Install]
WantedBy=default.target

but this continues the boot process so the graphical desktop still runs even though my script has not finished yet.

Is this possible to do with systemd?

I am running this on a Raspberry Pi with Raspbian Jessie.

1 Answer 1

0

Assuming you use gdm as a login manager,

[Unit]
Description=setup script
Before=gdm.service

[Service]
Type=oneshot
ExecStart=/my/setup/script

[Install]

If you don't use gdm, find out which service starts xorg and put that in the Before= line. Explanation: There were two problems: 1. in your case default.target is likely a symlink pointing to graphical.target. so Wants=default.target indicates that it should be started after the graphical target 2. Before=default.target does not work: Targets are used to report to systemd when certain stages in the boot process are finsihed starting, not when they start to be loaded. So using a target only makes sense if you want to start something after that target was reached not before or if you want to make sure that the target is only achieved once your service finished loading.

2
  • And if I'm not using a desktop environment? Should I use Before=multi-user.target ? Commented May 26, 2016 at 20:09
  • Could you please make more clear what it is that you are trying to achieve. Above you said your problem was that the graphical desktop runs before your script is done. How can that be if you are not using a desktop environment?
    – Thawn
    Commented May 26, 2016 at 21:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.