title: Porting SystemV init script to systemd
body: <p>I am in the process of porting over a custom Linux init system from SystemV to systemd.  This init system runs a script that interrupts the normal boot process to handle some firmware versioning before bind mounting the selected version and continuing on with the boot process.</p>
  
  <p>With my SystemV setup, I had /sbin/init call /etc/inittab (no /etc/rc present at this time).  Then, inittab would launch the custom boot script with the following line:</p>
  
  <pre><code>si:S:sysinit:/opt/pkg/var/oem/etc/init.d/boot
  </code></pre>
  
  <p>Since my script needs to be run very early in the init process, I thought I would add it to the sysinit.target.wants directory.</p>
  
  <p>/lib/systemd/system/sysinit.target.wants/custom_init.service:</p>
  
  <pre><code>[Unit]
  Description=Custom System Initialization Routine
  ConditionFileIsExecutable=/etc/init.d/boot
  Before=sysinit.target shutdown.target
  
  [Service]
  Type=oneshot
  RemainAfterExit=yes
  ExecStart=/etc/init.d/boot
  </code></pre>
  
  <p>However, when I boot the system, I get the following errors:</p>
  
  <pre><code>basic.target: Found ordering cycle on basic.target/start
  basic.target: Found dependency on sysinit.target/start
  basic.target: Found dependency on custom_init.service/start
  basic.target: Found dependency on basic.target/start
  basic.target: Breaking ordering cycle by deleting job custom_init.service.service/start
  custom_init.service.service: Job custom_init.service.service/start deleted to break ordering cycle starting with basic.target/start
  [ SKIP ] Ordering cycle found, skipping Custom System Initialization Routine
  </code></pre>
  
  <p>I think the .service file should be run immediately after sbin/init (lib/systemd/systemd) is executed.  Is sysinit.target.wants the correct location for this action?</p>
  
  <p>Any thoughts on how I can rewrite this .service file to perform the same role as my old inittab without this ordering issue?  I would like to make as few changes as possible to the boot script itself.  </p>