From 397789cea60237f357476c86df96cd234e7b37eb Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 17 Sep 2022 16:57:12 +0700 Subject: all: add script wg-activate.sh The wg-activate.sh is script that activate only one wireguard connection from list of configuration in /etc/wireguard/*.conf or turning off all of them if no parameter is given. --- etc/bash_completion.d/wg-activate | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 etc/bash_completion.d/wg-activate (limited to 'etc/bash_completion.d') diff --git a/etc/bash_completion.d/wg-activate b/etc/bash_completion.d/wg-activate new file mode 100644 index 0000000..a0f5486 --- /dev/null +++ b/etc/bash_completion.d/wg-activate @@ -0,0 +1,24 @@ +#/usr/bin/env bash +## SPDX-FileCopyrightText: 2022 M. Shulhan +## SPDX-License-Identifier: GPL-3.0-or-later + +_wg-activate_completions() +{ + confs=$(find -L /etc/wireguard -maxdepth 1 -type f -name "*.conf" -print) + + names=() + for f in $confs; do + got=$(basename "${f%.conf}") + names+=("$got") + done + + if [[ -z "${COMP_WORDS[1]}" ]]; then + COMPREPLY=("${names[@]}") + return + fi + + words="${names[@]}" + COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[1]}")) +} + +complete -F _wg-activate_completions wg-activate.sh -- cgit v1.3