]> git.ipfire.org Git - network.git/commitdiff
Move wpa_supplicant functions into their own file.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2012 20:14:52 +0000 (20:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2012 20:14:52 +0000 (20:14 +0000)
functions.wireless
functions.wpa_supplicant [new file with mode: 0644]

index eacc6abfcc0384b09196635fb2342ec44168784b..00e1a02f096ac2359fff3b4a5832ce5424c7f18a 100644 (file)
@@ -63,129 +63,3 @@ function wireless_set_channel() {
 
        iw dev ${device} set channel ${channel} $@
 }
-
-function wpa_supplicant_config_write() {
-       local device=${1}
-       shift
-
-       assert isset device
-
-       local ssid
-       local encryption
-       local key
-
-       while [ $# -gt 0 ]; do
-               case "${1}" in
-                       --ssid=*)
-                               ssid=${1#--ssid=}
-                               ;;
-                       --encryption=*)
-                               encryption=${1#--encryption=}
-                               ;;
-                       --key=*)
-                               key=${1#--key=}
-                               ;;
-               esac
-               shift
-       done
-
-       assert isset ssid
-       assert isset encryption
-       assert isset key
-
-       cat <<EOF
-# WPA supplicant configuration for ${device}.
-# DO NOT EDIT.
-
-network={
-       ssid="${ssid}"
-       proto=RSN
-       key_mgmt=${encryption}
-       pairwise=CCMP
-       group=TKIP
-       psk="${key}"
-}
-
-EOF
-}
-
-function wpa_supplicant_config_dir() {
-       local device=${1}
-
-       assert isset device
-
-       echo "${RUN_DIR}/wireless/${device}"
-}
-
-function wpa_supplicant_start() {
-       local device=${1}
-       shift
-
-       assert device_exists ${device}
-
-       local config_dir=$(wpa_supplicant_config_dir ${device})
-       mkdir -p ${config_dir}
-
-       local config_file=${config_dir}/config
-       wpa_supplicant_config_write ${device} $@ > ${config_file}
-
-       wpa_supplicant -i ${device} -D wext -B -c ${config_file} \
-               -P ${config_dir}/pid
-}
-
-function wpa_supplicant_stop() {
-       local device=${1}
-
-       assert isset device
-
-       local pid=$(wpa_supplicant_get_pid ${device})
-
-       if isset pid; then
-               process_kill ${pid}
-       else
-               warning_log "Could not find pid file for wpa_supplicant process running for ${device}."
-       fi
-
-       rm -rf $(wpa_supplicant_config_dir ${device})
-}
-
-function wpa_supplicant_get_pid() {
-       local device=${1}
-
-       assert isset device
-
-       local pid_file="$(wpa_supplicant_config_dir ${device})/pid"
-
-       [ -e "${pid_file}" ] || return ${EXIT_ERROR}
-
-       cat ${pid_file} 2>/dev/null
-       return ${EXIT_OK}
-}
-
-function wpa_supplicant_is_running() {
-       local device=${1}
-
-       assert isset device
-
-       local pid=$(wpa_supplicant_get_pid ${device})
-
-       if isset pid && [ -d "/proc/${pid}" ]; then
-               return ${EXIT_OK}
-       fi
-
-       return ${EXIT_ERROR}
-}
-
-function wpa_supplicant_get_pid() {
-       local zone=${1}
-       shift
-
-       
-}
-
-function wpa_supplicant_stop() {
-       local zone=${1}
-       shift
-
-       killall wpa_supplicant
-}
diff --git a/functions.wpa_supplicant b/functions.wpa_supplicant
new file mode 100644 (file)
index 0000000..3f01791
--- /dev/null
@@ -0,0 +1,146 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2012  IPFire Network Development Team                         #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+function wpa_supplicant_config_write() {
+       local device=${1}
+       shift
+
+       assert isset device
+
+       local ssid
+       local encryption
+       local key
+
+       while [ $# -gt 0 ]; do
+               case "${1}" in
+                       --ssid=*)
+                               ssid=${1#--ssid=}
+                               ;;
+                       --encryption=*)
+                               encryption=${1#--encryption=}
+                               ;;
+                       --key=*)
+                               key=${1#--key=}
+                               ;;
+               esac
+               shift
+       done
+
+       assert isset ssid
+       assert isset encryption
+       assert isset key
+
+       cat <<EOF
+# WPA supplicant configuration for ${device}.
+# DO NOT EDIT.
+
+network={
+       ssid="${ssid}"
+       proto=RSN
+       key_mgmt=${encryption}
+       pairwise=CCMP
+       group=TKIP
+       psk="${key}"
+}
+
+EOF
+}
+
+function wpa_supplicant_config_dir() {
+       local device=${1}
+
+       assert isset device
+
+       echo "${RUN_DIR}/wireless/${device}"
+}
+
+function wpa_supplicant_start() {
+       local device=${1}
+       shift
+
+       assert device_exists ${device}
+
+       local config_dir=$(wpa_supplicant_config_dir ${device})
+       mkdir -p ${config_dir}
+
+       local config_file=${config_dir}/config
+       wpa_supplicant_config_write ${device} $@ > ${config_file}
+
+       wpa_supplicant -i ${device} -D wext -B -c ${config_file} \
+               -P ${config_dir}/pid
+}
+
+function wpa_supplicant_stop() {
+       local device=${1}
+
+       assert isset device
+
+       local pid=$(wpa_supplicant_get_pid ${device})
+
+       if isset pid; then
+               process_kill ${pid}
+       else
+               warning_log "Could not find pid file for wpa_supplicant process running for ${device}."
+       fi
+
+       rm -rf $(wpa_supplicant_config_dir ${device})
+}
+
+function wpa_supplicant_get_pid() {
+       local device=${1}
+
+       assert isset device
+
+       local pid_file="$(wpa_supplicant_config_dir ${device})/pid"
+
+       [ -e "${pid_file}" ] || return ${EXIT_ERROR}
+
+       cat ${pid_file} 2>/dev/null
+       return ${EXIT_OK}
+}
+
+function wpa_supplicant_is_running() {
+       local device=${1}
+
+       assert isset device
+
+       local pid=$(wpa_supplicant_get_pid ${device})
+
+       if isset pid && [ -d "/proc/${pid}" ]; then
+               return ${EXIT_OK}
+       fi
+
+       return ${EXIT_ERROR}
+}
+
+function wpa_supplicant_get_pid() {
+       local zone=${1}
+       shift
+
+       
+}
+
+function wpa_supplicant_stop() {
+       local zone=${1}
+       shift
+
+       killall wpa_supplicant
+}