From 88e3205347e63d9c47bcde72615ef678933c44ea Mon Sep 17 00:00:00 2001 From: Wouter R Date: Tue, 14 May 2013 17:26:21 +0200 Subject: [PATCH] add proper init script setup; various small fixes. --- Makefile | 14 +++++++++----- TODO | 11 +++-------- post-install.sh | 6 +++++- post-remove.sh | 2 ++ pre-remove.sh | 5 +++++ src/autowifi/ext/autowifi_init | 2 +- 6 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 pre-remove.sh diff --git a/Makefile b/Makefile index e459384..ef76ff8 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ IncludeWithNewlines = $(subst # Name and release number of this package -PKG_NAME:=wifibox -PKG_VERSION:=0.1.0 -PKG_RELEASE:=1 +PKG_NAME := wifibox +PKG_VERSION := 0.1.0 +PKG_RELEASE := 3 # This specifies the directory where we're going to build the program. # The root build directory, $(BUILD_DIR), is by default the build_mipsel @@ -82,7 +82,7 @@ define Package/wifibox/install # $(INSTALL_DIR) $(1)/usr/share/lua/autowifi/ext # $(INSTALL_DIR) $(1)/usr/share/lua/autowifi/ext/www $(INSTALL_DIR) $(1)/usr/share/lua/autowifi/ext/www/cgi-bin - $(INSTALL_DIR) $(1)/etc/rc.d + $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/www/cgi-bin ### create all files in /usr/share/lua/autowifi (autowifi) @@ -109,7 +109,7 @@ endif $(LN) -s /usr/share/lua/autowifi/ext/wfcf $(1)/www/cgi-bin $(LN) -s /usr/share/lua/autowifi/admin $(1)/www - $(LN) -s /usr/share/lua/autowifi/ext/autowifi_init $(1)/etc/rc.d/S18autowifi_init + $(LN) -s /usr/share/lua/autowifi/ext/autowifi_init $(1)/etc/init.d/autowifi_init ### install gpx utility $(INSTALL_DIR) $(1)/usr/bin @@ -120,6 +120,10 @@ define Package/wifibox/postinst $(call IncludeWithNewlines,post-install.sh) endef +define Package/wifibox/prerm +$(call IncludeWithNewlines,pre-remove.sh) +endef + define Package/wifibox/postrm $(call IncludeWithNewlines,post-remove.sh) endef diff --git a/TODO b/TODO index 5c20727..33206fa 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,14 @@ # TODO -- 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 -- add dependency on either wr703n or mr3020 (and probably comment it out to avoid being to conservative...) - see if updating works when a new version is 'released' (probably needs a real feed) - add aliases to root profile only when debugging was requested in menuconfig -- symlinks created in the install section of the Makefile should perhaps be created in the postinstall script, - this way the package is truly relocatable - add config option to compile sources using luac? +- 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. -- remove usr/share/lua/autowifi and subdirectories (if empty) in postrm +- relocatabilty of package (take root prefix into consideration everywhere) # TODO for autowifi.js @@ -47,7 +42,7 @@ 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 / +./ ' ' /--// _|-// - | . /v / /________/__//__/__//____/___/_^_\ diff --git a/post-install.sh b/post-install.sh index 2fee890..1754296 100755 --- a/post-install.sh +++ b/post-install.sh @@ -41,7 +41,7 @@ if [ ! -f /etc/banner.default ]; then .......________ _____ _____ v $(PACKAGE_VERSION) ....../ / / |__ / __/ / - /___ __ ...../ / / /--// _|-// --| . /v / - ..../________/__//__/__//____/___/_^_\\ + ..../________/__//__/__//____/___/_^_\ ... ..A cad in a box. . @@ -68,3 +68,7 @@ addFirewallNet echo "Adding network interface 'wlan'..." uci set network.wlan=interface; uci commit network; /etc/init.d/network reload + +[ -z "$$IPKG_INSTROOT" ] || { /etc/init.d/autowifi_init enable; } + +exit 0 diff --git a/post-remove.sh b/post-remove.sh index 7105ede..7e8f3d5 100755 --- a/post-remove.sh +++ b/post-remove.sh @@ -18,3 +18,5 @@ rmdir /www/cgi-bin 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." + +exit 0 diff --git a/pre-remove.sh b/pre-remove.sh new file mode 100644 index 0000000..0652fbc --- /dev/null +++ b/pre-remove.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -z "$$IPKG_INSTROOT" ] || { /etc/init.d/autowifi_init disable; } + +exit 0 diff --git a/src/autowifi/ext/autowifi_init b/src/autowifi/ext/autowifi_init index 5d5f547..bfcb972 100755 --- a/src/autowifi/ext/autowifi_init +++ b/src/autowifi/ext/autowifi_init @@ -1,6 +1,6 @@ #!/bin/sh /etc/rc.common -START=19 +START=18 LOGGER="logger -s -t autowifi -p 6" boot() {