added wifi up when turning off wifi schedule. fixed some uninstall issues
added wifi up when turning off wifi schedule. fixed some uninstall issues

--- a/wifischedule-luci/Makefile
+++ b/wifischedule-luci/Makefile
@@ -14,14 +14,14 @@
 include $(INCLUDE_DIR)/package.mk
 
 define Package/luci-app-wifischedule
-  SECTION:=luci
-  CATEGORY:=LuCI
-  DEPENDS:=+wifischedule
-  TITLE:=LuCI - Lua Configuration Interface
-  URL:=http://openwrt.razvi.ro/wifischedule/luci-app-wifischedule_$(PKG_VERSION)-$(PKG_RELEASE).ipk
-  MAINTAINER:=Razvan Stanga <wifischedule@razvi.ro>
-  SUBMENU:=3. Applications
-  TITLE:=LuCI Support for wifischedule
+	SECTION:=luci
+	CATEGORY:=LuCI
+	DEPENDS:=+wifischedule
+	TITLE:=LuCI - Lua Configuration Interface
+	URL:=http://openwrt.razvi.ro/wifischedule/luci-app-wifischedule_$(PKG_VERSION)-$(PKG_RELEASE).ipk
+	MAINTAINER:=Razvan Stanga <wifischedule@razvi.ro>
+	SUBMENU:=3. Applications
+	TITLE:=LuCI Support for wifischedule
 endef
 
 define Package/luci-app-wifischedule/description
@@ -32,7 +32,7 @@
 endef
 
 define Package/luci-app-wifischedule/install
-	$(CP) ./files/* $(1)
+$(CP) ./files/* $(1)
 endef
 
 $(eval $(call BuildPackage,luci-app-wifischedule))

--- a/wifischedule/Makefile
+++ b/wifischedule/Makefile
@@ -14,12 +14,12 @@
 include $(INCLUDE_DIR)/package.mk
 
 define Package/wifischedule
-  SECTION:=net
-  CATEGORY:=Network
-  DEPENDS:=
-  TITLE:=A wifi scheduler
-  URL:=http://openwrt.razvi.ro/wifischedule/wifischedule_$(PKG_VERSION)-$(PKG_RELEASE).ipk
-  MAINTAINER:=Razvan Stanga <wifischedule@razvi.ro>
+	SECTION:=net
+	CATEGORY:=Network
+	DEPENDS:=
+	TITLE:=A wifi scheduler
+	URL:=http://openwrt.razvi.ro/wifischedule/wifischedule_$(PKG_VERSION)-$(PKG_RELEASE).ipk
+	MAINTAINER:=Razvan Stanga <wifischedule@razvi.ro>
 endef
 
 define Package/wifischedule/description
@@ -34,10 +34,11 @@
 endef
 
 define Package/wifischedule/install
-	$(CP) ./files/* $(1)
+$(CP) ./files/* $(1)
 endef
 
 define Package/wifischedule/postinst
+#!/bin/sh
 if [ -z "$${IPKG_INSTROOT}" ]
 then
 /etc/init.d/wifi_schedule enable
@@ -54,5 +55,18 @@
 exit 0
 endef
 
+define Package/wifischedule/prerm
+#!/bin/sh
+/etc/init.d/wifi_schedule disable
+/etc/init.d/wifi_schedule stop
+endef
+
+define Package/wifischedule/postrm
+#!/bin/sh
+uci delete ucitrack.@wifi_schedule[0].init
+uci delete ucitrack.@wifi_schedule[0]
+uci commit
+endef
+
 $(eval $(call BuildPackage,wifischedule))
 

--- a/wifischedule/files/etc/init.d/wifi_schedule
+++ b/wifischedule/files/etc/init.d/wifi_schedule
@@ -9,13 +9,18 @@
 		then
 			echo "wifi_schedule is running"
 		else
-                        echo "Starting wifi_schedule"
-                        /usr/sbin/wifi_schedule &
+			echo "Starting wifi_schedule"
+			/usr/sbin/wifi_schedule &
 		fi
 	fi
 }
 
 stop () {
 	[ -f /var/run/wifi_schedule.pid ] && kill $(cat /var/run/wifi_schedule.pid) && rm /var/run/wifi_schedule.pid
+	if [ "x$(uci -q -P /var/state/ get wireless.@wifi-iface[0].up)" != "x1" ]
+	then
+		logger "wifi_schedule: turning off and wifi is off, turn on"
+		wifi up
+	fi
 }
 

--- a/wifischedule/files/usr/sbin/wifi_schedule
+++ b/wifischedule/files/usr/sbin/wifi_schedule
@@ -14,15 +14,15 @@
 	then
 		if [ "x$(uci -q -P /var/state/ get wireless.@wifi-iface[0].up)" != "x1" ]
 		then
-        	        logger "wifi_schedule: wifi is enabled $day_hour and wifi is off, turn on"
-                	wifi up
+			logger "wifi_schedule: wifi is enabled $day_hour and wifi is off, turn on"
+			wifi up
 		fi
 	else
 		if [ "x$(uci -q -P /var/state/ get wireless.@wifi-iface[0].up)" == "x1" ]
-	        then
-        	        logger "wifi_schedule: wifi is disabled $day_hour and wifi is on, turn off"
-	                wifi down
-        	fi
+		then
+			logger "wifi_schedule: wifi is disabled $day_hour and wifi is on, turn off"
+			wifi down
+		fi
 	fi
 
 	timetosleep=$(uci -q -c /var/wifi_schedule get wifi_schedule.@options[0].interval)
@@ -32,4 +32,3 @@
 	fi
 	sleep $timetosleep
 done
-

comments