wifi/prepwifi.sh

32 lines
1.0 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
if [ -z "$1" ]; then
echo Usage: $0 IP name
exit 2
fi
ip=${1}
name=${2}
cd "out/${name}/files" || exit 3
2022-10-12 13:57:53 +03:00
newip=`grep ipaddr etc/config/network|grep -v \# |tail -n1|cut -d \' -f 2`
if [ -z "$newip" ]; then
echo ip not found
exit 2
fi
ssh-keygen -R ${ip}
ssh -o stricthostkeychecking=no root@${ip} uptime
scp -r * root@${ip}:/
2022-10-11 15:23:07 +03:00
now=`date +%s`
ssh -t root@${ip} "date -s @$now; cp /etc/resolv.conf /tmp/resolv.conf.old ; echo 'nameserver 8.8.8.8' > /etc/resolv.conf; ip r replace default via 192.168.1.99; opkg remove wpad-basic-wolfssl; opkg update && opkg install ebtables tcpdump bc iftop wpad-openssl collectd collectd-mod-iwinfo collectd-mod-interface collectd-mod-cpu collectd-mod-exec collectd-mod-load collectd-mod-memory collectd-mod-network ip-bridge ; /etc/init.d/wifi-sentinel enable; /etc/init.d/odhcpd disable; /etc/init.d/dnsmasq disable; mv /tmp/resolv.conf /etc/resolv.conf; reboot"
sleep 3
while ! fping ${newip}; do sleep 5; done
ssh-keygen -R ${newip}
sleep 3
ssh -o stricthostkeychecking=no root@${newip} "echo All done."