summaryrefslogtreecommitdiff
path: root/playbooks.d
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2024-03-04 10:31:17 +0000
committerPatrick Spek <p.spek@tyil.nl>2024-03-04 11:53:21 +0100
commit2d0dc51f31a4ea11e8aaccc31fc39839c6ad3b8d (patch)
tree7b8773b847f0aef2dc2ba464f4f7813f2a648ebe /playbooks.d
parentf8df21c618f7f785516054812c57a9aa954a6f18 (diff)
Undo some changes to vpn-tinc
Diffstat (limited to 'playbooks.d')
-rw-r--r--playbooks.d/vpn-tinc/playbook.bash58
1 files changed, 30 insertions, 28 deletions
diff --git a/playbooks.d/vpn-tinc/playbook.bash b/playbooks.d/vpn-tinc/playbook.bash
index c163949..6a6a957 100644
--- a/playbooks.d/vpn-tinc/playbook.bash
+++ b/playbooks.d/vpn-tinc/playbook.bash
@@ -11,6 +11,9 @@ playbook_add()
local data
local etc
local host
+ local iptool
+ local ipv4
+ local ipv6
local name
local tinc
local tincd
@@ -18,14 +21,22 @@ playbook_add()
data="$(playbook_path "data")"
etc="$(config "fs.etcdir")/tinc/tyilnet"
host="$(tr "." "_" <<< "${BASHTARD_PLATFORM[fqdn]}")"
+ ipv4="$(config "$BASHTARD_PLAYBOOK.ipv4")"
+ ipv6="$(config "$BASHTARD_PLAYBOOK.ipv6")"
name="$(config "$BASHTARD_PLAYBOOK.name")"
tinc="$(config "app.tinc")"
tincd="$(config "app.tincd")"
+ case "${BASHTARD_PLATFORM[key]}" in
+ freebsd) iptool=ifconfig ;;
+ *) iptool=ip
+ esac
+
info "$BASHTARD_PLAYBOOK/add" "Installing tinc"
pkg install "tinc"
info "$BASHTARD_PLAYBOOK/add" "Creating tinc configuration at $etc"
+
mkdir -pv -- \
"$etc" \
"$etc/hosts"
@@ -34,6 +45,25 @@ playbook_add()
"name=$host" \
> "$etc/tinc.conf"
+ file_template "tinc-up-$iptool" \
+ "ip4=$ipv4" \
+ "ip6=$ipv6" \
+ > "$etc/tinc-up"
+
+ file_template "tinc-down-$iptool" \
+ "ip4=$ipv4" \
+ "ip6=$ipv6" \
+ > "$etc/tinc-down"
+
+ file_template "host" \
+ "ip4=$ipv4" \
+ "ip6=$ipv6" \
+ > "$etc/hosts/$host"
+
+ chmod +x \
+ "$etc/tinc-up" \
+ "$etc/tinc-down"
+
info "$BASHTARD_PLAYBOOK/add" "Generating private keys"
case "$($tincd --version | awk '{ print $3 }' | head -n1)" in
@@ -89,42 +119,14 @@ playbook_sync()
local hash
local host
local iptool
- local ipv4
- local ipv6
local name
data="$(playbook_path "data")"
etc="$(config "fs.etcdir")/tinc/$(config "$BASHTARD_PLAYBOOK.name")"
hash="$(dir_hash "$etc/hosts")"
host="$(tr "." "_" <<< "${BASHTARD_PLATFORM[fqdn]}")"
- ipv4="$(config "$BASHTARD_PLAYBOOK.ipv4")"
- ipv6="$(config "$BASHTARD_PLAYBOOK.ipv6")"
name="$(config "$BASHTARD_PLAYBOOK.name")"
- case "${BASHTARD_PLATFORM[key]}" in
- freebsd) iptool=ifconfig ;;
- *) iptool=ip
- esac
-
- file_template "tinc-up-$iptool" \
- "ip4=$ipv4" \
- "ip6=$ipv6" \
- > "$etc/tinc-up"
-
- file_template "tinc-down-$iptool" \
- "ip4=$ipv4" \
- "ip6=$ipv6" \
- > "$etc/tinc-down"
-
- file_template "host" \
- "ip4=$ipv4" \
- "ip6=$ipv6" \
- > "$etc/hosts/$host"
-
- chmod +x \
- "$etc/tinc-up" \
- "$etc/tinc-down"
-
info "$BASHTARD_PLAYBOOK" "Regenerating tinc hosts"
rm -fr -- "$etc/hosts"
mkdir -p -- "$etc/hosts"