]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
ncat-client-server: do not always call sudo and use env bash
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 21 May 2018 23:08:51 +0000 (01:08 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 22 May 2018 14:41:59 +0000 (16:41 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
contrib/ncat-client-server/client-quick.sh

index 25ff6150ab16b5b36c6086faa6f132c4862cd65d..8ef8f70abe7c8e06e8a236f1649dbf1119d1122f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # SPDX-License-Identifier: GPL-2.0
 #
 # Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. 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