Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/wifi-ap:fix-wifi-ap-restart into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
- Git
- lp:~alfonsosanchezbeato/snappy-hwe-snaps/+git/wifi-ap
- fix-wifi-ap-restart
- Merge into master
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | b619722a038c20a74191c3071a57cfd236b3b256 |
Merged at revision: | 06b22bcbb7cf0aa96fb80a26b4c3fa18cedd91de |
Proposed branch: | ~alfonsosanchezbeato/snappy-hwe-snaps/+git/wifi-ap:fix-wifi-ap-restart |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master |
Diff against target: |
396 lines (+87/-76) 6 files modified
bin/ap.sh (+57/-52) bin/automatic-setup.sh (+3/-3) bin/config-internal.sh (+3/-3) bin/helper.sh (+5/-5) snapcraft.yaml (+19/-10) tests/lib/prepare.sh (+0/-3) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Oliver Grawert | Approve | ||
Review via email: mp+355136@code.launchpad.net |
Commit message
Description of the change
Some clean-ups and fix for lp: #1792923
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: b619722a038c20a
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:b619722a038
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: b619722a038c20a
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:b619722a038
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: b619722a038c20a
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:b619722a038
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: 2d5eda248ff0067
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2d5eda248ff
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Successfully build documentation, rev: 684c97d1238dbde
Generated documentation is available at https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:684c97d1238
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/bin/ap.sh b/bin/ap.sh | |||
2 | index be1f440..add2212 100755 | |||
3 | --- a/bin/ap.sh | |||
4 | +++ b/bin/ap.sh | |||
5 | @@ -14,22 +14,22 @@ | |||
6 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
7 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8 | 16 | 16 | ||
10 | 17 | if [ $(id -u) -ne 0 ] ; then | 17 | if [ "$(id -u)" -ne 0 ] ; then |
11 | 18 | echo "ERROR: $0 needs to be executed as root!" | 18 | echo "ERROR: $0 needs to be executed as root!" |
12 | 19 | exit 1 | 19 | exit 1 |
13 | 20 | fi | 20 | fi |
14 | 21 | 21 | ||
16 | 22 | . $SNAP/bin/config-internal.sh | 22 | . "$SNAP"/bin/config-internal.sh |
17 | 23 | 23 | ||
19 | 24 | if [ $DEBUG = "true" ]; then | 24 | if [ "$DEBUG" = "true" ]; then |
20 | 25 | set -x | 25 | set -x |
21 | 26 | fi | 26 | fi |
22 | 27 | 27 | ||
23 | 28 | # Now after we have enabled debugging or not we can safely load | 28 | # Now after we have enabled debugging or not we can safely load |
24 | 29 | # all others necessary bits. | 29 | # all others necessary bits. |
26 | 30 | . $SNAP/bin/helper.sh | 30 | . "$SNAP"/bin/helper.sh |
27 | 31 | 31 | ||
29 | 32 | if [ $DISABLED = "true" ] ; then | 32 | if [ "$DISABLED" = "true" ] ; then |
30 | 33 | echo "Not starting as WiFi AP is disabled" | 33 | echo "Not starting as WiFi AP is disabled" |
31 | 34 | exit 0 | 34 | exit 0 |
32 | 35 | fi | 35 | fi |
33 | @@ -38,23 +38,24 @@ DEFAULT_ACCESS_POINT_INTERFACE="ap0" | |||
34 | 38 | 38 | ||
35 | 39 | # Make sure the configured WiFi interface is really available before | 39 | # Make sure the configured WiFi interface is really available before |
36 | 40 | # doing anything. | 40 | # doing anything. |
38 | 41 | if ! ifconfig $WIFI_INTERFACE ; then | 41 | if ! ifconfig "$WIFI_INTERFACE" ; then |
39 | 42 | echo "ERROR: WiFi interface $WIFI_INTERFACE is not available!" | 42 | echo "ERROR: WiFi interface $WIFI_INTERFACE is not available!" |
40 | 43 | exit 1 | 43 | exit 1 |
41 | 44 | fi | 44 | fi |
42 | 45 | 45 | ||
48 | 46 | cleanup_on_exit() { | 46 | do_cleanup() { |
49 | 47 | read HOSTAPD_PID <$SNAP_DATA/hostapd.pid | 47 | if [ -f "$SNAP_DATA"/hostapd.pid ] ; then |
50 | 48 | if [ -n "$HOSTAPD_PID" ] ; then | 48 | read -r HOSTAPD_PID <"$SNAP_DATA"/hostapd.pid |
51 | 49 | kill -TERM $HOSTAPD_PID || true | 49 | kill -TERM "$HOSTAPD_PID" || true |
52 | 50 | wait $HOSTAPD_PID | 50 | wait "$HOSTAPD_PID" |
53 | 51 | rm "$SNAP_DATA"/hostapd.pid | ||
54 | 51 | fi | 52 | fi |
55 | 52 | 53 | ||
58 | 53 | read DNSMASQ_PID <$SNAP_DATA/dnsmasq.pid | 54 | if [ -f "$SNAP_DATA"/dnsmasq.pid ] ; then |
59 | 54 | if [ -n "$DNSMASQ_PID" ] ; then | 55 | read -r DNSMASQ_PID <"$SNAP_DATA"/dnsmasq.pid |
60 | 55 | # If dnsmasq is already gone don't error out here | 56 | # If dnsmasq is already gone don't error out here |
63 | 56 | kill -TERM $DNSMASQ_PID || true | 57 | kill -TERM "$DNSMASQ_PID" || true |
64 | 57 | wait $DNSMASQ_PID | 58 | wait "$DNSMASQ_PID" |
65 | 58 | fi | 59 | fi |
66 | 59 | 60 | ||
67 | 60 | iface=$WIFI_INTERFACE | 61 | iface=$WIFI_INTERFACE |
68 | @@ -62,28 +63,30 @@ cleanup_on_exit() { | |||
69 | 62 | iface=$DEFAULT_ACCESS_POINT_INTERFACE | 63 | iface=$DEFAULT_ACCESS_POINT_INTERFACE |
70 | 63 | fi | 64 | fi |
71 | 64 | 65 | ||
73 | 65 | if [ $SHARE_DISABLED = "false" ] ; then | 66 | if [ "$SHARE_DISABLED" = "false" ] ; then |
74 | 66 | # flush forwarding rules out | 67 | # flush forwarding rules out |
76 | 67 | iptables --table nat --delete POSTROUTING --out-interface $SHARE_NETWORK_INTERFACE -j MASQUERADE | 68 | iptables --table nat --delete POSTROUTING --out-interface "$SHARE_NETWORK_INTERFACE" -j MASQUERADE |
77 | 68 | iptables --delete FORWARD --in-interface $iface -j ACCEPT | 69 | iptables --delete FORWARD --in-interface $iface -j ACCEPT |
78 | 69 | sysctl -w net.ipv4.ip_forward=0 | 70 | sysctl -w net.ipv4.ip_forward=0 |
79 | 70 | fi | 71 | fi |
80 | 71 | 72 | ||
82 | 72 | if is_nm_running ; then | 73 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then |
83 | 74 | "$SNAP"/bin/iw dev $iface del | ||
84 | 75 | elif is_nm_running ; then | ||
85 | 73 | # Hand interface back to network-manager. This will also trigger the | 76 | # Hand interface back to network-manager. This will also trigger the |
86 | 74 | # auto connection process inside network-manager to get connected | 77 | # auto connection process inside network-manager to get connected |
87 | 75 | # with the previous network. | 78 | # with the previous network. |
93 | 76 | $SNAP/bin/nmcli d set $iface managed yes | 79 | "$SNAP"/bin/nmcli d set $iface managed yes |
89 | 77 | fi | ||
90 | 78 | |||
91 | 79 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then | ||
92 | 80 | $SNAP/bin/iw dev $iface del | ||
94 | 81 | fi | 80 | fi |
95 | 82 | } | 81 | } |
96 | 83 | 82 | ||
97 | 84 | # We need to install this right before we do anything to | 83 | # We need to install this right before we do anything to |
98 | 85 | # ensure that we cleanup everything again when we termiante. | 84 | # ensure that we cleanup everything again when we termiante. |
100 | 86 | trap cleanup_on_exit TERM | 85 | trap do_cleanup TERM |
101 | 86 | |||
102 | 87 | # Make initial clean-up for the case of the script being killed without | ||
103 | 88 | # a chance of finishing cleanly. | ||
104 | 89 | do_cleanup | ||
105 | 87 | 90 | ||
106 | 88 | iface=$WIFI_INTERFACE | 91 | iface=$WIFI_INTERFACE |
107 | 89 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then | 92 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then |
108 | @@ -92,7 +95,7 @@ if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then | |||
109 | 92 | # Make sure if the real wifi interface is connected we use | 95 | # Make sure if the real wifi interface is connected we use |
110 | 93 | # the same channel for our AP as otherwise the created AP | 96 | # the same channel for our AP as otherwise the created AP |
111 | 94 | # will not work. | 97 | # will not work. |
113 | 95 | channel_in_use=$($SNAP/bin/iw dev $WIFI_INTERFACE info |awk '/channel/{print$2}') | 98 | channel_in_use=$("$SNAP"/bin/iw dev "$WIFI_INTERFACE" info |awk '/channel/{print$2}') |
114 | 96 | if [ -z "$channel_in_use" ]; then | 99 | if [ -z "$channel_in_use" ]; then |
115 | 97 | echo "WARNING: WiFi is currently not connected so we can't determine" | 100 | echo "WARNING: WiFi is currently not connected so we can't determine" |
116 | 98 | echo " which channel we can use for the AP. This will most" | 101 | echo " which channel we can use for the AP. This will most" |
117 | @@ -109,10 +112,9 @@ fi | |||
118 | 109 | # Create our AP interface if required | 112 | # Create our AP interface if required |
119 | 110 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then | 113 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then |
120 | 111 | iface=$DEFAULT_ACCESS_POINT_INTERFACE | 114 | iface=$DEFAULT_ACCESS_POINT_INTERFACE |
123 | 112 | $SNAP/bin/iw dev $WIFI_INTERFACE interface add $iface type __ap | 115 | if ! "$SNAP"/bin/iw dev "$WIFI_INTERFACE" interface add $iface type __ap ; then |
122 | 113 | if [ $? -ne 0 ] ; then | ||
124 | 114 | echo "ERROR: Failed to create virtual WiFi network interface" | 116 | echo "ERROR: Failed to create virtual WiFi network interface" |
126 | 115 | cleanup_on_exit | 117 | do_cleanup |
127 | 116 | fi | 118 | fi |
128 | 117 | wait_until_interface_is_available $iface | 119 | wait_until_interface_is_available $iface |
129 | 118 | fi | 120 | fi |
130 | @@ -126,53 +128,52 @@ if is_nm_running ; then | |||
131 | 126 | # Prevent network-manager from touching the interface we want to use. If | 128 | # Prevent network-manager from touching the interface we want to use. If |
132 | 127 | # network-manager was configured to use the interface its nothing we want | 129 | # network-manager was configured to use the interface its nothing we want |
133 | 128 | # to prevent here as this is how the user configured the system. | 130 | # to prevent here as this is how the user configured the system. |
135 | 129 | $SNAP/bin/nmcli d set $iface managed no | 131 | "$SNAP"/bin/nmcli d set $iface managed no |
136 | 130 | fi | 132 | fi |
137 | 131 | 133 | ||
138 | 132 | # Initial wifi interface configuration | 134 | # Initial wifi interface configuration |
141 | 133 | ifconfig $iface up | 135 | if ! ifconfig "$iface" up ; then |
140 | 134 | if [ $? -ne 0 ] ; then | ||
142 | 135 | echo "ERROR: Failed to enable WiFi network interface '$iface'" | 136 | echo "ERROR: Failed to enable WiFi network interface '$iface'" |
143 | 136 | 137 | ||
144 | 137 | # Remove virtual interface again if we created one | 138 | # Remove virtual interface again if we created one |
145 | 138 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then | 139 | if [ "$WIFI_INTERFACE_MODE" = "virtual" ] ; then |
147 | 139 | $SNAP/bin/iw dev $iface del | 140 | "$SNAP"/bin/iw dev $iface del |
148 | 140 | fi | 141 | fi |
149 | 141 | 142 | ||
150 | 142 | if is_nm_running ; then | 143 | if is_nm_running ; then |
151 | 143 | # Hand interface back to network-manager. This will also trigger the | 144 | # Hand interface back to network-manager. This will also trigger the |
152 | 144 | # auto connection process inside network-manager to get connected | 145 | # auto connection process inside network-manager to get connected |
153 | 145 | # with the previous network. | 146 | # with the previous network. |
155 | 146 | $SNAP/bin/nmcli d set $iface managed yes | 147 | "$SNAP"/bin/nmcli d set $iface managed yes |
156 | 147 | fi | 148 | fi |
157 | 148 | 149 | ||
158 | 149 | exit 1 | 150 | exit 1 |
159 | 150 | fi | 151 | fi |
160 | 151 | 152 | ||
161 | 152 | # Configure interface and give it a moment to settle | 153 | # Configure interface and give it a moment to settle |
163 | 153 | ifconfig $iface $WIFI_ADDRESS netmask $WIFI_NETMASK | 154 | ifconfig "$iface" "$WIFI_ADDRESS" netmask "$WIFI_NETMASK" |
164 | 154 | sleep 2 | 155 | sleep 2 |
165 | 155 | 156 | ||
167 | 156 | if [ $SHARE_DISABLED = "false" ] ; then | 157 | if [ "$SHARE_DISABLED" = "false" ] ; then |
168 | 157 | # Enable NAT to forward our network connection | 158 | # Enable NAT to forward our network connection |
170 | 158 | iptables --table nat --append POSTROUTING --out-interface $SHARE_NETWORK_INTERFACE -j MASQUERADE | 159 | iptables --table nat --append POSTROUTING --out-interface "$SHARE_NETWORK_INTERFACE" -j MASQUERADE |
171 | 159 | iptables --append FORWARD --in-interface $iface -j ACCEPT | 160 | iptables --append FORWARD --in-interface $iface -j ACCEPT |
172 | 160 | sysctl -w net.ipv4.ip_forward=1 | 161 | sysctl -w net.ipv4.ip_forward=1 |
173 | 161 | fi | 162 | fi |
174 | 162 | 163 | ||
177 | 163 | generate_dnsmasq_config $SNAP_DATA/dnsmasq.conf | 164 | generate_dnsmasq_config "$SNAP_DATA"/dnsmasq.conf |
178 | 164 | $SNAP/bin/dnsmasq \ | 165 | "$SNAP"/bin/dnsmasq \ |
179 | 165 | -k \ | 166 | -k \ |
183 | 166 | -C $SNAP_DATA/dnsmasq.conf \ | 167 | -C "$SNAP_DATA"/dnsmasq.conf \ |
184 | 167 | -l $SNAP_DATA/dnsmasq.leases \ | 168 | -l "$SNAP_DATA"/dnsmasq.leases \ |
185 | 168 | -x $SNAP_DATA/dnsmasq.pid \ | 169 | -x "$SNAP_DATA"/dnsmasq.pid \ |
186 | 169 | -u root -g root \ | 170 | -u root -g root \ |
187 | 170 | & | 171 | & |
188 | 171 | 172 | ||
189 | 172 | driver=$WIFI_HOSTAPD_DRIVER | 173 | driver=$WIFI_HOSTAPD_DRIVER |
190 | 173 | 174 | ||
191 | 174 | # Generate our hostapd configuration file | 175 | # Generate our hostapd configuration file |
193 | 175 | cat <<EOF > $SNAP_DATA/hostapd.conf | 176 | cat <<EOF > "$SNAP_DATA"/hostapd.conf |
194 | 176 | interface=$iface | 177 | interface=$iface |
195 | 177 | driver=$driver | 178 | driver=$driver |
196 | 178 | channel=$WIFI_CHANNEL | 179 | channel=$WIFI_CHANNEL |
197 | @@ -214,7 +215,7 @@ wmm_ac_vo_acm=0 | |||
198 | 214 | EOF | 215 | EOF |
199 | 215 | 216 | ||
200 | 216 | if [ -n "$WIFI_COUNTRY_CODE" ] ; then | 217 | if [ -n "$WIFI_COUNTRY_CODE" ] ; then |
202 | 217 | cat <<-EOF >> $SNAP_DATA/hostapd.conf | 218 | cat <<-EOF >> "$SNAP_DATA"/hostapd.conf |
203 | 218 | # Regulatory domain options | 219 | # Regulatory domain options |
204 | 219 | country_code=$WIFI_COUNTRY_CODE | 220 | country_code=$WIFI_COUNTRY_CODE |
205 | 220 | # Send country code in beacon frames | 221 | # Send country code in beacon frames |
206 | @@ -226,7 +227,7 @@ if [ -n "$WIFI_COUNTRY_CODE" ] ; then | |||
207 | 226 | # End reg domain options | 227 | # End reg domain options |
208 | 227 | EOF | 228 | EOF |
209 | 228 | else | 229 | else |
211 | 229 | cat <<-EOF >> $SNAP_DATA/hostapd.conf | 230 | cat <<-EOF >> "$SNAP_DATA"/hostapd.conf |
212 | 230 | # Regulatory domain options | 231 | # Regulatory domain options |
213 | 231 | # Country code set to global | 232 | # Country code set to global |
214 | 232 | country_code=XX | 233 | country_code=XX |
215 | @@ -236,11 +237,11 @@ fi | |||
216 | 236 | 237 | ||
217 | 237 | case "$WIFI_SECURITY" in | 238 | case "$WIFI_SECURITY" in |
218 | 238 | open) | 239 | open) |
220 | 239 | cat <<-EOF >> $SNAP_DATA/hostapd.conf | 240 | cat <<-EOF >> "$SNAP_DATA"/hostapd.conf |
221 | 240 | EOF | 241 | EOF |
222 | 241 | ;; | 242 | ;; |
223 | 242 | wpa2) | 243 | wpa2) |
225 | 243 | cat <<-EOF >> $SNAP_DATA/hostapd.conf | 244 | cat <<-EOF >> "$SNAP_DATA"/hostapd.conf |
226 | 244 | wpa=2 | 245 | wpa=2 |
227 | 245 | wpa_key_mgmt=WPA-PSK | 246 | wpa_key_mgmt=WPA-PSK |
228 | 246 | wpa_passphrase=$WIFI_SECURITY_PASSPHRASE | 247 | wpa_passphrase=$WIFI_SECURITY_PASSPHRASE |
229 | @@ -255,16 +256,20 @@ esac | |||
230 | 255 | 256 | ||
231 | 256 | EXTRA_ARGS= | 257 | EXTRA_ARGS= |
232 | 257 | if [ "$DEBUG" = "true" ] ; then | 258 | if [ "$DEBUG" = "true" ] ; then |
234 | 258 | EXTRA_ARGS="$EXTRA_ARGS -ddd -t" | 259 | EXTRA_ARGS="-ddd -t" |
235 | 259 | fi | 260 | fi |
236 | 260 | 261 | ||
238 | 261 | hostapd=$SNAP/bin/hostapd | 262 | hostapd="$SNAP"/bin/hostapd |
239 | 262 | 263 | ||
240 | 263 | # Startup hostapd with the configuration we've put in place | 264 | # Startup hostapd with the configuration we've put in place |
242 | 264 | $hostapd $EXTRA_ARGS $SNAP_DATA/hostapd.conf & | 265 | # We need to tolerate no double quotes for EXTRA_ARGS, as it can be |
243 | 266 | # empty - this is safe as the definition of the variable is internal. | ||
244 | 267 | # shellcheck disable=SC2086 | ||
245 | 268 | $hostapd $EXTRA_ARGS "$SNAP_DATA"/hostapd.conf & | ||
246 | 265 | hostapd_pid=$! | 269 | hostapd_pid=$! |
249 | 266 | echo $hostapd_pid > $SNAP_DATA/hostapd.pid | 270 | echo $hostapd_pid > "$SNAP_DATA"/hostapd.pid |
250 | 267 | wait $hostapd_pid | 271 | # When TERM is received, wait will return and immediately after that |
251 | 272 | # do_cleanup will be called. | ||
252 | 273 | wait | ||
253 | 268 | 274 | ||
254 | 269 | cleanup_on_exit | ||
255 | 270 | exit 0 | 275 | exit 0 |
256 | diff --git a/bin/automatic-setup.sh b/bin/automatic-setup.sh | |||
257 | index 871429b..1b8f79f 100755 | |||
258 | --- a/bin/automatic-setup.sh | |||
259 | +++ b/bin/automatic-setup.sh | |||
260 | @@ -19,7 +19,7 @@ set -x | |||
261 | 19 | # Wait for the snap to be successfully setup. This will only be true | 19 | # Wait for the snap to be successfully setup. This will only be true |
262 | 20 | # when the snap is started the first time and the configure hook was | 20 | # when the snap is started the first time and the configure hook was |
263 | 21 | # never called before. | 21 | # never called before. |
265 | 22 | while [ ! -e $SNAP_COMMON/.setup_done ]; do | 22 | while [ ! -e "$SNAP_COMMON"/.setup_done ]; do |
266 | 23 | sleep 0.5 | 23 | sleep 0.5 |
267 | 24 | done | 24 | done |
268 | 25 | 25 | ||
269 | @@ -27,8 +27,8 @@ done | |||
270 | 27 | 27 | ||
271 | 28 | [ -f "$SNAP_DATA/config" ] && exit 0 | 28 | [ -f "$SNAP_DATA/config" ] && exit 0 |
272 | 29 | 29 | ||
274 | 30 | while ! $SNAP/bin/client status; do | 30 | while ! "$SNAP"/bin/client status; do |
275 | 31 | sleep .5 | 31 | sleep .5 |
276 | 32 | done | 32 | done |
277 | 33 | 33 | ||
279 | 34 | exec $SNAP/bin/client wizard --auto | 34 | exec "$SNAP"/bin/client wizard --auto |
280 | diff --git a/bin/config-internal.sh b/bin/config-internal.sh | |||
281 | index aa48897..c2768ac 100755 | |||
282 | --- a/bin/config-internal.sh | |||
283 | +++ b/bin/config-internal.sh | |||
284 | @@ -14,14 +14,14 @@ | |||
285 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
286 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
287 | 16 | 16 | ||
289 | 17 | . $SNAP/conf/default-config | 17 | . "$SNAP"/conf/default-config |
290 | 18 | 18 | ||
291 | 19 | # We allow the user to place two configuration files. One which | 19 | # We allow the user to place two configuration files. One which |
292 | 20 | # he can provide on its own in $SNAP_USER_DATA/config and one | 20 | # he can provide on its own in $SNAP_USER_DATA/config and one |
293 | 21 | # which only our scripts will modify in $SNAP_DATA/config | 21 | # which only our scripts will modify in $SNAP_DATA/config |
294 | 22 | if [ -e "$SNAP_DATA/config" ] ; then | 22 | if [ -e "$SNAP_DATA/config" ] ; then |
296 | 23 | . $SNAP_DATA/config | 23 | . "$SNAP_DATA"/config |
297 | 24 | fi | 24 | fi |
298 | 25 | if [ -e "$SNAP_USER_DATA/config" ] ; then | 25 | if [ -e "$SNAP_USER_DATA/config" ] ; then |
300 | 26 | . $SNAP_USER_DATA/config | 26 | . "$SNAP_USER_DATA"/config |
301 | 27 | fi | 27 | fi |
302 | diff --git a/bin/helper.sh b/bin/helper.sh | |||
303 | index 147fe89..f3426a3 100644 | |||
304 | --- a/bin/helper.sh | |||
305 | +++ b/bin/helper.sh | |||
306 | @@ -15,18 +15,18 @@ | |||
307 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
308 | 16 | 16 | ||
309 | 17 | does_interface_exist() { | 17 | does_interface_exist() { |
311 | 18 | [ -d /sys/class/net/$1 ] | 18 | [ -d /sys/class/net/"$1" ] |
312 | 19 | } | 19 | } |
313 | 20 | 20 | ||
314 | 21 | wait_until_interface_is_available() { | 21 | wait_until_interface_is_available() { |
316 | 22 | while ! does_interface_exist $1; do | 22 | while ! does_interface_exist "$1"; do |
317 | 23 | # Wait for 200ms | 23 | # Wait for 200ms |
318 | 24 | sleep 0.2 | 24 | sleep 0.2 |
319 | 25 | done | 25 | done |
320 | 26 | } | 26 | } |
321 | 27 | 27 | ||
322 | 28 | assert_not_managed_by_ifupdown() { | 28 | assert_not_managed_by_ifupdown() { |
324 | 29 | if [ -e /etc/network/interfaces.d/$1 ]; then | 29 | if [ -e /etc/network/interfaces.d/"$1" ]; then |
325 | 30 | echo "ERROR: Interface $1 is managed by ifupdown and can't be used" | 30 | echo "ERROR: Interface $1 is managed by ifupdown and can't be used" |
326 | 31 | exit 1 | 31 | exit 1 |
327 | 32 | fi | 32 | fi |
328 | @@ -49,10 +49,10 @@ generate_dnsmasq_config() { | |||
329 | 49 | dhcp-range=$DHCP_RANGE_START,$DHCP_RANGE_STOP,$DHCP_LEASE_TIME | 49 | dhcp-range=$DHCP_RANGE_START,$DHCP_RANGE_STOP,$DHCP_LEASE_TIME |
330 | 50 | dhcp-option=6, $WIFI_ADDRESS | 50 | dhcp-option=6, $WIFI_ADDRESS |
331 | 51 | EOF | 51 | EOF |
333 | 52 | } > $1 | 52 | } > "$1" |
334 | 53 | } | 53 | } |
335 | 54 | 54 | ||
336 | 55 | is_nm_running() { | 55 | is_nm_running() { |
338 | 56 | nm_status=`$SNAP/bin/nmcli -t -f RUNNING general` | 56 | nm_status=$("$SNAP"/bin/nmcli -t -f RUNNING general) |
339 | 57 | [ "$nm_status" = "running" ] | 57 | [ "$nm_status" = "running" ] |
340 | 58 | } | 58 | } |
341 | diff --git a/snapcraft.yaml b/snapcraft.yaml | |||
342 | index fbbdb2d..a1d3190 100644 | |||
343 | --- a/snapcraft.yaml | |||
344 | +++ b/snapcraft.yaml | |||
345 | @@ -70,18 +70,27 @@ parts: | |||
346 | 70 | prime: | 70 | prime: |
347 | 71 | - $binaries | 71 | - $binaries |
348 | 72 | 72 | ||
349 | 73 | go: | ||
350 | 74 | source-tag: go1.9.2 | ||
351 | 75 | |||
352 | 73 | service: | 76 | service: |
360 | 74 | plugin: go | 77 | after: [go] |
361 | 75 | source: . | 78 | plugin: make |
362 | 76 | go-importpath: launchpad.net/wifi-ap | 79 | build: | |
363 | 77 | prime: | 80 | set -ex |
364 | 78 | - bin | 81 | export GOPATH=$(mktemp -d) |
365 | 79 | install: | | 82 | (src_path="$GOPATH"/src/launchpad.net/wifi-ap |
366 | 80 | export GOPATH=$PWD/../go | 83 | mkdir -p "$src_path" |
367 | 84 | cp -a cmd "$src_path" | ||
368 | 85 | cd "$src_path" | ||
369 | 86 | go get -t -d ... | ||
370 | 87 | mkdir -p $SNAPCRAFT_PART_INSTALL/bin/ | ||
371 | 81 | for d in client service ; do | 88 | for d in client service ; do |
375 | 82 | cd $GOPATH/src/launchpad.net/wifi-ap/cmd/$d | 89 | cd $GOPATH/src/launchpad.net/wifi-ap/cmd/"$d" |
376 | 83 | go test -v | 90 | go build |
377 | 84 | done | 91 | cp -f "$d" $SNAPCRAFT_PART_INSTALL/bin/ |
378 | 92 | done) | ||
379 | 93 | rm -rf "$GOPATH" | ||
380 | 85 | 94 | ||
381 | 86 | dnsmasq: | 95 | dnsmasq: |
382 | 87 | plugin: make | 96 | plugin: make |
383 | diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh | |||
384 | index 7e27528..be54593 100644 | |||
385 | --- a/tests/lib/prepare.sh | |||
386 | +++ b/tests/lib/prepare.sh | |||
387 | @@ -20,9 +20,6 @@ for name in $gadget_name $kernel_name $core_name; do | |||
388 | 20 | fi | 20 | fi |
389 | 21 | done | 21 | done |
390 | 22 | 22 | ||
391 | 23 | echo "Kernel has a store revision" | ||
392 | 24 | snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical" | ||
393 | 25 | |||
394 | 26 | # Snapshot of the current snapd state for a later restore | 23 | # Snapshot of the current snapd state for a later restore |
395 | 27 | if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then | 24 | if [ ! -f $SPREAD_PATH/snapd-state.tar.gz ] ; then |
396 | 28 | systemctl stop snapd.service snapd.socket | 25 | systemctl stop snapd.service snapd.socket |
looks good (unrelated, i'm not sure if core18 will still ship the ifconfig binary, it might be good to move the ifconfig calls to become "ip" calls in a future commit)