summaryrefslogtreecommitdiff
path: root/playbooks.d/vpn-tinc/playbook.bash
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks.d/vpn-tinc/playbook.bash')
-rw-r--r--playbooks.d/vpn-tinc/playbook.bash20
1 files changed, 15 insertions, 5 deletions
diff --git a/playbooks.d/vpn-tinc/playbook.bash b/playbooks.d/vpn-tinc/playbook.bash
index 6a6a957..485c6e6 100644
--- a/playbooks.d/vpn-tinc/playbook.bash
+++ b/playbooks.d/vpn-tinc/playbook.bash
@@ -17,15 +17,17 @@ playbook_add()
local name
local tinc
local tincd
+ local port
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")"
+ port="$(config "$BASHTARD_PLAYBOOK.port" "655")"
+ etc="$(config "fs.etcdir")/tinc/$name"
case "${BASHTARD_PLATFORM[key]}" in
freebsd) iptool=ifconfig ;;
@@ -41,10 +43,6 @@ playbook_add()
"$etc" \
"$etc/hosts"
- file_template tinc.conf \
- "name=$host" \
- > "$etc/tinc.conf"
-
file_template "tinc-up-$iptool" \
"ip4=$ipv4" \
"ip6=$ipv6" \
@@ -58,6 +56,7 @@ playbook_add()
file_template "host" \
"ip4=$ipv4" \
"ip6=$ipv6" \
+ "port=$port" \
> "$etc/hosts/$host"
chmod +x \
@@ -139,6 +138,17 @@ playbook_sync()
cp -v -- "$data/hosts/$file" "$etc/hosts/$file"
done
+ info "$BASHTARD_PLAYBOOK/sync" "Reconfiguring peers"
+ {
+ printf "Name = %s\n\n" "$host"
+
+ while read -r peer
+ do
+ printf "ConnectTo = %s\n" "$(config "$BASHTARD_PLAYBOOK.peers.$peer")"
+ done < <( config_subkeys "$BASHTARD_PLAYBOOK.peers" )
+ } > "$etc/tinc.conf"
+
+
[[ "$BASHTARD_COMMAND" == "add" ]] && return
[[ "$hash" == "$(dir_hash "$etc/hosts")" ]] && return