Skip to content

Instantly share code, notes, and snippets.

@djGrrr
Last active October 14, 2023 04:03
Show Gist options
  • Save djGrrr/bdbc4818e2b8a229f113ffc0987eba26 to your computer and use it in GitHub Desktop.
Save djGrrr/bdbc4818e2b8a229f113ffc0987eba26 to your computer and use it in GitHub Desktop.
# WARNING: DO NOT RUN THIS AS A SCRIPT, RUN THE COMMANDS MANUALLY
# Make rootfs persistent (yes, this command must be run twice)
fw_setenv bootcmd "run ubi_init; run flash_flash"
fw_setenv bootcmd "run ubi_init; run flash_flash"
# Confirm the change:
strings /dev/mtd1 | grep bootcmd
strings /dev/mtd2 | grep bootcmd
# Prevent the startup script from reverting the bootcmd and rootfs
sed -r 's/^(.\/ptrom\/bin\/set_bootcmd_env)/#\1/g' -i /etc/init.d/bfw_start.sh
# Confirm the change, it should look like: #./ptrom/bin/set_bootcmd_env
grep /set_bootcmd /etc/init.d/bfw_start.sh
# Enable LCT (Management) interface to come up automatically on bootup
uci set network.lct.auto=1 && uci commit network
# Confirm the change, it should show: network.lct.auto='1'
uci show network.lct.auto
# Add failsafe hook to /etc/rc.local which starts omcid after a delay unless a .failsafe file exists in /root or /tmp
grep -q failsafe /etc/rc.local || sed 's#exit 0#sleep 30 \&\& [ ! -f /root/.failsafe ] \&\& [ ! -f /tmp/.failsafe ] \&\& /etc/init.d/omcid.sh start\nexit 0#g' -i /etc/rc.local ; chmod +x /etc/rc.local
# Confirm the change, you should see the following before exit 0: sleep 30 && [ ! -f /root/.failsafe ] && [ ! -f /tmp/.failsafe ] && /etc/init.d/omcid.sh start
cat /etc/rc.local
# Disable automatic startup of omcid
/etc/init.d/omcid.sh disable
# Confirm the change, this should say: 1
/etc/init.d/omcid.sh enabled ; echo $?
# Reboot
sync
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment