Skip to content

Commit

Permalink
feat(wireguard): add util to print configs (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
netr0m authored Dec 20, 2024
1 parent 6364edd commit dd97ca4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tasks/deploy_wireguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,12 @@
wait_timeout: "{{ infra_compose_wait_timeout }}"
register: deploy_wireguard_services_output

- name: Copy print-qr-codes util script into place
ansible.builtin.template:
src: print-qr-codes.sh.j2
dest: "{{ infra_wireguard_directory_path }}/print-qr-codes.sh"
owner: "{{ infra_wireguard_directory_owner }}"
group: "{{ infra_wireguard_directory_group }}"
mode: "0750"

...
17 changes: 17 additions & 0 deletions templates/print-qr-codes.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /usr/bin/env bash

# util to print QR codes for wireguard configs
# requires 'jq' and 'qrencode' to be installed

if ! command -v jq &> /dev/null; then
echo "Missing required package 'jq'"
exit 1
elif ! command -v qrencode &> /dev/null; then
echo "Missing required package 'qrencode'"
exit 1
fi

for wgcfg in $(docker volume inspect {{ infra_wireguard_volume_name_config }} | jq '.[].Mountpoint' | sed 's/"//g')/peer_*/peer_*.conf; do
echo $(basename "$wgcfg")
qrencode -t ansiutf8 < "$wgcfg"
done

0 comments on commit dd97ca4

Please sign in to comment.