Reset button duplicating in script?

Hey, does anybody know the command i have to issue to replicate holding the reset button for 10 seconds? im trying to write some startup scrips and the reset button is kinda annoying... I have tried:

ssh root@192.168.1.1 'echo y | firstboot && reboot'

also ran:
umount /overlay && jffs2reset && reboot
in the router terminal

its been behaving weirdly after these, but I can still reset it waiting 5 mins or so...

I don’t think you need the echo in the ssh command. When already logged in, you issue this:

firstboot -y && reboot

This is what happens when I actually run the command inside the router:

root@OpenWrt:~# firstboot -y && reboot
/dev/ubi0_5 is not mounted
/dev/ubi0_5 will be erased on next mount
root@OpenWrt:~# exit
Connection to 192.168.1.1 closed.

When I ssh in again, the port change that I made, is still active, it doesn't seem to actually reset it, and im not sure why, I think this works for a soft reset, but im looking to replicate holding the reset button

ubus call system board
root@OpenWrt:~# ubus call system board
{
	"kernel": "5.15.137",
	"hostname": "OpenWrt",
	"system": "ARMv8 Processor rev 4",
	"model": "Linksys E8450 (UBI)",
	"board_name": "linksys,e8450-ubi",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.2",
		"revision": "r23630-842932a63d",
		"target": "mediatek/mt7622",
		"description": "OpenWrt 23.05.2 r23630-842932a63d"
	}
}

Does the gui reset to defaults button work?

from what I can tell, no... using System > Backup / Flash Firmware > Restore > Perform reset button does not reset ssh to the default port, where the physical reset button does.

I have no idea why it isn't working.

Maybe try flashing the firmware again?

sysupgrade -n /tmp/firmware.bin (so not keeping settings) would be my next approach as well.

But I do wonder about

I would expect a message like ubi0_5 is mounted, only deleting files instead.

…but, I don't know this particular device myself.

I found that these commands work.

scp -P 2222 openwrt-23.05.2-mediatek-mt7622-linksys_e8450-ubi-squashfs-sysupgrade.itb root@192.168.1.1:/tmp/
ssh -p 2222 root@192.168.1.1 'sysupgrade -n /tmp/openwrt-23.05.2-mediatek-mt7622-linksys_e8450-ubi-squashfs-sysupgrade.itb'

thanks guys