summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-26 22:52:07 +0300
committerPaul Buetow <paul@buetow.org>2025-04-26 22:52:07 +0300
commit91977db042be28cfdabc65d4466455752861c121 (patch)
tree15778954bae44573a1418ec37c48958a27669e40
parent9599b70752d1261d3f95bafb0fad8a9372d0676c (diff)
can upload wireguard config to hosts
-rw-r--r--README.md21
-rw-r--r--wireguardmeshgenerator.rb12
-rw-r--r--wireguardmeshgenerator.yaml6
3 files changed, 28 insertions, 11 deletions
diff --git a/README.md b/README.md
index 4d3b38d..5e4ff3f 100644
--- a/README.md
+++ b/README.md
@@ -44,18 +44,19 @@ keys/r2/pubkey
### FreeBSD
-https://docs.vultr.com/how-to-install-wireguard-vpn-on-freebsd-14-0
-
```sh
-doas freebsd-update fetch..... and so on
-doas pkg install wireguard-tools
-
-paul@f0:~ % doas sysrc wireguard_interfaces="wg0"
-wireguard_interfaces: -> wg0
-
-paul@f0:~ % doas sysrc wireguard_enable="YES"
-wireguard_enable: -> YES
+doas freebsd-update fetch..... and so on... reboot
+doas pkg update
+doas pkg upgrade
+reboot
+doas pkg install wireguard-tools
```
+### Rocky Linux 9
+```sh
+dnf update -y
+reboot
+dnf install wireguard-tools
+```
diff --git a/wireguardmeshgenerator.rb b/wireguardmeshgenerator.rb
index 19949ff..9c32e45 100644
--- a/wireguardmeshgenerator.rb
+++ b/wireguardmeshgenerator.rb
@@ -2,6 +2,7 @@
require 'yaml'
require 'fileutils'
+require 'English'
# Generates Wireguard keys and config files for each host
class KeyTool
@@ -75,6 +76,15 @@ WireguardConfig = Struct.new(:myself, :hosts) do
dist_dir = "dist/#{myself}/etc/wireguard"
FileUtils.mkdir_p(dist_dir) unless Dir.exist?(dist_dir)
File.write("#{dist_dir}/wg0.conf", to_s)
+ self
+ end
+
+ def upload!
+ ssh_user = hosts[myself]['lan']['ssh_user']
+ wg0_conf = "dist/#{myself}/etc/wireguard/wg0.conf"
+ puts "Uploading #{wg0_conf} to #{myself}:."
+ system("scp #{wg0_conf} #{ssh_user}@#{myself}:.")
+ raise "Unable to upload #{wg0_conf} to #{myself}" unless $CHILD_STATUS.success?
end
private
@@ -91,5 +101,5 @@ end
CONFIG = YAML.load_file('wireguardmeshgenerator.yaml').freeze
CONFIG['hosts'].each_key do |hostname|
- WireguardConfig.new(hostname, CONFIG['hosts']).generate!
+ WireguardConfig.new(hostname, CONFIG['hosts']).generate!.upload!
end
diff --git a/wireguardmeshgenerator.yaml b/wireguardmeshgenerator.yaml
index 148bc51..a123b83 100644
--- a/wireguardmeshgenerator.yaml
+++ b/wireguardmeshgenerator.yaml
@@ -3,6 +3,7 @@ wg_tool: /usr/bin/wg
hosts:
f0:
lan:
+ ssh_user: paul
domain: 'lan.buetow.org'
ip: '192.168.1.130'
wg0:
@@ -10,6 +11,7 @@ hosts:
ip: '192.168.2.130'
f1:
lan:
+ ssh_user: paul
domain: 'lan.buetow.org'
ip: '192.168.1.131'
wg0:
@@ -17,6 +19,7 @@ hosts:
ip: '192.168.2.131'
f2:
lan:
+ ssh_user: paul
domain: 'lan.buetow.org'
ip: '192.168.1.132'
wg0:
@@ -24,6 +27,7 @@ hosts:
ip: '192.168.2.132'
r0:
lan:
+ ssh_user: root
domain: 'lan.buetow.org'
ip: '192.168.1.120'
wg0:
@@ -31,6 +35,7 @@ hosts:
ip: '192.168.2.120'
r1:
lan:
+ ssh_user: root
domain: 'lan.buetow.org'
ip: '192.168.1.121'
wg0:
@@ -38,6 +43,7 @@ hosts:
ip: '192.168.2.121'
r2:
lan:
+ ssh_user: root
domain: 'lan.buetow.org'
ip: '192.168.1.122'
wg0: