AsusWRT-Merlin: Installing Entware into a CIFS folder

Sat 07 April 2018 by LrdShaper

This is taken from AsusWRT-Merlin Wiki and modified to work with CIFS shares. You can read what Entware is all about here. This assumes:
a Your router is and is connected to the internet
b Samba is running on with a share name of Share1
c We're going to mount \\Share1 into /cifs1

1) SSH into your router and mount the CIFS share. Replace smbuser1 and smbuser1passwd with the credentials of the id that have rw permissions on the shared folder:

$ ssh admin@
# mount \\\\\\Share1 /cifs1 -o "username=smbuser1,password=smbuser1passwd"

2) Create directory opt under /cifs1, create a symlink to /tmp/opt and initialize Entware

# mkdir /cifs1/opt
# rm -fr /tmp/opt
# ln -s /cifs1/entware /tmp/opt
# wget -O - | sh

3) Configure Asuswrt-Merlin to automatically stop/start services:

# echo "#!/bin/sh" > /jffs/scripts/services-start
# echo "sleep 20" >> /jffs/scripts/services-start
# echo "/opt/etc/init.d/rc.unslung start" >> /jffs/scripts/services-start
# echo "#!/bin/sh" > /jffs/scripts/services-stop
# echo "/opt/etc/init.d/rc.unslung stop" >> /jffs/scripts/services-stop
# chmod a+rx /jffs/scripts/*

4) Now we need to edit /jffs/scripts/services-start so that our CIFS share is mounted and the Entware dirs are setup. Add the following lines between "sleep 20" and "/opt/etc/init.d/rc.unslung start"

sleep 20
mount \\\\${CIFS_SERVER}\\${CIFS_SHARE} ${CIFS_MPOINT} -o "username=${CIFS_USER},password=${CIFS_PASSWD}"
rm -fr /tmp/opt
ln -s /cifs1/entware /tmp/opt
/opt/etc/init.d/rc.unslung start

That's it. You can start using opkg to install/upgrade/remove packages