From 2d0dc51f31a4ea11e8aaccc31fc39839c6ad3b8d Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 4 Mar 2024 10:31:17 +0000 Subject: Undo some changes to vpn-tinc --- playbooks.d/vpn-tinc/playbook.bash | 58 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'playbooks.d') 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" -- cgit v1.1