Cleanup
- Improve temporary folder creation
This commit is contained in:
parent
da7697a5b0
commit
217bf2a237
@ -1017,18 +1017,17 @@ apply_ubuntu1804_nss_fix() {
|
|||||||
nss_deb1="libnss3_3.49.1-1ubuntu1.5_amd64.deb"
|
nss_deb1="libnss3_3.49.1-1ubuntu1.5_amd64.deb"
|
||||||
nss_deb2="libnss3-dev_3.49.1-1ubuntu1.5_amd64.deb"
|
nss_deb2="libnss3-dev_3.49.1-1ubuntu1.5_amd64.deb"
|
||||||
nss_deb3="libnss3-tools_3.49.1-1ubuntu1.5_amd64.deb"
|
nss_deb3="libnss3-tools_3.49.1-1ubuntu1.5_amd64.deb"
|
||||||
TMPDIR=$(mktemp -d /tmp/nss.XXXXX 2>/dev/null)
|
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||||
if [ -d "$TMPDIR" ]; then
|
|
||||||
bigecho2 "Applying fix for NSS bug on Ubuntu 18.04..."
|
bigecho2 "Applying fix for NSS bug on Ubuntu 18.04..."
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
if wget -t 3 -T 30 -q -O "$TMPDIR/1.deb" "$nss_url1/$nss_deb1" \
|
if wget -t 3 -T 30 -q -O "$tmpdir/1.deb" "$nss_url1/$nss_deb1" \
|
||||||
&& wget -t 3 -T 30 -q -O "$TMPDIR/2.deb" "$nss_url1/$nss_deb2" \
|
&& wget -t 3 -T 30 -q -O "$tmpdir/2.deb" "$nss_url1/$nss_deb2" \
|
||||||
&& wget -t 3 -T 30 -q -O "$TMPDIR/3.deb" "$nss_url2/$nss_deb3"; then
|
&& wget -t 3 -T 30 -q -O "$tmpdir/3.deb" "$nss_url2/$nss_deb3"; then
|
||||||
apt-get -yqq update
|
apt-get -yqq update
|
||||||
apt-get -yqq install "$TMPDIR/1.deb" "$TMPDIR/2.deb" "$TMPDIR/3.deb" >/dev/null
|
apt-get -yqq install "$tmpdir/1.deb" "$tmpdir/2.deb" "$tmpdir/3.deb" >/dev/null
|
||||||
fi
|
fi
|
||||||
/bin/rm -f "$TMPDIR/1.deb" "$TMPDIR/2.deb" "$TMPDIR/3.deb"
|
/bin/rm -f "$tmpdir/1.deb" "$tmpdir/2.deb" "$tmpdir/3.deb"
|
||||||
/bin/rmdir "$TMPDIR"
|
/bin/rmdir "$tmpdir"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -155,11 +155,10 @@ get_setup_url() {
|
|||||||
|
|
||||||
run_setup() {
|
run_setup() {
|
||||||
status=0
|
status=0
|
||||||
TMPDIR=$(mktemp -d /tmp/vpnsetup.XXXXX 2>/dev/null)
|
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||||
if [ -d "$TMPDIR" ]; then
|
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url" \
|
||||||
if ( set -x; wget -t 3 -T 30 -q -O "$TMPDIR/vpn.sh" "$setup_url" \
|
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||||
|| curl -fsL "$setup_url" -o "$TMPDIR/vpn.sh" 2>/dev/null ); then
|
if /bin/bash "$tmpdir/vpn.sh"; then
|
||||||
if /bin/bash "$TMPDIR/vpn.sh"; then
|
|
||||||
if [ -s /opt/src/ikev2.sh ] && [ ! -f /etc/ipsec.d/ikev2.conf ]; then
|
if [ -s /opt/src/ikev2.sh ] && [ ! -f /etc/ipsec.d/ikev2.conf ]; then
|
||||||
sleep 1
|
sleep 1
|
||||||
/bin/bash /opt/src/ikev2.sh --auto || status=1
|
/bin/bash /opt/src/ikev2.sh --auto || status=1
|
||||||
@ -171,8 +170,8 @@ run_setup() {
|
|||||||
status=1
|
status=1
|
||||||
echo "Error: Could not download VPN setup script." >&2
|
echo "Error: Could not download VPN setup script." >&2
|
||||||
fi
|
fi
|
||||||
/bin/rm -f "$TMPDIR/vpn.sh"
|
/bin/rm -f "$tmpdir/vpn.sh"
|
||||||
/bin/rmdir "$TMPDIR"
|
/bin/rmdir "$tmpdir"
|
||||||
else
|
else
|
||||||
exiterr "Could not create temporary directory."
|
exiterr "Could not create temporary directory."
|
||||||
fi
|
fi
|
||||||
|
@ -138,17 +138,16 @@ get_setup_url() {
|
|||||||
|
|
||||||
run_setup() {
|
run_setup() {
|
||||||
status=0
|
status=0
|
||||||
TMPDIR=$(mktemp -d /tmp/vpnup.XXXXX 2>/dev/null)
|
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||||
if [ -d "$TMPDIR" ]; then
|
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpnup.sh" "$setup_url" \
|
||||||
if ( set -x; wget -t 3 -T 30 -q -O "$TMPDIR/vpnup.sh" "$setup_url" \
|
|| curl -fsL "$setup_url" -o "$tmpdir/vpnup.sh" 2>/dev/null ); then
|
||||||
|| curl -fsL "$setup_url" -o "$TMPDIR/vpnup.sh" 2>/dev/null ); then
|
VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$tmpdir/vpnup.sh" || status=1
|
||||||
VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$TMPDIR/vpnup.sh" || status=1
|
|
||||||
else
|
else
|
||||||
status=1
|
status=1
|
||||||
echo "Error: Could not download update script." >&2
|
echo "Error: Could not download update script." >&2
|
||||||
fi
|
fi
|
||||||
/bin/rm -f "$TMPDIR/vpnup.sh"
|
/bin/rm -f "$tmpdir/vpnup.sh"
|
||||||
/bin/rmdir "$TMPDIR"
|
/bin/rmdir "$tmpdir"
|
||||||
else
|
else
|
||||||
exiterr "Could not create temporary directory."
|
exiterr "Could not create temporary directory."
|
||||||
fi
|
fi
|
||||||
|
13
vpnsetup.sh
13
vpnsetup.sh
@ -209,22 +209,21 @@ get_setup_url() {
|
|||||||
|
|
||||||
run_setup() {
|
run_setup() {
|
||||||
status=0
|
status=0
|
||||||
TMPDIR=$(mktemp -d /tmp/vpnsetup.XXXXX 2>/dev/null)
|
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
|
||||||
if [ -d "$TMPDIR" ]; then
|
if ( set -x; wget -t 3 -T 30 -q -O "$tmpdir/vpn.sh" "$setup_url" \
|
||||||
if ( set -x; wget -t 3 -T 30 -q -O "$TMPDIR/vpn.sh" "$setup_url" \
|
|| curl -fsL "$setup_url" -o "$tmpdir/vpn.sh" 2>/dev/null ); then
|
||||||
|| curl -fsL "$setup_url" -o "$TMPDIR/vpn.sh" 2>/dev/null ); then
|
|
||||||
VPN_IPSEC_PSK="$VPN_IPSEC_PSK" VPN_USER="$VPN_USER" VPN_PASSWORD="$VPN_PASSWORD" \
|
VPN_IPSEC_PSK="$VPN_IPSEC_PSK" VPN_USER="$VPN_USER" VPN_PASSWORD="$VPN_PASSWORD" \
|
||||||
VPN_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
|
VPN_PUBLIC_IP="$VPN_PUBLIC_IP" VPN_L2TP_NET="$VPN_L2TP_NET" \
|
||||||
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \
|
VPN_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_POOL" \
|
||||||
VPN_XAUTH_NET="$VPN_XAUTH_NET" VPN_XAUTH_POOL="$VPN_XAUTH_POOL" \
|
VPN_XAUTH_NET="$VPN_XAUTH_NET" VPN_XAUTH_POOL="$VPN_XAUTH_POOL" \
|
||||||
VPN_DNS_SRV1="$VPN_DNS_SRV1" VPN_DNS_SRV2="$VPN_DNS_SRV2" \
|
VPN_DNS_SRV1="$VPN_DNS_SRV1" VPN_DNS_SRV2="$VPN_DNS_SRV2" \
|
||||||
/bin/bash "$TMPDIR/vpn.sh" || status=1
|
/bin/bash "$tmpdir/vpn.sh" || status=1
|
||||||
else
|
else
|
||||||
status=1
|
status=1
|
||||||
echo "Error: Could not download VPN setup script." >&2
|
echo "Error: Could not download VPN setup script." >&2
|
||||||
fi
|
fi
|
||||||
/bin/rm -f "$TMPDIR/vpn.sh"
|
/bin/rm -f "$tmpdir/vpn.sh"
|
||||||
/bin/rmdir "$TMPDIR"
|
/bin/rmdir "$tmpdir"
|
||||||
else
|
else
|
||||||
exiterr "Could not create temporary directory."
|
exiterr "Could not create temporary directory."
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user