Startup script to install LuCI

I run snapshot builds on my devices, and have gotten tired of SSH'ing after each update just to manually install LuCI.

After a quick search for an automated install turned up fruitless, I decided to write my own rc.local startup script to install LuCI. I'm a PowerShell guy, not a bash guy, so feel free to point out mistakes or suggest improvements!

echo "$(date) - Begin execute" >> $OUTFILE
LUCI=$(opkg list-installed | grep luci)
if [ -z "$LUCI" ]
  echo "$(date) - Updating packages" >> $OUTFILE
  until opkg update
    let ATTEMPTS++
    if [ $ATTEMPTS -ge 10 ]
	  echo "$(date) - Max attempts reached! Cannot update packages" >> $OUTFILE
	  exit 1
	  echo "$(date) - Failed to update packages; sleeping and retrying..." >> $OUTFILE
	  sleep 1
  echo "$(date) - Installing luci" >> $OUTFILE
  opkg install luci
  echo "$(date) - luci is already home" >> $OUTFILE
echo "$(date) - Finish execute" >> $OUTFILE
exit 0

Add a sleep before each retry.
Have a maximum number of retries

it's fine if all you can do is write scripts that are executed post-install/upgrade and you have network access without installing additional packages.

You can integrate all packages you want in a firmware image if you use the Image Builder, but that tool runs only under Linux or under the WSL environment on Windows


Great advice! I've updated the original post.

1 Like

Neat! I wasn't aware of the Image Builder.
I've found ways to automate around my annoyances, so I'm happy to let buildbot do the work for me - at least for now.

In addition to installing LuCI, my other annoyance was disabling services (dnsmasq/firewall/odhcpd) for my dumb AP. I used this workaround to create null symlinks, and persist them through the sysupgrade.conf.

If you're using the Image Builder anyways, imho the neater way would be to create a uci-defaults script in which you can pre-configure your dumb ap (disable services, configure wifi, etc.).


note that the image builder is not compiling from source, but just downloading pre-compiled packages and using them to create a firmware image.

So the buildbot is still doing most of the leg work.

  • you should bake opkg script (opkg_extras or richbhanovers implementation has worked for a long time) into 'FILES' including the config/opkg and profile.d/ stuff. its the most comprehensive current tool to manage similar functions...

  • imagebuilder supports DISABLED_SERVICES on image creation...


Looks like the consensus is that the Image Builder is the way to go.
Will definitely look into this. Thanks everyone!