feat: add installer script and builder tools

- Added install.sh for easy setup and teardown
- Added build.sh and build.bat to dynamically assemble install.sh
- Updated README.md with new installation instructions
- Fixed bidirectional WG_POLICY FORWARD rule routing in wg-policy-engine.sh
This commit is contained in:
datadunia
2026-05-01 15:35:31 +07:00
parent 0b19a9061f
commit 760e0e88fa
5 changed files with 1577 additions and 23 deletions
+23 -15
View File
@@ -15,22 +15,30 @@ Rather than allowing all VPN clients to reach any part of your internal network,
---
## 📁 File Locations & Installation
## 📁 Installation
All scripts must be placed in `/usr/local/bin/` and made executable.
The easiest way to install is using the provided `install.sh` script, which automatically installs dependencies, copies all scripts to `/usr/local/bin/`, sets up the systemd daemon, and enables the service.
| File | Location | Description |
|------|----------|-------------|
| `wg-policy-lib.sh` | `/usr/local/bin/wg-policy-lib.sh` | Shared library and core validation tools. |
| `wg-sync-policy.sh` | `/usr/local/bin/wg-sync-policy.sh` | Extracts config into atomic JSON format. |
| `wg-policy-engine.sh` | `/usr/local/bin/wg-policy-engine.sh` | Translates JSON into iptables & ipset logic. |
| `wg-policy-cleanup.sh` | `/usr/local/bin/wg-policy-cleanup.sh` | Reverts and cleans up all firewall traces safely. |
| `wg-sync-watch.sh` | `/usr/local/bin/wg-sync-watch.sh` | Debounced file watcher (daemon). |
| `wg-policy-ctl` | `/usr/local/bin/wg-policy-ctl` | Handy command-line interface tool. |
Make sure they are executable:
```bash
chmod +x /usr/local/bin/wg-*.sh /usr/local/bin/wg-policy-ctl
# Install everything
sudo ./install.sh install
# Uninstall everything
sudo ./install.sh uninstall
```
### Building the Installer (For Developers)
If you modify any of the source `.sh` or `.service` files, you must rebuild the `install.sh` script using the provided builders.
**On Linux (Bash):**
```bash
./build.sh
```
**On Windows (CMD/PowerShell):**
```cmd
build.bat
```
---
@@ -132,9 +140,9 @@ wg-policy-ctl validate
## 🔧 Systemd Integration (Watcher Daemon)
If you are using the daemon mode to auto-sync changes instantly upon editing `wg0.conf` (without needing to run `wg-policy-ctl reload` or restarting the interface).
If you use the `install.sh` script, the daemon is automatically installed, enabled, and started for you. It monitors `wg0.conf` for changes and triggers the pipeline seamlessly.
### 1. File Installation
### Manual File Installation (If not using install.sh)
Place the three provided systemd unit files into `/etc/systemd/system/`.
| Systemd File | Location | Description |