Cleanup
This commit is contained in:
parent
ed5cbb865f
commit
997cacdaeb
@ -11,7 +11,7 @@
|
|||||||
# know how you have improved it!
|
# know how you have improved it!
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
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; }
|
exiterr() { echo "Error: $1" >&2; exit 1; }
|
||||||
conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; }
|
conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; }
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# know how you have improved it!
|
# know how you have improved it!
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
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; }
|
exiterr() { echo "Error: $1" >&2; exit 1; }
|
||||||
conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; }
|
conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; }
|
||||||
|
@ -27,7 +27,7 @@ YOUR_PASSWORDS=''
|
|||||||
# =====================================================
|
# =====================================================
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
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; }
|
exiterr() { echo "Error: $1" >&2; exit 1; }
|
||||||
conf_bk() { /bin/cp -f "$1" "$1.old-$SYS_DT" 2>/dev/null; }
|
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."
|
exiterr "All VPN credentials must be specified. Edit the script and re-enter them."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VPN_USERS="$(noquotes "$VPN_USERS")"
|
VPN_USERS=$(noquotes "$VPN_USERS")
|
||||||
VPN_USERS="$(onespace "$VPN_USERS")"
|
VPN_USERS=$(onespace "$VPN_USERS")
|
||||||
VPN_USERS="$(noquotes2 "$VPN_USERS")"
|
VPN_USERS=$(noquotes2 "$VPN_USERS")
|
||||||
VPN_PASSWORDS="$(noquotes "$VPN_PASSWORDS")"
|
VPN_PASSWORDS=$(noquotes "$VPN_PASSWORDS")
|
||||||
VPN_PASSWORDS="$(onespace "$VPN_PASSWORDS")"
|
VPN_PASSWORDS=$(onespace "$VPN_PASSWORDS")
|
||||||
VPN_PASSWORDS="$(noquotes2 "$VPN_PASSWORDS")"
|
VPN_PASSWORDS=$(noquotes2 "$VPN_PASSWORDS")
|
||||||
|
|
||||||
if printf '%s' "$VPN_USERS $VPN_PASSWORDS" | LC_ALL=C grep -q '[^ -~]\+'; then
|
if printf '%s' "$VPN_USERS $VPN_PASSWORDS" | LC_ALL=C grep -q '[^ -~]\+'; then
|
||||||
exiterr "VPN credentials must not contain non-ASCII characters."
|
exiterr "VPN credentials must not contain non-ASCII characters."
|
||||||
|
@ -22,10 +22,10 @@ exiterr2() { exiterr "'apt-get install' failed."; }
|
|||||||
|
|
||||||
vpnupgrade() {
|
vpnupgrade() {
|
||||||
|
|
||||||
os_type="$(lsb_release -si 2>/dev/null)"
|
os_type=$(lsb_release -si 2>/dev/null)
|
||||||
if [ -z "$os_type" ]; then
|
if [ -z "$os_type" ]; then
|
||||||
[ -f /etc/os-release ] && os_type="$(. /etc/os-release && printf '%s' "$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")"
|
[ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID")
|
||||||
fi
|
fi
|
||||||
if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then
|
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."
|
exiterr "This script only supports Ubuntu and Debian."
|
||||||
@ -77,8 +77,8 @@ case "$SWAN_VER" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
ipsec_ver="$(/usr/local/sbin/ipsec --version 2>/dev/null)"
|
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_short=$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//')
|
||||||
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|
||||||
exiterr "This script requires Libreswan already installed."
|
exiterr "This script requires Libreswan already installed."
|
||||||
fi
|
fi
|
||||||
@ -202,7 +202,7 @@ EOF
|
|||||||
if [ "$(packaging/utils/lswan_detect.sh init)" = "systemd" ]; then
|
if [ "$(packaging/utils/lswan_detect.sh init)" = "systemd" ]; then
|
||||||
apt-get -yq install libsystemd-dev || exiterr2
|
apt-get -yq install libsystemd-dev || exiterr2
|
||||||
fi
|
fi
|
||||||
NPROCS="$(grep -c ^processor /proc/cpuinfo)"
|
NPROCS=$(grep -c ^processor /proc/cpuinfo)
|
||||||
[ -z "$NPROCS" ] && NPROCS=1
|
[ -z "$NPROCS" ] && NPROCS=1
|
||||||
make "-j$((NPROCS+1))" -s base && make -s install-base
|
make "-j$((NPROCS+1))" -s base && make -s install-base
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ case "$SWAN_VER" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
ipsec_ver="$(/usr/local/sbin/ipsec --version 2>/dev/null)"
|
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_short=$(printf '%s' "$ipsec_ver" | sed -e 's/Linux Libreswan/Libreswan/' -e 's/ (netkey) on .*//')
|
||||||
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|
if ! printf '%s' "$ipsec_ver" | grep -q "Libreswan"; then
|
||||||
exiterr "This script requires Libreswan already installed."
|
exiterr "This script requires Libreswan already installed."
|
||||||
fi
|
fi
|
||||||
@ -199,7 +199,7 @@ USE_DNSSEC = false
|
|||||||
USE_DH31 = false
|
USE_DH31 = false
|
||||||
USE_GLIBC_KERN_FLIP_HEADERS = true
|
USE_GLIBC_KERN_FLIP_HEADERS = true
|
||||||
EOF
|
EOF
|
||||||
NPROCS="$(grep -c ^processor /proc/cpuinfo)"
|
NPROCS=$(grep -c ^processor /proc/cpuinfo)
|
||||||
[ -z "$NPROCS" ] && NPROCS=1
|
[ -z "$NPROCS" ] && NPROCS=1
|
||||||
make "-j$((NPROCS+1))" -s base && make -s install-base
|
make "-j$((NPROCS+1))" -s base && make -s install-base
|
||||||
|
|
||||||
|
14
vpnsetup.sh
14
vpnsetup.sh
@ -34,7 +34,7 @@ YOUR_PASSWORD=''
|
|||||||
# =====================================================
|
# =====================================================
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
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; }
|
exiterr() { echo "Error: $1" >&2; exit 1; }
|
||||||
exiterr2() { exiterr "'apt-get install' failed."; }
|
exiterr2() { exiterr "'apt-get install' failed."; }
|
||||||
@ -48,10 +48,10 @@ check_ip() {
|
|||||||
|
|
||||||
vpnsetup() {
|
vpnsetup() {
|
||||||
|
|
||||||
os_type="$(lsb_release -si 2>/dev/null)"
|
os_type=$(lsb_release -si 2>/dev/null)
|
||||||
if [ -z "$os_type" ]; then
|
if [ -z "$os_type" ]; then
|
||||||
[ -f /etc/os-release ] && os_type="$(. /etc/os-release && printf '%s' "$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")"
|
[ -f /etc/lsb-release ] && os_type=$(. /etc/lsb-release && printf '%s' "$DISTRIB_ID")
|
||||||
fi
|
fi
|
||||||
if ! printf '%s' "$os_type" | head -n 1 | grep -qiF -e ubuntu -e debian -e raspbian; then
|
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."
|
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
|
if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
|
||||||
bigecho "VPN credentials not set by user. Generating random PSK and password..."
|
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_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
|
fi
|
||||||
|
|
||||||
if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then
|
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
|
if [ "$(packaging/utils/lswan_detect.sh init)" = "systemd" ]; then
|
||||||
apt-get -yq install libsystemd-dev || exiterr2
|
apt-get -yq install libsystemd-dev || exiterr2
|
||||||
fi
|
fi
|
||||||
NPROCS="$(grep -c ^processor /proc/cpuinfo)"
|
NPROCS=$(grep -c ^processor /proc/cpuinfo)
|
||||||
[ -z "$NPROCS" ] && NPROCS=1
|
[ -z "$NPROCS" ] && NPROCS=1
|
||||||
make "-j$((NPROCS+1))" -s base && make -s install-base
|
make "-j$((NPROCS+1))" -s base && make -s install-base
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ YOUR_PASSWORD=''
|
|||||||
# =====================================================
|
# =====================================================
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
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; }
|
exiterr() { echo "Error: $1" >&2; exit 1; }
|
||||||
exiterr2() { exiterr "'yum install' failed."; }
|
exiterr2() { exiterr "'yum install' failed."; }
|
||||||
@ -84,9 +84,9 @@ fi
|
|||||||
|
|
||||||
if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
|
if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
|
||||||
bigecho "VPN credentials not set by user. Generating random PSK and password..."
|
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_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
|
fi
|
||||||
|
|
||||||
if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then
|
if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then
|
||||||
@ -194,7 +194,7 @@ USE_DNSSEC = false
|
|||||||
USE_DH31 = false
|
USE_DH31 = false
|
||||||
USE_GLIBC_KERN_FLIP_HEADERS = true
|
USE_GLIBC_KERN_FLIP_HEADERS = true
|
||||||
EOF
|
EOF
|
||||||
NPROCS="$(grep -c ^processor /proc/cpuinfo)"
|
NPROCS=$(grep -c ^processor /proc/cpuinfo)
|
||||||
[ -z "$NPROCS" ] && NPROCS=1
|
[ -z "$NPROCS" ] && NPROCS=1
|
||||||
make "-j$((NPROCS+1))" -s base && make -s install-base
|
make "-j$((NPROCS+1))" -s base && make -s install-base
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user