Add Systemd path as trigger for service

This commit is contained in:
Alexandre CATTEAU 2023-06-03 12:54:27 +02:00
parent 513a95ec4b
commit 216702239d
3 changed files with 11 additions and 4 deletions

View File

@ -13,7 +13,7 @@ https://wiki.libreelec.tv/configuration/wireguard for reference)
* `systemd-templates/` contains Systemd units templates for detecting VPN connection, and apply routes and DNS * `systemd-templates/` contains Systemd units templates for detecting VPN connection, and apply routes and DNS
modifications. modifications.
#### Installation #### Installation
* `install.sh` script copies Systemd templates to their destination, and enables trigger. * `install.sh` script copies Systemd templates to their destination, and enables trigger (Systemd path).
### TODO ### TODO
* Define a trigger * RAS

View File

@ -13,11 +13,12 @@ echo "Copying Systemd units to system directory..."
$sudo cp $run_directory/systemd-templates/set-ip-routes.service /etc/systemd/system/ $sudo cp $run_directory/systemd-templates/set-ip-routes.service /etc/systemd/system/
$sudo sed -i -e "s/PH_DNS/$dns_server/g" /etc/systemd/system/set-ip-routes.service $sudo sed -i -e "s/PH_DNS/$dns_server/g" /etc/systemd/system/set-ip-routes.service
$sudo sed -i -e "s:PH_NETWORK:$target_network:g" /etc/systemd/system/set-ip-routes.service $sudo sed -i -e "s:PH_NETWORK:$target_network:g" /etc/systemd/system/set-ip-routes.service
$sudo cp $run_directory/systemd-templates/set-ip-routes.path /etc/systemd/system/
echo "Reloading Systemd..." echo "Reloading Systemd..."
$sudo systemctl daemon-reload $sudo systemctl daemon-reload
echo "Enabling timer (not starting it, either do it manually or reboot)..." # TODO replace by new trigger echo "Enabling path unit (not starting it, either do it manually or reboot)..."
$sudo systemctl enable conf-sync.timer $sudo systemctl enable set-ip-routes.path
echo "Finished install. Exiting..." echo "Finished install. Exiting..."
exit 0 exit 0

View File

@ -0,0 +1,6 @@
[Unit]
Description=Detect WireGuard VPN activation
[Path]
PathExists=/sys/class/net/wg0
Unit=set-ip-routes.service