diff --git a/install.sh b/install.sh index 2db79ef..4e49a5e 100755 --- a/install.sh +++ b/install.sh @@ -13,12 +13,11 @@ echo "Copying Systemd units to system directory..." cp $run_directory/systemd-templates/set-ip-routes.service /storage/.config/system.d/ sed -i -e "s/PH_DNS/$dns_server/g" /storage/.config/system.d/set-ip-routes.service sed -i -e "s:PH_NETWORK:$target_network:g" /storage/.config/system.d/set-ip-routes.service -cp $run_directory/systemd-templates/set-ip-routes.path /storage/.config/system.d/ +mkdir /storage/.config/system.d/sys-subsystem-net-devices-wg0.device.d +cp $run_directory/systemd-templates/set-ip-routes.conf /storage/.config/system.d/sys-subsystem-net-devices-wg0.device.d echo "Reloading Systemd..." systemctl daemon-reload -#echo "Enabling path unit (not starting it, either do it manually or reboot)..." -#systemctl enable set-ip-routes.path echo "Finished install. Exiting..." exit 0 diff --git a/systemd-templates/set-ip-routes.conf b/systemd-templates/set-ip-routes.conf new file mode 100644 index 0000000..2ef06c0 --- /dev/null +++ b/systemd-templates/set-ip-routes.conf @@ -0,0 +1,3 @@ +[Unit] +BindsTo=set-ip-routes.service +Before=set-ip-routes.service diff --git a/systemd-templates/set-ip-routes.path b/systemd-templates/set-ip-routes.path deleted file mode 100644 index 346826b..0000000 --- a/systemd-templates/set-ip-routes.path +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Detect WireGuard VPN activation - -[Path] -PathExists=/sys/class/net/wg0/dev_id -Unit=set-ip-routes.service - -[Install] -WantedBy=default.target diff --git a/systemd-templates/set-ip-routes.service b/systemd-templates/set-ip-routes.service index c1a2ef5..13c28aa 100644 --- a/systemd-templates/set-ip-routes.service +++ b/systemd-templates/set-ip-routes.service @@ -1,5 +1,6 @@ [Unit] Description=Update IP routes after connecting to VPN +BindsTo=sys-subsystem-net-devices-wg0.device [Service] Type=oneshot