diff options
author | makefu <github@syntax-fehler.de> | 2013-05-26 14:41:01 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-05-26 14:41:01 +0200 |
commit | 91b2ec7821796c75bb3a56df951c6734d41a26bb (patch) | |
tree | 61971a9ab364483018b4977ca2c1ae227c360040 /usr/lib | |
parent | d42681fb63901254700cfbb35116cbdca9945463 (diff) |
cleanup and usage for plugins
Diffstat (limited to 'usr/lib')
-rw-r--r-- | usr/lib/autowifi/lib/core | 9 | ||||
-rw-r--r-- | usr/lib/autowifi/lib/plugin_core | 26 | ||||
-rwxr-xr-x | usr/lib/autowifi/plugins/11belkin_wps | 8 |
3 files changed, 28 insertions, 15 deletions
diff --git a/usr/lib/autowifi/lib/core b/usr/lib/autowifi/lib/core deleted file mode 100644 index f41de225..00000000 --- a/usr/lib/autowifi/lib/core +++ /dev/null @@ -1,9 +0,0 @@ -parse_plugin_args(){ - # convenience function to put args in ENV variables - ESSID="$1" - MAC="$2" - CHANNEL="$3" - ENC="$4" - WPA="$5" - WPA2="$6" -} diff --git a/usr/lib/autowifi/lib/plugin_core b/usr/lib/autowifi/lib/plugin_core new file mode 100644 index 00000000..025d9dbd --- /dev/null +++ b/usr/lib/autowifi/lib/plugin_core @@ -0,0 +1,26 @@ +parse_plugin_args(){ + [ $# -ne 6 ] && plugin_usage && exit 1 + # convenience function to put args in ENV variables + ESSID="$1" + MAC="$2" + CHANNEL="$3" + ENC="$4" + WPA="$5" + WPA2="$6" + if [ ${#MAC} -ne 17 ] ;then + echo "MAC malformed" + exit 1 + fi +} +plugin_usage(){ + cat << EOF +usage: $0 ESSID MAC CHANNEL ENC WPA WPA2" + + ESSID - string + MAC - 00:11:22:33:44:55 + ENC - on | off + WPA - 0 | 1 + WPA2 - 0 | 1 +EOF + +} diff --git a/usr/lib/autowifi/plugins/11belkin_wps b/usr/lib/autowifi/plugins/11belkin_wps index 3820cf2e..1dba7377 100755 --- a/usr/lib/autowifi/plugins/11belkin_wps +++ b/usr/lib/autowifi/plugins/11belkin_wps @@ -11,15 +11,11 @@ # belkin.XXX 09:86:3B:XX:XX:XX F9K1104 v1000 cd $(dirname $(readlink -f $0)) -. ../lib/core +. ../lib/plugin_core . ../lib/wps parse_plugin_args $@ -MAC=$(printf "%s" $2| sed 's/://g') -if [ ${#MAC} -ne 12 ] ;then - echo "MAC malformed" - exit 1 -fi +MAC=$(printf "%s" $MAC| sed 's/://g') VENDOR_MAC=${MAC:0:6} PRIVATE_MAC=${MAC:6:12} if ! [ $VENDOR_MAC == "002275" -o $VENDOR_MAC == "001CDF" -o $VENDOR_MAC == "09863B" ] ;then |