Description:
Entware is repository full of apps for embeded linux like android on tv box. I have prepared installation script to install it from scratch because android is different. You have to rebuild folders in root on every reboot. Root partition is rebuilt on every boot from the image. I will use /data partition to store files (path /data/opt) and mount –bind on /opt.

Check your architecture of processor and os. My TV Box has Amlogic S912 armv8 – aarch64. Just run two commands:

uname -a
cat /proc/cpuinfo

Processor : AArch64 Processor rev 4 (aarch64)
processor : 0
processor : 1
processor : 2
processor : 3
processor : 4
processor : 5
processor : 6
processor : 7
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 wp half thumb fastmult vfp edsp neon vfpv3 tlsi vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Hardware : Amlogic

Script will download binaries for aarch64. For another you have to change URL= and DLOADER and busybox binary.

Source of the install script and repository: http://bin.entware.net/aarch64-k3.10/installer/

First you have to root your device!

On windows you will need Minimal ADB: https://forum.xda-developers.com/showthread.php?t=2317790
On linux just install android-tools-adb android-tools-fastboot.

  1. Install WiFi ADB: https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb
    or http://www.mediafire.com/file/zki6u53zom8d684/WiFi_ADB_2.0.1.zip
  2. Run WiFi ADB and connect to via adb:
    adb connect ip:5555

    Accept and remember connection on TV Box

  3. Download script (source code is on the bottom):
  4. Download busybox for armv8 because my wget on TV Box was broken (it can’t finish any download):
    https://www.busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/busybox-armv8l
  5. Push the script from disk to TV Box:
    adb push C:\Users\user\Desktop\ent-armv8-android.sh /storage/emulated/0/

    If there is permission denied use another directory.

  6. Push busybox binary:
    adb push C:\Users\user\Desktop\busybox-armv8l /storage/emulated/0/

    If there is permission denied use another directory.

  7. Run ADB shell an run all below as root with su:
    adb shell
    su
  8. Move script from emulated internal memory to another without noexec flag:
    mv /storage/emulated/0/ent-armv8-android.sh /data/local
    chmod +x /data/local/ent-armv8-android.sh

    If there will be error Read only file system, just remount it to write and run again above commands:

    mount -o rw,remount /
    mount -o rw,remount /system
  9. Run the script:
    /system/bin/sh /data/local/ent-armv8-android.sh

    If there is a /bin you will be asked for delete. Do not delete it if it is not empty, just remove that part from script. It will delete /opt as well. Then will create neccesary folders and instsall opkg, basic enteware and dropbear for SSH.

  10. Script will create autorun script in /system/etc/init.d/entstart.sh It has to be run every boot to make entware and entware services to work. If your Android rom support init.d you dont’t have to do nothing.
  11. Another Auto Start options:
    • Try to enable init.d support with Uni-Init apk or sh script: https://forum.xda-developers.com/showthread.php?t=1933849 It does not work for me.
    • Try to modify init rc scripts. (it does not work for me i’ve still got init: Service exec () does not have a SELinux domain defined.)
      1. Try to rebuild image to modify /init.rc
      2. Modify init scripts from /system/rtc/init/
    • Check for any autorun static script:
      https://android.stackexchange.com/a/69194

      $ find /etc -type f -perm +110
      $ find /etc -name "*rc"
      $ find /etc -name "init*"
      $ grep -R /data /etc
      $ grep -R /system /etc

      I have checked either:

      dmesg | grep .sh

      I’ve got few candidates:

      /system/bin/install-recovery.sh
      init: cannot find /system/bin/kodi.sh’ (No such file or directory), disabling ‘kodiconf’
      init: cannot find ‘/system/bin/dtvdata.sh’ (No such file or directory), disabling ‘dtvdatas’
      init: cannot find ‘/system/bin/factoryreset.sh’ (No such file or directory), disabling ‘factoryreset’

      You can try run init.d
      First use app Uni-init to create all files ant contexts: https://forum.xda-developers.com/showthread.php?t=1933849 and hen link your built-in in rom script to sysinit created by this app:

      ln -s /system/etc/init.d/sysinit /system/bin/kodi.sh

      now you have properly working init.d.

      There is exmaple of script to run all init.d if your need yor own:

      AUTO_START=/system/bin/autostart.sh
      touch $AUTO_START
      echo -e "#!/system/bin/sh" > $AUTO_START 
      echo -e "\n" >> $AUTO_START 
      echo -e "sleep 1" >> $AUTO_START 
      echo -e "export PATH=/sbin:/system/sbin:/system/bin:/system/xbin" >> $AUTO_START 
      echo -e "/system/bin/busybox run-parts /system/etc/init.d" >> $AUTO_START 
      echo -e "\n" >> $AUTO_START
      chmod 0755 $AUTO_START

      If SELINUX blocked you…

    • Just install app SManager: https://play.google.com/store/apps/details?id=os.tools.scriptmanager or http://www.mediafire.com/file/skh4dkla2e1d5bo/SManager_3.0.7.zip and add /system/etc/init.d/entstart.sh to autostart with su privileges. (to do that click still upper directory even there is access denied)
  12. Modify /system/etc/mkshrc and add
    export PATH=$PATH
  13. Install pyload:
    opkg install ca-bundle ca-certificates
    opkg install pyload
    opkg install python-pyopenssl openssl-util
    opkg install duktape
    opkg install pillow tesseract
    opkg install python-crypto
    opkg install unrar unzip
    opkg install p7zip
    pyload --configdir=/opt/var/pyload

ent-armv8-android.sh

#!/system/bin/sh
 
#set paths
OPT_DIR="/data/opt"
SYS_DIRS="/etc /lib /bin /tmp /lib/opkg /var/lock"
MAIN_DIR="/opt"
BBOX_BIN="/storage/emulated/0/busybox-armv8l"
AUTO_START="/system/etc/init.d/entstart"
 
 
echo "Mount to write"
mount -o rw,remount /
mount -o rw,remount /system
 
echo "Set DNS for future wget"
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf
echo "Installing busybox for fix wget"
if [ -f "$BBOX_BIN" ]
	then
	cp -rf $BBOX_BIN /system/xbin/busybox
	chmod 0755 /system/xbin/busybox
	#for i in $(/system/xbin/busybox ); do
	#	echo "$i"
	#done
	/system/xbin/busybox --install -s /system/xbin
else
	echo "Can't find $BBOX_BIN . Download it and push with adb push busybox-armv8l /storage/emulated/0/"
	echo "Sorry you have to do that manually"
	exit 1
fi
 
echo -e "Before installation we have to delete all directories in: $OPT_DIR. Just CTR+C if you are not sure or run manually\nrm -rf $OPT_DIR\nrm -rf $MAIN_DIR"
umount $MAIN_DIR
rm -ri $OPT_DIR
rm -ri $MAIN_DIR
 
if [ -d "$MAIN_DIR" ]
	then
	echo "Warning: Folder $MAIN_DIR exists! Remove an re run script"
	exit 1
else
	echo "Make $MAIN_DIR and mount --bind $OPT_DIR $MAIN_DIR"
	mkdir -p $OPT_DIR
	mkdir -p $MAIN_DIR
	mount --bind $OPT_DIR $MAIN_DIR
	#ln -s $OPT_DIR $MAIN_DIR
fi
 
if [ -d "/bin" ]
	then
	echo "Warning: Folder /bin exists! Deleting it may break you device if you are not sure just CTRL+C"
	echo "Removing /bin - if you know what are you doing just run rm -rf /bin"
	umount /bin
	rm -ri /bin
fi
	echo "Make /bin and mount --bind $OPT_DIR/bin /bin"
	mkdir -p $OPT_DIR/bin
	mkdir -p /bin
	mount --bind $OPT_DIR/bin /bin
	#ln -s $OPT_DIR/bin /bin
	echo "Link shell /bin/sh"
	ln -s /system/bin/sh /bin/sh
 
echo "Checking folders..."
for folder in $SYS_DIRS
do
  if [ -d "$OPT_DIR$folder" ]
  then
    echo "Warning: Folder $OPT_DIR$folder exists!"
  else
    mkdir -p $OPT_DIR$folder
  fi
done
echo "Exporting path"
export PATH=/bin:$PATH:/$OPT_DIR/bin:$OPT_DIR/sbin
 
# Fix for multiuser environment
chmod 777 $MAIN_DIR/tmp
 
echo "Info: Opkg package manager deployment..."
DLOADER="ld-linux-aarch64.so.1"
URL=http://bin.entware.net/aarch64-k3.10/installer
wget $URL/opkg -O /opt/bin/opkg
chmod 755 /opt/bin/opkg
wget $URL/opkg.conf -O /opt/etc/opkg.conf
wget $URL/ld-2.27.so -O /opt/lib/ld-2.27.so
wget $URL/libc-2.27.so -O /opt/lib/libc-2.27.so
wget $URL/libgcc_s.so.1 -O /opt/lib/libgcc_s.so.1
wget $URL/libpthread-2.27.so -O /opt/lib/libpthread-2.27.so
cd /opt/lib
chmod 755 ld-2.27.so
ln -s ld-2.27.so $DLOADER
ln -s libc-2.27.so libc.so.6
ln -s libpthread-2.27.so libpthread.so.0
 
echo "Info: Basic packages installation..."
/opt/bin/opkg update --force-space
/opt/bin/opkg upgrade --force-space
/opt/bin/opkg install busybox --force-space
/opt/bin/opkg install entware-opt --force-space
 
echo "Install ca certs for curl https support"
/opt/bin/opkg install ca-bundle ca-certificates --force-space
 
# Fix for multiuser environment
chmod 777 /opt/tmp
 
# now copy default files - it is an alternative installation
cp -f /opt/etc/passwd.1 /opt/etc/passwd
cp -f /opt/etc/group.1 /opt/etc/group
cp -f /opt/etc/shells.1 /opt/etc/shells
 
if [ -f /etc/localtime ]
then
    ln -sf /etc/localtime /opt/etc/localtime
fi
 
echo "Install SSH dropbear"
/opt/bin/opkg install dropbear --force-space
 
/opt/sbin/dropbear -p 22 -a
if [ $? == 0 ]; then
    echo "Info: Using standard port 22 for dropbear"
  else
   /opt/sbin/dropbear -p 12345 -a
   echo "Warning: Using non-standard port 12345 for dropbear. Please check your init.d"
fi
echo -e "\n\n\n"
echo "Now you can login via SSH on port 22 login: root and password: 12345"
echo -e "\n"
 
echo "Creating autostart script"
mkdir -p /system/etc/init.d/
rm -f $AUTO_START
touch $AUTO_START
chmod 0755 $AUTO_START
echo -e "#!/system/bin/sh" >> $AUTO_START 
echo -e "\n" >> $AUTO_START 
echo -e "sleep 15" >> $AUTO_START 
echo -e "mount -o rw,remount /" >> $AUTO_START 
echo -e "mount -o rw,remount /system" >> $AUTO_START 
echo -e "mkdir -p $MAIN_DIR" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR $MAIN_DIR" >> $AUTO_START 
echo -e "mkdir -p /bin" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR/bin /bin" >> $AUTO_START 
echo -e "mkdir -p /tmp" >> $AUTO_START 
echo -e "mount --bind $OPT_DIR/tmp /tmp" >> $AUTO_START 
echo -e "mkdir -p /usr/bin" >> $AUTO_START
echo -e "ln -snf /bin/env /usr/bin/env" >> $AUTO_START
echo -e "export PATH=\$PATH:/opt/bin:/opt/sbin" >> $AUTO_START
echo -e "/opt/etc/init.d/rc.unslung start" >> $AUTO_START 
echo -e "mount -o ro,remount /" >> $AUTO_START 
echo -e "mount -o ro,remount /system" >> $AUTO_START 
echo -e "\n" >> $AUTO_START 
 
 
echo "If init.d supported there is a script $AUTO_START or run via autostart SManager app"
echo -e "\n\n\n"
 
echo "Mount to read-only"
mount -o ro,remount /
mount -o ro,remount /system

/system/etc/init.d/entstart

#!/system/bin/sh
 
 
sleep 15
mount -o rw,remount /
mount -o rw,remount /system
mkdir -p
mount --bind
mkdir -p /bin
mount --bind /bin /bin
mkdir -p /tmp
mount --bind /tmp /tmp
mkdir -p /usr/bin
ln -snf /bin/env /usr/bin/env
export PATH=$PATH:/opt/bin:/opt/sbin
/opt/etc/init.d/rc.unslung start
mount -o ro,remount /
mount -o ro,remount /system