I want my service to start only if another service is not active. To do so, as explained in this other question, I am going to do:
ExecStartPre=/bin/bash -xc '/usr/bin/systemctl is-active --quiet other-unit.service && exit 1 || exit 0'
However, there is a small possibility that the OS does not include /bin/bash. In that case, I'd like the service to start anyway. I was trying to achieve this by using:
ExecStartPre=which bash 2>/dev/null && /usr/bin/bash -xc '/usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service && exit 1 || exit 0' || exit 0
But systemd complains:
which[1122772]: /usr/bin/which: invalid option -- 'x'
which[1122772]: /usr/bin/which: invalid option -- 'c'
which[1122772]: /usr/bin/which: no && in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
I guess ExecStartPre= is quite limited. Is it possible to achieve what I want?