#! /bin/ash /etc/init.d/cron stop #vars for downloading base configurations ff_s='http://fabfi.fablab.af' #fabfi server ff_dld='/download/software/base_config/2_1/' # dld needs leading and trailing / ff_u='fabfi' #user ff_cfg='fabfi-files.tgz' ec="etc/config/" i_d="etc/init.d/" r_d="etc/rc.d/" #temporary directory for downloaded files ff_tmp='/tmp/' ff_tdld='/tmp/setup/' #needs trailing / ff_td='/tmp/setup/packages/' #needs trailing / expected to be a direct sub of tdld. Tar file defines fabfi_config part ff_tdo='/tmp/setup/packages_optional/' #needs trailing / expected to be a direct sub of tdld. Tar file defines fabfi_config part #misc constants ff_cIP=0 ff_dIP=0 ff_wm_abIP="10.102." #needs trailing . ff_m_abIP="10.101." #needs trailing . ff_m_cIP="0." #needs trailing . ff_l_abIP="10.103." #needs trailing . ff_gw_dIP="1" echo "" echo "Welcome to the FabFi 2.0a->2.1 device update script." sleep 2 echo "" i="nothing" until (test "y" == $i || test "n" == $i); do echo "Do you need to download config files y/n? (respond y unless you have already download $ff_cfg to $ff_tdld)" read i done if test "y" == $i; then #get tarball for base config files echo "Retrieving configuration files with wget" mkdir $ff_tdld if !(wget $ff_s$ff_dld$ff_cfg -O $ff_tdld$ff_cfg); then echo "Could not download config files." exit fi fi #unzip config files to temp dir. tar -C $ff_tdld -xzf $ff_tdld$ff_cfg cp -rf ${ff_tdld}lib/ / #cp -f ${ff_tdld}${ec}network /${ec} #cp -f ${ff_tdld}${ec}wireless /${ec} #cp -f ${ff_tdld}${ec}httpd /${ec} #cp -f ${ff_tdld}${ec}dhcp /${ec} #cp -f ${ff_tdld}${ec}system /${ec} cp -f ${ff_tdld}etc/opkg.conf.offline /etc/opkg.conf echo "Replacing wget temporarily. If you quit now, you'll have to the symlink to /bin/busybox" # Copy wget for opkg-spoofing purposes rm /usr/bin/wget rm /usr/bin/wget-real echo '#!/bin/ash' > /usr/bin/wget-opkg echo 'cp $4 $3' >> /usr/bin/wget-opkg chmod ugo+x /usr/bin/wget-opkg ln -s /usr/bin/wget-opkg /usr/bin/wget echo "Updating software" ### Doing it the old fashioned way.... opkg update opkg --autoremove remove ngrep opkg -force-reinstall install iptables-mod-extra df -h opkg -force-reinstall install nodogsplash df -h echo "software updated. Fixing files" rm -rf /etc/nodogsplash/htdocs/images/ #rm /etc/nodogsplash/htdocs/images/wifidog.png rm /${i_d}/nodogsplash.init cp -df ${ff_tdld}www/index.html /www/ cp -df ${ff_tdld}www/images /www/ #cp -f ${ff_tdld}${ec}olsrd /${ec} #cp -f ${ff_tdld}${ec}firewall /${ec} cp -f ${ff_tdld}${ec}qos /${ec} cp -rf ${ff_tdld}etc/fabfi-scripts/ /etc/ cp -f ${ff_tdld}etc/crontabs/root /etc/crontabs/ #cp -f ${ff_tdld}etc/firewall.user /etc/ cp -f ${ff_tdld}${i_d}custom-user-startup /${i_d} #cp -df ${ff_tdld}${r_d}S98customuserstartup /${r_d} #cp -df ${ff_tdld}${r_d}S50olsrd /${r_d} #cp -df ${ff_tdld}${r_d}S65mini_snmpd /${r_d} cp -df ${ff_tdld}${r_d}S66nodogsplash /${r_d} #cp -f ${ff_tdld}${ec}luci_ethers /${ec} #cp -f ${ff_tdld}${ec}luci_hosts /${ec} #cp -f ${ff_tdld}${ec}mini_snmpd /${ec} #cp -f ${ff_tdld}${i_d}mini_snmpd /${i_d} #cp -f ${ff_tdld}etc/passwd /etc/ cp -f ${ff_tdld}etc/nodogsplash/nodogsplash.conf /etc/nodogsplash/ rm /etc/nodogsplash/htdocs/splash.html cp -df ${ff_tdld}etc/nodogsplash/htdocs/splash.html /etc/nodogsplash/htdocs/ cp -df ${ff_tdld}etc/nodogsplash/splash.base /etc/nodogsplash/ cp -df ${ff_tdld}etc/nodogsplash/splash-auth.base /etc/nodogsplash/ cp -rf ${ff_tdld}/etc/nodogsplash/htdocs/images/ /etc/nodogsplash/htdocs/ cp -f ${ff_tdld}etc/nodogsplash/htdocs/infoskel.html /etc/nodogsplash/htdocs/ ln -s /var/etc/ffstatus.log /www/ffstatus.log rm /etc/hosts cp -df ${ff_tdld}etc/hosts /etc/ cp -f ${ff_tdld}${i_d}nodogsplash /${i_d} df -h echo "Restoring wget.." rm /usr/bin/wget df -h ln -s /bin/busybox /usr/bin/wget cp -f ${ff_tdld}etc/opkg.conf.online /etc/opkg.conf echo "wget has been restored to normal." ns_index=`uci show olsrd | grep -e 'olsrd\.@LoadPlugin\[.*\]\.library=olsrd_nameservice\.so' | awk 'FS="[";{print $2}' | awk 'FS="]";{print $1};' | tail -1` #set config variables uci set olsrd.@LoadPlugin[${ns_index}].name_change_script="/init.d/luci_hosts restart" uci set httpd.@httpd[0].port=80 uci commit echo Hostname = `uci get system.@system[0].hostname` echo "" echo LAN IP = `uci get network.lan.ipaddr` echo MESH IP = `uci get network.mesh.ipaddr` echo WIFIMESH IP = `uci get network.wifimesh.ipaddr` echo "" echo Wireless channel = `uci get wireless.wl0.channel` echo Wireless distance = `uci get wireless.wl0.distance` sleep 2 #hack so I don't have to keep fixing setrouter in the AP and STA tarballs. #cp ${ff_tmp}fabfi-setup /etc/fabfi-scripts/fabfi-setup echo "YOU MUST RESTART ROUTER FOR CHANGES TO TAKE EFFECT" echo "" sleep 4