[arch-projects] [netcfg] [PATCH 7/8] systemd: Allow explicit dependencies between profiles

Thomas Bächler thomas at archlinux.org
Fri Oct 26 17:09:17 EDT 2012


There may be situations where a profile requires another. For example, we
can create several tap interfaces and add them to a bridge. On boot, the
device dependencies should take care of the correct ordering, if all required
profiles are enabled. If they are not, or if a user runs
 systemctl start netcfg-profile-mybridge.service
then the required profiles should be pulled in. In the systemd case, this
patch introduces a new DEPENDS=() array to add those dependencies.
---
 systemd/netcfg-generator | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/systemd/netcfg-generator b/systemd/netcfg-generator
index 6a625f4..989040d 100755
--- a/systemd/netcfg-generator
+++ b/systemd/netcfg-generator
@@ -28,7 +28,7 @@ EOF
 
 list_profiles | while read p; do
     # Clean environment before loading the profile
-    unset CONNECTION INTERFACE SLAVE_INTERFACES BRIDGE_INTERFACES VLAN_PHYS_DEV
+    unset CONNECTION INTERFACE SLAVE_INTERFACES BRIDGE_INTERFACES VLAN_PHYS_DEV DEPENDS
     load_profile "${p}" || continue
     systemd_devices=()
     extra_deps=()
@@ -59,6 +59,9 @@ list_profiles | while read p; do
             ;;
     esac
     [[ ${#systemd_devices[@]} > 0 ]] && extra_deps+=("BindsTo=${systemd_devices[*]}" "After=${systemd_devices[*]}")
+    for dep in "${DEPENDS[@]}"; do
+        extra_deps+=("Requires=netcfg-profile-${dep}.service" "After=netcfg-profile-${dep}.service")
+    done
     write_template "${p}" "${extra_deps[@]}" > "$1/netcfg-profile-${p}.service"
 done
 
-- 
1.8.0



More information about the arch-projects mailing list