1
0
mirror of synced 2024-11-22 04:56:03 +03:00
- Improve temporary folder creation
This commit is contained in:
hwdsl2 2021-08-28 16:07:52 -05:00
parent da7697a5b0
commit 217bf2a237
4 changed files with 25 additions and 29 deletions

View File

@ -1017,18 +1017,17 @@ apply_ubuntu1804_nss_fix() {
nss_deb1="libnss3_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"
TMPDIR=$(mktemp -d /tmp/nss.XXXXX 2>/dev/null)
if [ -d "$TMPDIR" ]; then
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
bigecho2 "Applying fix for NSS bug on Ubuntu 18.04..."
export DEBIAN_FRONTEND=noninteractive
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/3.deb" "$nss_url2/$nss_deb3"; then
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/3.deb" "$nss_url2/$nss_deb3"; then
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
/bin/rm -f "$TMPDIR/1.deb" "$TMPDIR/2.deb" "$TMPDIR/3.deb"
/bin/rmdir "$TMPDIR"
/bin/rm -f "$tmpdir/1.deb" "$tmpdir/2.deb" "$tmpdir/3.deb"
/bin/rmdir "$tmpdir"
fi
fi
}

View File

@ -155,11 +155,10 @@ get_setup_url() {
run_setup() {
status=0
TMPDIR=$(mktemp -d /tmp/vpnsetup.XXXXX 2>/dev/null)
if [ -d "$TMPDIR" ]; then
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
if /bin/bash "$TMPDIR/vpn.sh"; then
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
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
if /bin/bash "$tmpdir/vpn.sh"; then
if [ -s /opt/src/ikev2.sh ] && [ ! -f /etc/ipsec.d/ikev2.conf ]; then
sleep 1
/bin/bash /opt/src/ikev2.sh --auto || status=1
@ -171,8 +170,8 @@ run_setup() {
status=1
echo "Error: Could not download VPN setup script." >&2
fi
/bin/rm -f "$TMPDIR/vpn.sh"
/bin/rmdir "$TMPDIR"
/bin/rm -f "$tmpdir/vpn.sh"
/bin/rmdir "$tmpdir"
else
exiterr "Could not create temporary directory."
fi

View File

@ -138,17 +138,16 @@ get_setup_url() {
run_setup() {
status=0
TMPDIR=$(mktemp -d /tmp/vpnup.XXXXX 2>/dev/null)
if [ -d "$TMPDIR" ]; then
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
VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$TMPDIR/vpnup.sh" || status=1
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
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
VPN_UPDATE_SWAN_VER="$SWAN_VER" /bin/bash "$tmpdir/vpnup.sh" || status=1
else
status=1
echo "Error: Could not download update script." >&2
fi
/bin/rm -f "$TMPDIR/vpnup.sh"
/bin/rmdir "$TMPDIR"
/bin/rm -f "$tmpdir/vpnup.sh"
/bin/rmdir "$tmpdir"
else
exiterr "Could not create temporary directory."
fi

View File

@ -209,22 +209,21 @@ get_setup_url() {
run_setup() {
status=0
TMPDIR=$(mktemp -d /tmp/vpnsetup.XXXXX 2>/dev/null)
if [ -d "$TMPDIR" ]; then
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
if tmpdir=$(mktemp --tmpdir -d vpn.XXXXX 2>/dev/null); then
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
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_L2TP_LOCAL="$VPN_L2TP_LOCAL" VPN_L2TP_POOL="$VPN_L2TP_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" \
/bin/bash "$TMPDIR/vpn.sh" || status=1
/bin/bash "$tmpdir/vpn.sh" || status=1
else
status=1
echo "Error: Could not download VPN setup script." >&2
fi
/bin/rm -f "$TMPDIR/vpn.sh"
/bin/rmdir "$TMPDIR"
/bin/rm -f "$tmpdir/vpn.sh"
/bin/rmdir "$tmpdir"
else
exiterr "Could not create temporary directory."
fi