Add variables and install script
This commit is contained in:
parent
e0c7ce3fca
commit
513a95ec4b
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
variables.conf
|
||||
.disabled
|
12
README.md
12
README.md
@ -5,5 +5,15 @@ This repository contains setup or configuration files for [LibreELEC](https://li
|
||||
### WireGuard VPN setup
|
||||
* copy `~/.config/wireguard/wireguard.config.sample` to a new file, and adjust the parameters (see
|
||||
https://wiki.libreelec.tv/configuration/wireguard for reference)
|
||||
|
||||
### Files
|
||||
* `set-resolv-conf.sh` moves last DNS entry up in `/etc/resolv.conf` (is called after VPN initialization)
|
||||
* TOFINISH
|
||||
* `variables.conf.template` contains examples variables definitions, and should be copied locally to `variables.conf`
|
||||
(with any required modifications).
|
||||
* `systemd-templates/` contains Systemd units templates for detecting VPN connection, and apply routes and DNS
|
||||
modifications.
|
||||
#### Installation
|
||||
* `install.sh` script copies Systemd templates to their destination, and enables trigger.
|
||||
|
||||
### TODO
|
||||
* Define a trigger
|
||||
|
23
install.sh
Normal file
23
install.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
run_directory=$(dirname $(readlink -f "$0"))
|
||||
|
||||
source "$run_directory/variables.conf"
|
||||
|
||||
if [ -f $run_directory/.disabled ]; then
|
||||
echo "Installation is disabled. Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Copying Systemd units to system directory..."
|
||||
$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_NETWORK:$target_network:g" /etc/systemd/system/set-ip-routes.service
|
||||
|
||||
echo "Reloading Systemd..."
|
||||
$sudo systemctl daemon-reload
|
||||
echo "Enabling timer (not starting it, either do it manually or reboot)..." # TODO replace by new trigger
|
||||
$sudo systemctl enable conf-sync.timer
|
||||
|
||||
echo "Finished install. Exiting..."
|
||||
exit 0
|
@ -4,6 +4,6 @@ Description=Update IP routes after connecting to VPN
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/ip route del default dev wg0
|
||||
ExecStart=/usr/sbin/ip route add 192.168.0.63 dev wg0
|
||||
ExecStart=/usr/sbin/ip route add 192.168.3.0/24 dev wg0
|
||||
ExecStart=/usr/sbin/ip route add PH_DNS dev wg0
|
||||
ExecStart=/usr/sbin/ip route add PH_NETWORK dev wg0
|
||||
ExecStart=/storage/libreelec-conf/set-resolv-conf.sh
|
6
variables.conf.template
Normal file
6
variables.conf.template
Normal file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copy this file as variables.conf, with the correct values
|
||||
|
||||
dns_server=192.168.0.63
|
||||
target_network=192.168.3.0/24
|
Loading…
Reference in New Issue
Block a user