local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount"
local confd="${new_srv_path}.d"
mkdir -p "${confd}"
- cat <<EOF >> "$confd/isu.conf.tmp" || return 1
+ if [ "$INSTANCE" = "system" ]; then
+ cat <<EOF >> "$confd/isu.conf.tmp" || return 1
+# Automatically generated by $0
[Unit]
After=${mount_unit}
BindsTo=${mount_unit}
EOF
+ else
+# User session unit can not depend on system session units, thus we can't really use After=/etc. here.
+# However, given that we guarantee that isu .mount units are mounted in local-fs.target, which is part
+# of basic.target, it should be enough to depend on the DefaultDependencies logic.
+ cat <<EOF >> "$confd/isu.conf.tmp" || return 1
+# Automatically generated by $0
+[Unit]
+DefaultDependencies=yes
+EOF
+ fi
# make new unit visible
mv "${confd}/isu.conf.tmp" "${confd}/isu.conf" || return 1
# install_mount_unit() invocation - for the same ISU package, but different
# .service file
cat <<EOF >> "$UNITDIR/$mount_unit" || return 1
-# This unit file has been automatically generated by isu-generator.
-#
-# Do not edit this file as it will be re-created at next generator run.
-
+# Automatically generated by $0
[Unit]
DefaultDependencies=no
+Before=local-fs.target
[Mount]
What=${PKGDIR}/${isu_pkg_name}/rootfs.img
Where=${RUNDIR}/${isu_pkg_name}/rootfs
EOF
+ mkdir -p "$UNITDIR/local-fs.target.wants"
+ ln -s "../$mount_unit" "$UNITDIR/local-fs.target.wants/"
+
fi
return 0