Hi all,

I've been recently searching through internet for a possible solution for this but so far without success and I'm still not sure if it is even possible. Basically what I'm trying to do:

During system boot, after the network-online target I want to execute a script which changes the current target ( or put simply just to boot in another target, not in the default multi-user.target).

So here goes what I've done:

1. Create a service and put it in the network-online.target:

/etc/systemd/system/change-target.service:
/[Unit]//
//Description=Change Target //
//Wants=network-online.target//
//After=network-online.target//
//
//[Service]//
//Type=oneshot//
//ExecStart=/tmp/script.sh//
//TimeoutSec=60s//
//
//[Install]//
//WantedBy=network-online.target/

2. Create two new targets:
/etc/systemd/system/a.target:
/[Unit]//
//Description=A Target//
//Requires=multi-user.target//
//After=multi-user.target//
//AllowIsolate=yes//
//Conflicts=b.target/

/etc/systemd/system/b.target:
/[Unit]//
//Description=B Target//
//Requires=multi-user.target//
//After=multi-user.target//
//AllowIsolate=yes//
//Conflicts=a.target/

3. The contents of script.sh
blah blah: do some work and based on that do either
systemctl isolate a.target || systemctl isolate b.target

Note I've also edited the multi-user.target to depend on the the change-target.service by putting the latter in the former's wants and after sections. I've tried many things and every time it failed. The problem is that the systemd should "wait" for the execution of script.sh before continuing with the boot process.

The question is - is what I'm trying to achieve even possible or systemd should boot in a certain target before changing to another one ? If possible please advise what I'm doing wrong since I'm pretty lost..

---
BR,

Swetli

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to