From: Jason A. Donenfeld Date: Mon, 21 May 2018 23:08:51 +0000 (+0200) Subject: ncat-client-server: do not always call sudo and use env bash X-Git-Tag: v1.0.20191226~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=550119bb08262cd8ab60d48e0610dbe109f7531d;p=thirdparty%2Fwireguard-tools.git ncat-client-server: do not always call sudo and use env bash Signed-off-by: Jason A. Donenfeld --- diff --git a/contrib/ncat-client-server/client-quick.sh b/contrib/ncat-client-server/client-quick.sh index 25ff615..8ef8f70 100755 --- a/contrib/ncat-client-server/client-quick.sh +++ b/contrib/ncat-client-server/client-quick.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0 # # Copyright (C) 2015-2018 Jason A. Donenfeld . All Rights Reserved. @@ -19,7 +19,8 @@ IFS=: read -r status server_pubkey server_port internal_ip <&7 [[ $status == OK ]] || exit 1 echo "[+] Writing config file." -sudo sh -c 'umask 077; mkdir -p /etc/wireguard; cat > /etc/wireguard/demo.conf' <<_EOF +[[ $UID -eq 0 ]] || sudo=sudo +$sudo sh -c 'umask 077; mkdir -p /etc/wireguard; cat > /etc/wireguard/demo.conf' <<_EOF [Interface] PrivateKey = $privatekey Address = $internal_ip/24