From b7dca0a8a5bbd9de2b6b499c1344725841c294cc Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 22 May 2018 01:08:51 +0200 Subject: ncat-client-server: do not always call sudo and use env bash --- contrib/examples/ncat-client-server/client-quick.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'contrib/examples/ncat-client-server') diff --git a/contrib/examples/ncat-client-server/client-quick.sh b/contrib/examples/ncat-client-server/client-quick.sh index 25ff615..8ef8f70 100755 --- a/contrib/examples/ncat-client-server/client-quick.sh +++ b/contrib/examples/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 -- cgit v1.2.3-59-g8ed1b