bare-metal-setup: Use systemd templates

The host-gpio-monitor systemd service and gbmc-bare-metal-active target
were recently changed to templates. So, those references need to be
updated here. For now, this script assumes there's only one host. It
will need to be updated, if we need this to work on multi-host machines.

Tested:
Set the bare metal flag /var/google/config-package/enable-bm.flag, and
power cycled.
Confirmed bare-metal-setup.service started before
host-gpio-monitor@0.service.
Set /run/bm-drive-cleaning-done-ack.flag
Ran “ipmitool raw 0x2e 0x32 0x79 0x2b 0x00 0x11”
Confirmed hostlogger@ttyS1.service started when
gbmc-bare-metal-active@0.target started.

presubmit:
https://fusion2.corp.google.com/cfe0fcd7-5e20-3242-a39e-55add2b3b907

Google-Bug-Id: 392972581
Google-Bug-Id: 330355581
Change-Id: I68964123c6487f67407994fea785e585fa296e60
Signed-off-by: John Wedig <johnwedig@google.com>
(cherry picked from commit f7acb2183156f07ab65f5e489555e2908c5962ac)
Platforms-Affected: platform11, platform17, platform5, platform23
diff --git a/recipes-google/bare-metal-setup/files/bare-metal-setup.service b/recipes-google/bare-metal-setup/files/bare-metal-setup.service
index 04487e5..07d6139 100644
--- a/recipes-google/bare-metal-setup/files/bare-metal-setup.service
+++ b/recipes-google/bare-metal-setup/files/bare-metal-setup.service
@@ -1,6 +1,6 @@
 [Unit]
 Description=Bare Metal Readyness Setup
-Before=google-usb-dynamic.service host-gpio-monitor.service
+Before=google-usb-dynamic.service host-gpio-monitor@0.service
 
 [Service]
 Type=oneshot
diff --git a/recipes-google/bare-metal-setup/files/bare-metal-setup.sh.in b/recipes-google/bare-metal-setup/files/bare-metal-setup.sh.in
index 9711fe5..a737b5e 100644
--- a/recipes-google/bare-metal-setup/files/bare-metal-setup.sh.in
+++ b/recipes-google/bare-metal-setup/files/bare-metal-setup.sh.in
@@ -57,11 +57,11 @@
 
     mkdir -p ${hostlogger_override_dir}
     echo "[Unit]
-BindsTo=gbmc-bare-metal-active.target
-Before=gbmc-bare-metal-active.target
+BindsTo=gbmc-bare-metal-active@0.target
+Before=gbmc-bare-metal-active@0.target
 [Install]
 WantedBy=
-WantedBy=gbmc-bare-metal-active.target
+WantedBy=gbmc-bare-metal-active@0.target
 " > "${hostlogger_override_dir}/50-bm-override.conf"
 
     # Overriding Install section does not work for already installed service
@@ -70,10 +70,10 @@
 
     systemd_etc_dir='/etc/systemd/system'
 
-    mkdir -p ${systemd_etc_dir}/gbmc-bare-metal-active.target.wants
+    mkdir -p ${systemd_etc_dir}/gbmc-bare-metal-active@0.target.wants
 
     cp -P ${systemd_etc_dir}/multi-user.target.wants/hostlogger@*.service \
-      ${systemd_etc_dir}/gbmc-bare-metal-active.target.wants/
+      ${systemd_etc_dir}/gbmc-bare-metal-active@0.target.wants/
 
     rm ${systemd_etc_dir}/multi-user.target.wants/hostlogger@*.service
 
@@ -90,10 +90,10 @@
     # hostlogger already in multi-user target, return
     ls ${systemd_etc_dir}/multi-user.target.wants/hostlogger@* > /dev/null 2>&1 && return 1
 
-    cp -P  ${systemd_etc_dir}/gbmc-bare-metal-active.target.wants/hostlogger@*.service \
+    cp -P  ${systemd_etc_dir}/gbmc-bare-metal-active@0.target.wants/hostlogger@*.service \
       ${systemd_etc_dir}/multi-user.target.wants/ 2> /dev/null
 
-    rm ${systemd_etc_dir}/gbmc-bare-metal-active.target.wants/hostlogger@*.service 2> /dev/null
+    rm ${systemd_etc_dir}/gbmc-bare-metal-active@0.target.wants/hostlogger@*.service 2> /dev/null
 }
 
 function hide_boot_drive_in_bm_mode() {