wifi_schedule: fix startup problems

Fixes: e0d7181a6
Closes: #22973
Closes: #22988

1. Make the new `startup()` function in `/usr/bin/wifi_schedule.sh`
   respect the global `enabled` config flag; in particular, make no
   changes to `/etc/config/wireless` when wifi_schedule is disabled.
2. Make the new `/etc/init.d/wifi_schedule` service script executable.

Signed-off-by: Rani Hod <rani.hod@gmail.com>
This commit is contained in:
Rani Hod 2023-12-23 13:47:59 +02:00 committed by Rosen Penev
parent ed5e79644d
commit 1e0d7fd2ef
2 changed files with 12 additions and 10 deletions

View File

@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=wifischedule PKG_NAME:=wifischedule
PKG_VERSION:=1.0.5 PKG_VERSION:=1.0.5
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_LICENSE:=PRPL PKG_LICENSE:=PRPL
PKG_MAINTAINER:=Nils Koenig <openwrt@newk.it> PKG_MAINTAINER:=Nils Koenig <openwrt@newk.it>
@ -54,7 +54,7 @@ define Package/wifischedule/install
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./net/etc/config/wifi_schedule $(1)/etc/config/wifi_schedule $(INSTALL_DATA) ./net/etc/config/wifi_schedule $(1)/etc/config/wifi_schedule
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DATA) ./net/etc/init.d/wifi_schedule $(1)/etc/init.d/wifi_schedule $(INSTALL_BIN) ./net/etc/init.d/wifi_schedule $(1)/etc/init.d/wifi_schedule
endef endef
define Package/wifischedule/postinst define Package/wifischedule/postinst

View File

@ -277,14 +277,16 @@ _should_wifi_enabled()
startup() startup()
{ {
_log "startup" _log "startup"
local _enable_wifi=$(_should_wifi_enabled) local global_enabled=$(_get_uci_value ${GLOBAL}.enabled) || _exit 1
if [[ ${_enable_wifi} -eq 0 ]] if [ ${global_enabled} -eq 1 ]; then
then local _enable_wifi=$(_should_wifi_enabled)
_log "enable wifi" if [ ${_enable_wifi} -eq 0 ]; then
enable_wifi _log "enable wifi"
else enable_wifi
_log "disable wifi" else
disable_wifi _log "disable wifi"
disable_wifi
fi
fi fi
} }