Merge ~morphis/snappy-hwe-snaps/+git/wifi-ap:small-fixes-for-plano into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master

Proposed by Simon Fels
Status: Merged
Approved by: Simon Fels
Approved revision: 5d1e564a09f192f9d0c81fd271122e9fe0ed5c69
Merged at revision: 6899817c59ad0bcae17cac8bb6a43fa6fa40c4e7
Proposed branch: ~morphis/snappy-hwe-snaps/+git/wifi-ap:small-fixes-for-plano
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
Diff against target: 180 lines (+41/-26)
4 files modified
bin/ap.sh (+11/-11)
bin/helper.sh (+7/-4)
cmd/client/cmd_wizard.go (+20/-8)
conf/default-config (+3/-3)
Reviewer Review Type Date Requested Status
Matteo Croce (community) Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+309450@code.launchpad.net

Description of the change

Multiple fixes

 * Make wizard work correct and set the correct configuration values
 * Use same DHCP configuration as on 15.04

To post a comment you must log in.
Revision history for this message
Matteo Croce (teknoraver) :
review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matteo Croce (teknoraver) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matteo Croce (teknoraver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/ap.sh b/bin/ap.sh
2index 89750fa..3dcb93d 100755
3--- a/bin/ap.sh
4+++ b/bin/ap.sh
5@@ -45,7 +45,7 @@ cleanup_on_exit() {
6 wait $DNSMASQ_PID
7
8 iface=$WIFI_INTERFACE
9- if [ "$WIFI_INTERFACE_MODE" == "virtual" ] ; then
10+ if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then
11 iface=$DEFAULT_ACCESS_POINT_INTERFACE
12 fi
13
14@@ -56,7 +56,7 @@ cleanup_on_exit() {
15 sysctl -w net.ipv4.ip_forward=0
16 fi
17
18- if [ "$WIFI_INTERFACE_MODE" == "virtual" ] ; then
19+ if [ "$WIFI_INTERFACE_MODE" = "virtual" ] && does_interface_exist $iface ; then
20 $SNAP/bin/iw dev $iface del
21 fi
22
23@@ -69,14 +69,14 @@ cleanup_on_exit() {
24 }
25
26 iface=$WIFI_INTERFACE
27-if [ "$WIFI_INTERFACE_MODE" == "virtual" ] ; then
28+if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then
29 iface=$DEFAULT_ACCESS_POINT_INTERFACE
30
31 # Make sure if the real wifi interface is connected we use
32 # the same channel for our AP as otherwise the created AP
33 # will not work.
34 channel_in_use=$(iw dev $WIFI_INTERFACE info |awk '/channel/{print$2}')
35- if [ $channel_in_use != $WIFI_CHANNEL ] ; then
36+ if [ "$channel_in_use" != "$WIFI_CHANNEL" ] ; then
37 echo "ERROR: You configured a different channel than the WiFi device"
38 echo " is currently using. This will not work as most devices"
39 echo " require you to operate for AP and STA on the same channel."
40@@ -88,7 +88,11 @@ fi
41 if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then
42 iface=$DEFAULT_ACCESS_POINT_INTERFACE
43 $SNAP/bin/iw dev $WIFI_INTERFACE interface add $iface type __ap
44- sleep 2
45+ if [ $? -ne 0 ] ; then
46+ echo "ERROR: Failed to create virtual WiFi network interface"
47+ cleanup_on_exit
48+ fi
49+ wait_until_interface_is_available $iface
50 fi
51 if [ "$WIFI_INTERFACE_MODE" = "direct" ] ; then
52 # If WiFi interface is managed by ifupdown or network-manager leave it as is
53@@ -137,12 +141,8 @@ fi
54 generate_dnsmasq_config $SNAP_DATA/dnsmasq.conf
55 $SNAP/bin/dnsmasq -k -C $SNAP_DATA/dnsmasq.conf -l $SNAP_DATA/dnsmasq.leases -x $SNAP_DATA/dnsmasq.pid &
56
57-# Wait a bit until our WiFi network interface is correctly
58-# setup by dnsmasq
59-wait_until_interface_is_available $iface
60-
61 driver=$WIFI_HOSTAPD_DRIVER
62-if [ "$driver" == "rtl8188" ] ; then
63+if [ "$driver" = "rtl8188" ] ; then
64 driver=rtl871xdrv
65 fi
66
67@@ -181,7 +181,7 @@ case "$WIFI_SECURITY" in
68 esac
69
70 EXTRA_ARGS=
71-if [ "$DEBUG" == "1" ] ; then
72+if [ "$DEBUG" = "1" ] ; then
73 EXTRA_ARGS="$EXTRA_ARGS -ddd -t"
74 fi
75
76diff --git a/bin/helper.sh b/bin/helper.sh
77index 5ad68f5..718a2d6 100644
78--- a/bin/helper.sh
79+++ b/bin/helper.sh
80@@ -16,11 +16,14 @@
81
82 set -x
83
84+does_interface_exist() {
85+ grep -q $1 /proc/net/dev
86+}
87+
88 wait_until_interface_is_available() {
89- grep $1 /proc/net/dev &> /dev/null
90- while [ $? != 0 ] ; do
91- sleep 5
92- grep $1 /proc/net/dev &> /dev/null
93+ while ! does_interface_exist $iface; do
94+ # Wait for 10ms
95+ sleep 0.01
96 done
97 }
98
99diff --git a/cmd/client/cmd_wizard.go b/cmd/client/cmd_wizard.go
100index 5ba1357..9a9ebd5 100644
101--- a/cmd/client/cmd_wizard.go
102+++ b/cmd/client/cmd_wizard.go
103@@ -92,7 +92,7 @@ var allSteps = [...]wizardStep{
104 if len(iface) == 0 || len(iface) > 31 {
105 return fmt.Errorf("ESSID length must be between 1 and 31 characters")
106 }
107- configuration["wifi.essid"] = iface
108+ configuration["wifi.ssid"] = iface
109
110 return nil
111 },
112@@ -122,7 +122,7 @@ var allSteps = [...]wizardStep{
113 if len(key) < 8 || len(key) > 63 {
114 return fmt.Errorf("WPA2 passphrase must be between 8 and 63 characters")
115 }
116- configuration["wifi.passphrase"] = key
117+ configuration["wifi.security-passphrase"] = key
118
119 return nil
120 },
121@@ -223,6 +223,23 @@ var allSteps = [...]wizardStep{
122
123 return nil
124 },
125+
126+ func (configuration map[string]string, reader *bufio.Reader) error {
127+ fmt.Print("Do you want to enable the AP now? (y/n) ")
128+ switch resp := strings.ToLower(readUserInput(reader)); resp {
129+ case "y":
130+ configuration["disabled"] = "0"
131+
132+ fmt.Println("In order to get the AP correctly enabled you have to restart the backend service:")
133+ fmt.Println(" $ systemctl restart snap.wifi-ap.backend")
134+ case "n":
135+ configuration["disabled"] = "1"
136+ default:
137+ return fmt.Errorf("Invalid answer: %s", resp)
138+ }
139+
140+ return nil
141+ },
142 }
143
144 // Use the REST API to set the configuration
145@@ -249,12 +266,7 @@ type wizardCommand struct{}
146
147 func (cmd *wizardCommand) Execute(args []string) error {
148 // Setup some sane default values, we don't ask the user for everything
149- configuration := map[string]string{
150- "disabled": "0",
151- "wifi.channel": "6",
152- "wifi.operation-mode": "g",
153- "dhcp.lease-time": "12h",
154- }
155+ configuration := map[string]string{}
156
157 reader := bufio.NewReader(os.Stdin)
158
159diff --git a/conf/default-config b/conf/default-config
160index 2bbf816..1af80f8 100644
161--- a/conf/default-config
162+++ b/conf/default-config
163@@ -21,7 +21,7 @@ DEBUG=0
164
165 # Default configuration
166 WIFI_INTERFACE=wlan0
167-WIFI_ADDRESS=192.168.7.1
168+WIFI_ADDRESS=10.0.60.1
169 WIFI_NETMASK=255.255.255.0
170
171 # Possible options are: virtual, direct
172@@ -52,7 +52,7 @@ WIFI_OPERATION_MODE="g"
173 # clients. Set to 'none' for not shared network connection.
174 SHARE_NETWORK_INTERFACE=eth0
175
176-DHCP_RANGE_START=192.168.7.5
177-DHCP_RANGE_STOP=192.168.7.100
178+DHCP_RANGE_START=10.0.60.3
179+DHCP_RANGE_STOP=10.0.60.20
180 DHCP_LEASE_TIME="12h"
181

Subscribers

People subscribed via source and target branches

to all changes: