It really depends on your definition of "booted". I assume you want it to run immediately after the getty starts. To do this, you need to add your service to /etc/systemd/system/getty.target.wants/
directory. You should also ensure your file is using similar code to the other services in this directory. To run a custom service on bootup and shutdown (just beeps my motherboard buzzer) I use the following script in /etc/systemd/system/getty.target.wants/service_name.service
[Unit]
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
Before=getty.target
IgnoreOnIsolate=yes
[Service]
ExecStart=/usr/bin/myinitscript.sh start
ExecStop=/usr/bin/myinitscript.sh stop
Type=oneshot
RemainAfterExit=true
[Install]
WantedBy=basic.target
/usr/bin/myinitscript.sh
is executable and has a shebang at the start.
Note that not everything will be started at this point in the boot, but this is the point at which the logon prompt appears to the user
Although this does use Before=
and After=
, it was for me much more understandable and actually works; I didn't find the above answer informative enough. This is also allows you to use both ExecStart=
and ExecStop=
, rather than being limited to a Type=simple
-like service.