#!/bin/sh

## for armv7 and higher cpu with hardfloat support use armhf
#ARCH=amd64, armel, armhf, arm64, mips, mipsel
ARCH=armel

## debian codenames
#DISTRO=oldoldstable - The previous old stable release (jessie).
#DISTRO=oldstable - The previous stable release (stretch).
#DISTRO=stable - The current stable release (buster).
#DISTRO=testing - The next generation release (bullseye).
#DISTRO=unstable - The unstable development release (sid).
DISTRO=stable

## target installation folder
TARGET=/opt/debian

## extra packages to install
#INCLUDE="--include=sudo,nano,wget"
INCLUDE=

## variant
#VARIANT="--variant=minbase"
VARIANT=

## unofficial mirror
#MIRROR=http://mirror.yandex.ru/debian/
## official mirror
MIRROR=http://ftp.debian.org/debian/

unset LD_LIBRARY_PATH
unset LD_PRELOAD

/opt/sbin/debootstrap $VARIANT $INCLUDE --arch $ARCH $DISTRO $TARGET $MIRROR

## disable services autostart
cat > /opt/debian/usr/sbin/policy-rc.d <<EOF
#!/bin/sh
exit 101
EOF
chmod a+x /opt/debian/usr/sbin/policy-rc.d

## add Entware path at the end
echo "PATH=\$PATH:/opt/bin:/opt/sbin" >> /opt/debian/etc/profile

## add more secure tty's
echo "pts/0" >> /opt/debian/etc/securetty
echo "pts/1" >> /opt/debian/etc/securetty
echo "pts/2" >> /opt/debian/etc/securetty

echo "Please run /opt/etc/init.d/S99debian start"
echo "Please run start-debian,change password with passwd command and run 'apt-get update'"
