aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/wg-quick.bash
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/wg-quick.bash')
-rwxr-xr-xsrc/tools/wg-quick.bash7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash
index 80921bf..af72f7d 100755
--- a/src/tools/wg-quick.bash
+++ b/src/tools/wg-quick.bash
@@ -27,7 +27,7 @@ PROGRAM="${0##*/}"
ARGS=( "$@" )
parse_options() {
- local interface_section=0 line key value
+ local interface_section=0 line key value stripped
CONFIG_FILE="$1"
[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf"
[[ -e $CONFIG_FILE ]] || die "\`$CONFIG_FILE' does not exist"
@@ -37,8 +37,9 @@ parse_options() {
INTERFACE="${BASH_REMATCH[2]}"
shopt -s nocasematch
while read -r line || [[ -n $line ]]; do
- key="${line%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
- value="${line#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
+ stripped="${line%%\#*}"
+ key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
+ value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
[[ $key == "["* ]] && interface_section=0
[[ $key == "[Interface]" ]] && interface_section=1
if [[ $interface_section -eq 1 ]]; then