~ubuntu-branches/ubuntu/gutsy/wpasupplicant/gutsy

« back to all changes in this revision

Viewing changes to debian/ifupdown.sh

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Copyright (C) 2006 Debian/Ubuntu wpasupplicant Maintainers 
 
4
# <pkg-wpa-devel@lists.alioth.debian.org>
 
5
#
 
6
# This program is free software; you can redistribute it and/or
 
7
# modify it under the terms of the GNU General Public License
 
8
# as published by the Free Software Foundation; either version 2
 
9
# of the License, or (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# On Debian GNU/Linux systems, the text of the GPL license can be
 
17
# found in /usr/share/common-licenses/GPL.
 
18
 
 
19
if [ -n "$IF_WPA_MAINT_DEBUG" ]; then
 
20
        set -x
 
21
fi
 
22
 
 
23
# quit if we're called for the loopback
 
24
if [ "$IFACE" = lo ]; then
 
25
        exit 0
 
26
fi
 
27
 
 
28
# allow wpa_supplicant interface to be specified via wpa-iface
 
29
# useful for starting wpa_supplicant on one interface of a bridge
 
30
if [ -n "$IF_WPA_IFACE" ]; then
 
31
        WPA_IFACE="$IF_WPA_IFACE"
 
32
else
 
33
        WPA_IFACE="$IFACE"
 
34
fi
 
35
 
 
36
# source functions
 
37
if [ -f /etc/wpa_supplicant/functions.sh ]; then
 
38
        . /etc/wpa_supplicant/functions.sh
 
39
else
 
40
        exit 0
 
41
fi
 
42
 
 
43
# quit if executables are not installed
 
44
if [ ! -x "$WPA_SUP_BIN" ] || [ ! -x "$WPA_CLI_BIN" ]; then
 
45
        exit 0
 
46
fi
 
47
 
 
48
# quit if wpa_action is active
 
49
if test_wpa_cli; then
 
50
        exit 0
 
51
fi
 
52
 
 
53
# preliminary sanity checks for roaming daemon
 
54
if [ -n "$IF_WPA_ROAM" ]; then
 
55
        if [ "$METHOD" != "manual" ]; then
 
56
                wpa_msg stderr "wpa-roam can only be used with the \"manual\" inet METHOD"
 
57
                exit 1
 
58
        fi
 
59
        if [ -n "$IF_WPA_MAPPING_SCRIPT" ]; then
 
60
                if ! type "$IF_WPA_MAPPING_SCRIPT" >/dev/null; then
 
61
                        wpa_msg stderr "wpa-mapping-script \"$IF_WPA_MAPPING_SCRIPT\" is not valid"
 
62
                        exit 1
 
63
                fi
 
64
        fi
 
65
        if [ -n "$IF_WPA_MAPPING_SCRIPT_PRIORITY" ] && [ -z "$IF_WPA_MAPPING_SCRIPT" ]; then
 
66
                wpa_msg stderr "\"wpa-mapping-script-priority 1\" is invalid without a wpa-mapping-script"
 
67
                exit 1
 
68
        fi
 
69
        IF_WPA_CONF="$IF_WPA_ROAM"
 
70
        WPA_ACTION_SCRIPT="/sbin/wpa_action"
 
71
fi
 
72
 
 
73
# master function; determines if ifupdown.sh should do something or not
 
74
if [ -n "$IF_WPA_CONF" ]; then
 
75
        if [ ! -s "$IF_WPA_CONF" ]; then
 
76
                wpa_msg stderr "cannot read contents of $IF_WPA_CONF"
 
77
                exit 1
 
78
        fi      
 
79
        WPA_SUP_CONF_CTRL_DIR=$(sed --quiet \
 
80
                's/[[:space:]]*#.*//g;s/[[:space:]]\+.*$//g;s/^\(ctrl_interface\|DIR\)=\(.*\)/\2/p' "$IF_WPA_CONF")
 
81
        if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
 
82
                WPA_CTRL_DIR="$WPA_SUP_CONF_CTRL_DIR"
 
83
        fi
 
84
        WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_CTRL_DIR"
 
85
elif set | grep --quiet "^IF_WPA"; then
 
86
        WPA_SUP_CONF="-C $WPA_CTRL_DIR"
 
87
else
 
88
        exit 0
 
89
fi
 
90
 
 
91
case "$MODE" in 
 
92
        start)
 
93
                case "$PHASE" in
 
94
                        pre-up)
 
95
                                kill_wpa_supplicant
 
96
                                init_wpa_supplicant     || exit 1
 
97
                                conf_wpa_supplicant     || { kill_wpa_supplicant; exit 1; }
 
98
                                ;;
 
99
                        post-up)
 
100
                                init_wpa_cli            || { kill_wpa_supplicant; exit 1; }
 
101
                                ;;
 
102
                esac
 
103
                ;;
 
104
 
 
105
        stop)
 
106
                case "$PHASE" in
 
107
                        pre-down)
 
108
                                kill_wpa_cli
 
109
                                ;;
 
110
                        post-down)
 
111
                                kill_wpa_supplicant
 
112
                                ;;
 
113
                        *)
 
114
                                wpa_msg stderr "unknown phase: \"$PHASE\""
 
115
                                exit 1
 
116
                                ;;
 
117
                esac
 
118
                ;;
 
119
        
 
120
        *)
 
121
                wpa_msg stderr "unknown mode: \"$MODE\""
 
122
                exit 1
 
123
                ;;
 
124
esac
 
125
 
 
126
exit 0