rm -f "${new_srv_path}" "${new_srv_path}.tmp"
cat "$srv_path" > "$new_srv_path".tmp || return 1
- if [ -f "$SERVICES_DIR/${srv_fname}" ]; then
+ local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount"
+ if [ ! -r "$mount_unit" ]; then
# generate mount unit for ISU image and extend the service file to use it
- local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount"
+ # if mount unit already exists, it means it's been generated by previous
+ # install_units() 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.
#
What=${PKGDIR}/${isu_pkg_name}/rootfs.img
Where=${RUNDIR}/${isu_pkg_name}/rootfs
EOF
+ fi
cat <<EOF >> "$new_srv_path".tmp || return 1
After=${mount_unit}
BindsTo=${mount_unit}
EOF
- fi
# make new unit visible
mv "${new_srv_path}.tmp" "${new_srv_path}" || return 1