I would like to know if I am unable to ssh to a router with openwrt installed or to connect via an http or https connection which commands to save to debug the problem and find a possible solution.
I currently have a hardware button configured to execute a script in the hope that hardware-wise it will still execute.
it could be useful to save the files on a usb storage, but I thought that if there are problems accessing the storage the files would not be written, so I opted for writing on the internal flash
I know that the best solution would be a serial access to the device but I'm not that good
post the script that can be freely modified or reused if it can be useful to someone else.
#!/bin/sh
if [ -f /root/config/network ]; then
if [ ! -d /root/fail ]; then
mkdir /root/fail
fi
now=$(date +"%d_%m_%Y_%s")
cat /proc/net/arp > /root/fail/arp-${now}
dmesg > /root/fail/dmesg-${now}
logread > /root/fail/logread-${now}
cp /etc/config/network /root/fail/network-${now}
cp /root/config/network /etc/config/network
/etc/init.d/network restart
ip neigh flush all
fi