From 489feff4f35682eb99c60aeb1446bda789889947 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 11 Dec 2017 11:51:25 +0100 Subject: Do not install addon.d if no directory Some ROMs don't support this. While we're at it, add more error reporting. --- standalone-tools/installer.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/standalone-tools/installer.sh b/standalone-tools/installer.sh index 84dacdc..c285e4c 100644 --- a/standalone-tools/installer.sh +++ b/standalone-tools/installer.sh @@ -47,19 +47,28 @@ echo "ui_print = by zx2c4 =" >&$OUTFD echo "ui_print = www.wireguard.com =" >&$OUTFD echo "ui_print ==================================" >&$OUTFD +[ -n $ARCH ] || die "Could not determine architecture" +[ -f "$ZIP" ] || die "Could not find zip file" + trap cleanup INT TERM EXIT mount_system +print "Extracting files" rm -rf /tmp/wireguard mkdir -p /tmp/wireguard -print "Extracting files" unzip -d /tmp/wireguard "$ZIP" -[ -d /tmp/wireguard/arch/$ARCH ] || die "Not available for device's ABI" + print "Installing WireGuard tools" -cp /tmp/wireguard/arch/$(getprop ro.product.cpu.abi)/* /system/xbin/ -cp /tmp/wireguard/addon.d/40-wireguard.sh /system/addon.d/ -chmod 755 /system/xbin/wg /system/xbin/wg-quick /system/addon.d/40-wireguard.sh +[ -d /tmp/wireguard/arch/$ARCH ] || die "Not available for device's ABI" +cp -f /tmp/wireguard/arch/$ARCH/* /system/xbin/ || die "Could not copy binaries" +chmod 755 /system/xbin/wg /system/xbin/wg-quick || die "Could not mark binaries as executable" + +if [ -d /system/addon.d ]; then + print "Installing ROM flash survial script" + cp -f /tmp/wireguard/addon.d/40-wireguard.sh /system/addon.d/ || die "Could not copy survival script" + chmod 755 /system/addon.d/40-wireguard.sh || die "Could not mark survival script as executable" +fi mkdir -pm 700 /data/misc/wireguard print "Success! Be sure your kernel has the WireGuard module enabled." -- cgit v1.2.3-59-g8ed1b