diff options
Diffstat (limited to 'playbooks.d/vpn-tinc/playbook.bash')
-rw-r--r-- | playbooks.d/vpn-tinc/playbook.bash | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/playbooks.d/vpn-tinc/playbook.bash b/playbooks.d/vpn-tinc/playbook.bash index 91d79f5..909dc8f 100644 --- a/playbooks.d/vpn-tinc/playbook.bash +++ b/playbooks.d/vpn-tinc/playbook.bash @@ -11,8 +11,6 @@ playbook_add() local data local etc local host - local ipv4 - local ipv6 local name local tinc local tincd @@ -20,17 +18,10 @@ 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" @@ -39,24 +30,6 @@ playbook_add() "$etc" \ "$etc/hosts" - file_template tinc.conf \ - "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" \ @@ -77,12 +50,13 @@ playbook_add() info "$BASHTARD_PLAYBOOK/add" "Adding new host to Bashtard configs" mkdir -pv -- "$data/hosts" + + playbook_sync + cp -v -- \ "$etc/hosts/$host" \ "$data/hosts/$host" - playbook_sync - info "$BASHTARD_PLAYBOOK" "Enabling VPN service" case "${BASHTARD_PLATFORM[key]}" in @@ -117,14 +91,43 @@ playbook_sync() local etc 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.conf \ + "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" + info "$BASHTARD_PLAYBOOK" "Regenerating tinc hosts" rm -fr -- "$etc/hosts" mkdir -p -- "$etc/hosts" |