From 1675e96714afcb3f70d74fc764689a8bfb40dd13 Mon Sep 17 00:00:00 2001 From: Nuno Goncalves Date: Mon, 15 Sep 2014 23:18:42 +0000 Subject: [PATCH] wifitoggle: move to github Signed-off-by: Nuno Goncalves SVN-Revision: 42560 --- utils/wifitoggle/Makefile | 44 ------ utils/wifitoggle/files/wifitoggle.config | 11 -- utils/wifitoggle/files/wifitoggle.hotplug | 172 ---------------------- 3 files changed, 227 deletions(-) delete mode 100644 utils/wifitoggle/Makefile delete mode 100755 utils/wifitoggle/files/wifitoggle.config delete mode 100755 utils/wifitoggle/files/wifitoggle.hotplug diff --git a/utils/wifitoggle/Makefile b/utils/wifitoggle/Makefile deleted file mode 100644 index adec3fb128..0000000000 --- a/utils/wifitoggle/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (C) 2010-2013 OpenWrt.org -# Copyright (C) 2010 segal.di.ubi.pt -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=wifitoggle -PKG_VERSION:=1 -PKG_RELEASE:=4 - -PKG_MAINTAINER:=Nuno Goncalves - -include $(INCLUDE_DIR)/package.mk - -define Package/wifitoggle - SECTION:=utils - CATEGORY:=Utilities - TITLE:=Script to toggle Wi-Fi with a button and UCI config -endef - -define Package/wifitoggle/description -Very versatile script to toggle Wi-Fi with a button. Allows to set -timeouts, persist changes after boot, and set LEDs according to the state. -endef - -define Package/wifitoggle/conffiles -/etc/config/wifitoggle -endef - -define Build/Compile -endef - -define Package/wifitoggle/install - $(INSTALL_DIR) $(1)/etc/hotplug.d/button - $(INSTALL_BIN) ./files/wifitoggle.hotplug $(1)/etc/hotplug.d/button/50-wifitoggle - $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_DATA) ./files/wifitoggle.config $(1)/etc/config/wifitoggle -endef - -$(eval $(call BuildPackage,wifitoggle)) diff --git a/utils/wifitoggle/files/wifitoggle.config b/utils/wifitoggle/files/wifitoggle.config deleted file mode 100755 index f3bec29ab7..0000000000 --- a/utils/wifitoggle/files/wifitoggle.config +++ /dev/null @@ -1,11 +0,0 @@ -config wifitoggle - option button 'wps' - - option persistent '0' - option timer '600' - - option led_sysfs 'wrt160nl:amber:wps' - option led_enable_trigger 'timer' - option led_enable_delayon '500' - option led_enable_delayoff '500' - option led_disable_default '0' diff --git a/utils/wifitoggle/files/wifitoggle.hotplug b/utils/wifitoggle/files/wifitoggle.hotplug deleted file mode 100755 index d66db3f0a7..0000000000 --- a/utils/wifitoggle/files/wifitoggle.hotplug +++ /dev/null @@ -1,172 +0,0 @@ -# /bin/sh - -setled() { - if [ -e /sys/class/leds/${led_sysfs}/brightness ] - then - [ $led_default -eq 1 ] && echo 1 >/sys/class/leds/${led_sysfs}/brightness - [ $led_default -eq 1 ] || echo 0 >/sys/class/leds/${led_sysfs}/brightness - - echo $led_trigger > /sys/class/leds/${led_sysfs}/trigger - - [ "$led_trigger" == "netdev" -a -n "$led_dev" ] && { - echo $led_dev > /sys/class/leds/${led_sysfs}/device_name - echo $led_mode > /sys/class/leds/${led_sysfs}/mode - } - - [ "$led_trigger" == "timer" ] && { - [ -n "$led_delayon" ] && echo $led_delayon > /sys/class/leds/${led_sysfs}/delay_on - [ -n "$led_delayoff" ] && echo $led_delayoff > /sys/class/leds/${led_sysfs}/delay_off - } - else - logger -p user.err -t "wifitoggle" "led: ${led_sysfs} not found" - fi -} - -load_wireless() { - disabled="$(uci get wireless.${1}.disabled)" -} - -save_wireless() { - [ "$device" = "all" -o "$device" = "${1}" ] && { - uci set "wireless.${1}.disabled=$disabled" - } -} - -setwifi() { - setled - - config_load wireless - config_foreach save_wireless wifi-device - - if ubus list network.wireless >/dev/null 2>/dev/null; then - ubus call network reload - else - wifi - fi -} - - -save_system() { - config_get sysfs $1 sysfs - [ "$sysfs" = "$led_sysfs" ] && { - uci set "system.${1}.trigger=$led_trigger" - uci set "system.${1}.dev=$led_dev" - uci set "system.${1}.mode=$led_mode" - uci set "system.${1}.default=$led_default" - uci set "system.${1}.delayon=$led_delayon" - uci set "system.${1}.delayoff=$led_delayoff" - - ledset=1 - } -} - -commit_changes() { - ledset="" - - config_load system - config_foreach save_system led - - [ "$ledset" -eq 1 ] || { - section=$(uci add system led) - uci set "system.${section}.sysfs=$led_sysfs" - uci set "system.${section}.trigger=$led_trigger" - uci set "system.${section}.dev=$led_dev" - uci set "system.${section}.mode=$led_mode" - uci set "system.${section}.default=$led_default" - uci set "system.${section}.delayon=$led_delayon" - uci set "system.${section}.delayoff=$led_delayoff" - } - - uci commit -} - -enable() { - - led_trigger="$led_enable_trigger" - led_trigger="$led_enable_trigger" - led_dev="$led_enable_dev" - led_mode="$led_enable_mode" - led_default="$led_enable_default" - led_delayon="$led_enable_delayon" - led_delayoff="$led_enable_delayoff" - disabled=0 - - setwifi - - [ "$timer" -le 0 -a "$persistent" -eq 1 ] && commit_changes - - logger -p user.info -t "wifitoggle" "device($device) enabled" - - [ "$timer" -gt 0 ] && { - sleep "$timer" && disable && rm /tmp/run/wirelesstoggle_${1}.pid & - echo $! > /tmp/run/wirelesstoggle_${1}.pid - logger -p user.info -t "wifitoggle" "auto-disable timer started($timer seconds)" - } -} - -disable() { - - led_trigger="$led_disable_trigger" - led_trigger="$led_disable_trigger" - led_dev="$led_disable_dev" - led_mode="$led_disable_mode" - led_default="$led_disable_default" - led_delayon="$led_disable_delayon" - led_delayoff="$led_disable_delayoff" - disabled=1 - - setwifi - - [ "$timer" -le 0 -a "$persistent" -eq 1 ] && commit_changes - - logger -p user.info -t "wifitoggle" "device($device) disabled" -} - - -load_wifitoggle() { - config_get device $1 device "all" - config_get button $1 button "wps" - config_get action $1 action "pressed" - config_get_bool persistent $1 persistent "0" - config_get timer $1 timer "0" - - config_get led_sysfs $1 led_sysfs - - config_get led_enable_trigger $1 led_enable_trigger "none" - config_get led_enable_dev $1 led_enable_dev - config_get led_enable_mode $1 led_enable_mode "link" - config_get_bool led_enable_default $1 led_enable_default "1" - config_get led_enable_delayon $1 led_enable_delayon - config_get led_enable_delayoff $1 led_enable_delayoff - - config_get led_disable_trigger $1 led_disable_trigger "none" - config_get led_disable_dev $1 led_disable_dev - config_get led_disable_mode $1 led_disable_mode "link" - config_get_bool led_disable_default $1 led_disable_default "0" - config_get led_disable_delayon $1 led_disable_delayon - config_get led_disable_delayoff $1 led_disable_delayoff - - [ "$ACTION" = "$action" -a "$BUTTON" = "$button" ] && { - - [ -f /tmp/run/wirelesstoggle_${1}.pid ] && read PID < /tmp/run/wirelesstoggle_${1}.pid && kill $PID && rm /tmp/run/wirelesstoggle_${1}.pid - - if [ "$device" = "all" ] - then - config_load wireless - config_foreach load_wireless wifi-device - else - disabled="$(uci get wireless."$device".disabled)" - fi - - - if [ "$disabled" = "1" ] - then - enable $1 - else - disable - fi - } -} - -config_load wifitoggle -config_foreach load_wifitoggle wifitoggle -- 2.30.2