From 9789fdc0c3049d71f3e72dcfdb3b504da7b7ea2e Mon Sep 17 00:00:00 2001 From: Wouter R Date: Tue, 14 May 2013 11:34:55 +0200 Subject: [PATCH] Finish post-install/pre-remove package scripts (not yet used/included by Makefile). --- add-fw-net.sh | 30 ++++++++++++++++++++++++++++++ post-install.sh | 23 ++++++++++++----------- pre-remove.sh | 13 ++++++------- src/TODO | 18 +++++++++++------- 4 files changed, 59 insertions(+), 25 deletions(-) create mode 100755 add-fw-net.sh mode change 100644 => 100755 post-install.sh mode change 100644 => 100755 pre-remove.sh diff --git a/add-fw-net.sh b/add-fw-net.sh new file mode 100755 index 0000000..d2e71ef --- /dev/null +++ b/add-fw-net.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +cfgChanged=0; zoneNum=-1; i=0 + +while true; do + name=`uci get firewall.@zone[$i].name 2>&1` + exists=`echo "$name" | grep "Entry not found" >/dev/null 2>&1; echo $?` + + if [ $exists -eq 0 ]; then break; fi + if [ $name = "lan" ]; then zoneNum=$i; fi + + i=`expr $i + 1` +done + +if [ $zoneNum -gt -1 ]; then + network=`uci get firewall.@zone[$zoneNum].network 2>&1` + hasWlan=`echo $network | grep "wlan" >/dev/null 2>&1; echo $?` + if [ $hasWlan -eq 1 ]; then + uci set firewall.@zone[$zoneNum].network="lan wlan" + uci commit firewall + /etc/init.d/dnsmasq reload + cfgChanged=1 + fi +fi + +if [ $cfgChanged -eq 1 ]; then + echo "Added network 'wlan' to zone lan" +else + echo "Firewall configuration not changed" +fi diff --git a/post-install.sh b/post-install.sh old mode 100644 new mode 100755 index 958a009..3f5410a --- a/post-install.sh +++ b/post-install.sh @@ -1,24 +1,20 @@ +########### NOTE: add an extra '$' in front of all existing ones when copying into Makefile (and remove this line...) + + #!/bin/sh - -############## -# MAIN CODE # -############ - if [ ! -f /etc/banner.default ]; then mv /etc/banner /etc/banner.default cat <<-'EOM' > /etc/banner ........D o o d l e 3 D .......________ _____ _____ v $(PACKAGE_VERSION) ....../ / / |__ / __/ / - /___ __ - ...../ / / /--// _|-// - | . /- / - ..../________/__//__/__//____/___/_-_\ + ...../ / / /--// _|-// --| . /v / + ..../________/__//__/__//____/___/_^_\\ ... ..A cad in a box. . EOM - fi - grep '^# DO NOT MODIFY.*wifibox package.$' /root/.profile >/dev/null 2>&1 if [ $? -eq 1 ]; then cat <<-EOM >> /root/.profile @@ -29,5 +25,10 @@ if [ $? -eq 1 ]; then EOM fi -#3. make sure the radio0 interface is enabled in /etc/config/wireless (preferably through uci) -#4. make sure the wlan net is in the lan zone in /etc/config/dnsmasq (and make sure wlan net exists?) +@echo "Enabling wifi device..." +uci set wireless.@wifi-device[0].disabled=0; uci commit wireless; wifi + +./add-fw-net.sh + +@echo "Adding network interface 'wlan'..." +uci set network.wlan=interface; uci commit network; /etc/init.d/network reload diff --git a/pre-remove.sh b/pre-remove.sh old mode 100644 new mode 100755 index 9364cf3..7cab24a --- a/pre-remove.sh +++ b/pre-remove.sh @@ -1,8 +1,7 @@ #!/bin/sh - -#if [ -f /etc/banner.default ]; then -# mv /etc/banner.default /etc/banner -#fi - -# emit message stating that /root/.profile is not changed back and -# neither are wlan zone and radio0 enabled state +if [ -f /etc/banner.default ]; then + mv /etc/banner.default /etc/banner +fi +echo "The wifibox banner has been removed. Changes to the root profile however, have" +echo "not been reverted, as haven't the wlan firewall zone and the radio0 device state." +echo "NOTE: config changes have not been implemented yet." diff --git a/src/TODO b/src/TODO index 5078261..1e10cd1 100644 --- a/src/TODO +++ b/src/TODO @@ -1,15 +1,19 @@ # TODO - finish postinst and prerm/postrm scripts - - preliminary test with postinst does not seem to work (i.e. touch a file in the device root does not result in a file being there) +- externalize postinst+prerm scripts by doing something like: 'POSTINST_SCRIPT:=$(shell cat postinst.sh)'? + see: http://stackoverflow.com/questions/1435861/computing-makefile-variable-on-assignment +- do things right and copy (not link) the init script to init.d + (and enable it automatically, which links to it from rc.d with the proper start priority?) + as sudo does: '[ -n "$$IPKG_INSTROOT" ] || { /etc/init.d/sudo enable}'; and here: https://forum.openwrt.org/viewtopic.php?pid=85197#p85197 - add more config options to package; candidates: reconf.WWW_RENAME_NAME, wifihelper.{AP_ADDRESS, AP_NETMASK, (NET)} about bridging this to lua: have some Makefile stage create a ini/lua file with k/v's and have lua read out that file? - write a shellscript to automate tasks like swapping out /www and packaging modified code for git merging -- do things right and copy (not link) the init script to init.d - (and enable it automatically, which links to it from rc.d with the proper start priority?) - add dependency on either wr703n or mr3020 (and probably comment it out to avoid being to conservative...) -- add/link general OpenWrt build instructions for OSX to installation page on wiki. - see if updating works when a new version is 'released' (probably needs a real feed) +- add config option to compile sources using luac? +- add/link general OpenWrt build instructions for OSX to installation page on wiki. +- remove usr/share/lua/autowifi and subdirectories (if empty) in postrm # TODO for autowifi.js @@ -43,12 +47,12 @@ Check http://geon.github.io/Programming/2012/04/25/ascii-art-signatures-in-the-w ....D o o d l e 3 D ...________ _____ _____ v 1.0.1 ../ / / |__ / __/ / - /___ __ -./ ' ' /--// _|-// - | . /- / -/________/__//__/__//____/___/_-_\ +./ ' ' /--// _|-// --| . /v / +/________/__//__/__//____/___/_^_\ -# Shelled bugs/annoyances +# Shelled bugs/annoyances (all except the lua errors have been filed) + scripts are only allowed to be created in src folder? (nothing else shown, root greys out 'Finish') + text inside heredoc is highlighted + only one space allowed at start of line...makes it impossible to draw ascii art