diff --git a/extras/add_vpn_user.sh b/extras/add_vpn_user.sh index ca40a5d..12a1f09 100644 --- a/extras/add_vpn_user.sh +++ b/extras/add_vpn_user.sh @@ -11,7 +11,7 @@ # know how you have improved it! export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -SYS_DT="$(date +%F-%T)" +SYS_DT=$(date +%F-%T) exiterr() { echo "Error: $1" >&2; exit 1; } conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; } diff --git a/extras/del_vpn_user.sh b/extras/del_vpn_user.sh index 02e20cf..e176dd5 100644 --- a/extras/del_vpn_user.sh +++ b/extras/del_vpn_user.sh @@ -11,7 +11,7 @@ # know how you have improved it! export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -SYS_DT="$(date +%F-%T)" +SYS_DT=$(date +%F-%T) exiterr() { echo "Error: $1" >&2; exit 1; } conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; } diff --git a/extras/update_vpn_users.sh b/extras/update_vpn_users.sh index fd1774d..4db4223 100644 --- a/extras/update_vpn_users.sh +++ b/extras/update_vpn_users.sh @@ -27,7 +27,7 @@ YOUR_PASSWORDS='' # ===================================================== export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -SYS_DT="$(date +%F-%T)" +SYS_DT=$(date +%F-%T) exiterr() { echo "Error: $1" >&2; exit 1; } conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; } @@ -65,12 +65,12 @@ if [ -z "$VPN_USERS" ] || [ -z "$VPN_PASSWORDS" ]; then exiterr "All VPN credentials must be specified. Edit the script and re-enter them." fi -VPN_USERS="$(noquotes "$VPN_USERS")" -VPN_USERS="$(onespace "$VPN_USERS")" -VPN_USERS="$(noquotes2 "$VPN_USERS")" -VPN_PASSWORDS="$(noquotes "$VPN_PASSWORDS")" -VPN_PASSWORDS="$(onespace "$VPN_PASSWORDS")" -VPN_PASSWORDS="$(noquotes2 "$VPN_PASSWORDS")" +VPN_USERS=$(noquotes "$VPN_USERS") +VPN_USERS=$(onespace "$VPN_USERS") +VPN_USERS=$(noquotes2 "$VPN_USERS") +VPN_PASSWORDS=$(noquotes "$VPN_PASSWORDS") +VPN_PASSWORDS=$(onespace "$VPN_PASSWORDS") +VPN_PASSWORDS=$(noquotes2 "$VPN_PASSWORDS") if printf '%s' "$VPN_USERS $VPN_PASSWORDS" | LC_ALL=C grep -q '[^ -~]\+'; then exiterr "VPN credentials must not contain non-ASCII characters." diff --git a/extras/vpnupgrade.sh b/extras/vpnupgrade.sh index 45b9504..a91fab2 100644 --- a/extras/vpnupgrade.sh +++ b/extras/vpnupgrade.sh @@ -22,10 +22,10 @@ exiterr2() { exiterr "'apt-get install' failed."; } vpnupgrade() { -os_type="$(lsb_release -si 2>/dev/null)" +os_type=$(lsb_release -si 2>/dev/null) if [ -z "$os_type" ]; then - [ -f /etc/os-release ] && os_type="$(. /etc/os-release && printf '%s' "$ID")" - [ -f /etc/lsb-release ] && os_type="$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID")" + [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID") + [ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID") fi if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then exiterr "This script only supports Ubuntu and Debian." @@ -77,8 +77,8 @@ case "$SWAN_VER" in ;; esac -ipsec_ver="$(/usr/local/sbin/ipsec --version 2>/dev/null)" -ipsec_ver_short="$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//')" +ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) +ipsec_ver_short=$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//') if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then exiterr "This script requires Libreswan already installed." fi @@ -202,7 +202,7 @@ EOF if [ "$(packaging/utils/lswan_detect.sh init)" = "systemd" ]; then apt-get -yq install libsystemd-dev || exiterr2 fi -NPROCS="$(grep -c ^processor /proc/cpuinfo)" +NPROCS=$(grep -c ^processor /proc/cpuinfo) [ -z "$NPROCS" ] && NPROCS=1 make "-j$((NPROCS+1))" -s base && make -s install-base diff --git a/extras/vpnupgrade_centos.sh b/extras/vpnupgrade_centos.sh index a3eb542..fb33eb9 100644 --- a/extras/vpnupgrade_centos.sh +++ b/extras/vpnupgrade_centos.sh @@ -68,8 +68,8 @@ case "$SWAN_VER" in ;; esac -ipsec_ver="$(/usr/local/sbin/ipsec --version 2>/dev/null)" -ipsec_ver_short="$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//')" +ipsec_ver=$(/usr/local/sbin/ipsec --version 2>/dev/null) +ipsec_ver_short=$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//') if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then exiterr "This script requires Libreswan already installed." fi @@ -199,7 +199,7 @@ USE_DNSSEC = false USE_DH31 = false USE_GLIBC_KERN_FLIP_HEADERS = true EOF -NPROCS="$(grep -c ^processor /proc/cpuinfo)" +NPROCS=$(grep -c ^processor /proc/cpuinfo) [ -z "$NPROCS" ] && NPROCS=1 make "-j$((NPROCS+1))" -s base && make -s install-base diff --git a/vpnsetup.sh b/vpnsetup.sh index 3d3db0e..8bb8bca 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -34,7 +34,7 @@ YOUR_PASSWORD='' # ===================================================== export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -SYS_DT="$(date +%F-%T)" +SYS_DT=$(date +%F-%T) exiterr() { echo "Error: $1" >&2; exit 1; } exiterr2() { exiterr "'apt-get install' failed."; } @@ -48,10 +48,10 @@ check_ip() { vpnsetup() { -os_type="$(lsb_release -si 2>/dev/null)" +os_type=$(lsb_release -si 2>/dev/null) if [ -z "$os_type" ]; then - [ -f /etc/os-release ] && os_type="$(. /etc/os-release && printf '%s' "$ID")" - [ -f /etc/lsb-release ] && os_type="$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID")" + [ -f /etc/os-release ] && os_type=$(. /etc/os-release && printf '%s' "$ID") + [ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID") fi if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then exiterr "This script only supports Ubuntu and Debian." @@ -95,9 +95,9 @@ fi if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then bigecho "VPN credentials not set by user. Generating random PSK and password..." - VPN_IPSEC_PSK="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 20)" + VPN_IPSEC_PSK=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 20) VPN_USER=vpnuser - VPN_PASSWORD="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 16)" + VPN_PASSWORD=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 16) fi if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then @@ -207,7 +207,7 @@ EOF if [ "$(packaging/utils/lswan_detect.sh init)" = "systemd" ]; then apt-get -yq install libsystemd-dev || exiterr2 fi -NPROCS="$(grep -c ^processor /proc/cpuinfo)" +NPROCS=$(grep -c ^processor /proc/cpuinfo) [ -z "$NPROCS" ] && NPROCS=1 make "-j$((NPROCS+1))" -s base && make -s install-base diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index c133bc4..8be592e 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -34,7 +34,7 @@ YOUR_PASSWORD='' # ===================================================== export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -SYS_DT="$(date +%F-%T)" +SYS_DT=$(date +%F-%T) exiterr() { echo "Error: $1" >&2; exit 1; } exiterr2() { exiterr "'yum install' failed."; } @@ -84,9 +84,9 @@ fi if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then bigecho "VPN credentials not set by user. Generating random PSK and password..." - VPN_IPSEC_PSK="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 20)" + VPN_IPSEC_PSK=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 20) VPN_USER=vpnuser - VPN_PASSWORD="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 16)" + VPN_PASSWORD=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 16) fi if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then @@ -194,7 +194,7 @@ USE_DNSSEC = false USE_DH31 = false USE_GLIBC_KERN_FLIP_HEADERS = true EOF -NPROCS="$(grep -c ^processor /proc/cpuinfo)" +NPROCS=$(grep -c ^processor /proc/cpuinfo) [ -z "$NPROCS" ] && NPROCS=1 make "-j$((NPROCS+1))" -s base && make -s install-base