#!/system/bin/sh
# This file is generated by Nix-on-Droid. DO NOT EDIT.
set -eu -o pipefail

export USER="nix-on-droid"
export HOME="/data/data/com.termux.nix/files/home"
export PROOT_TMP_DIR=/data/data/com.termux.nix/files/usr/tmp
export PROOT_L2S_DIR=/data/data/com.termux.nix/files/usr/.l2s

if ! /system/bin/pgrep proot-static > /dev/null; then
  if test -e /data/data/com.termux.nix/files/usr/bin/.proot-static.new; then
    echo "Installing new proot-static..."
    /system/bin/mv /data/data/com.termux.nix/files/usr/bin/.proot-static.new /data/data/com.termux.nix/files/usr/bin/proot-static
  fi

  if test -e /data/data/com.termux.nix/files/usr/usr/lib/.login-inner.new; then
    echo "Installing new login-inner..."
    /system/bin/mv /data/data/com.termux.nix/files/usr/usr/lib/.login-inner.new /data/data/com.termux.nix/files/usr/usr/lib/login-inner
  fi
fi

if [ ! -r /proc/stat ] && [ -e /data/data/com.termux.nix/files/usr/nix/store/773374jwy00i2k0jj8vbn2v1gzhw3xik-fakeProcStat ]; then
  BIND_PROC_STAT="-b /data/data/com.termux.nix/files/usr/nix/store/773374jwy00i2k0jj8vbn2v1gzhw3xik-fakeProcStat:/proc/stat"
else
  BIND_PROC_STAT=""
fi

if [ ! -r /proc/uptime ] && [ -e /data/data/com.termux.nix/files/usr/nix/store/wlgfl8f6was55bskjqc4jshi0l5ma8z9-fakeProcUptime ]; then
  BIND_PROC_UPTIME="-b /data/data/com.termux.nix/files/usr/nix/store/wlgfl8f6was55bskjqc4jshi0l5ma8z9-fakeProcUptime:/proc/uptime"
else
  BIND_PROC_UPTIME=""
fi

exec /data/data/com.termux.nix/files/usr/bin/proot-static \
  -b /data/data/com.termux.nix/files/usr/nix:/nix \
  -b /data/data/com.termux.nix/files/usr/bin:/bin \
  -b /data/data/com.termux.nix/files/usr/etc:/etc \
  -b /data/data/com.termux.nix/files/usr/tmp:/tmp \
  -b /data/data/com.termux.nix/files/usr/usr:/usr \
  -b /data/data/com.termux.nix/files/usr/dev/shm:/dev/shm \
  $BIND_PROC_STAT \
  $BIND_PROC_UPTIME \
  -b /:/android \
  --link2symlink \
  --sysvipc \
   \
  /data/data/com.termux.nix/files/usr/bin/sh /data/data/com.termux.nix/files/usr/usr/lib/login-inner "$@"
