Alfonso Sanchez-Beato has proposed merging 
~alfonsosanchezbeato/network-manager:add-connectivity-check into 
network-manager:snap-1.10.

Commit message:
* Remove duplicated configure hook
* Adapt dns options to UC series
* Allow installation on UC16 as dns is not an issue anymore
* Add support for connectivity check via ubuntu core options
* Disable MAC randomization feature
* Remove obsoleted no-system-libraries attribute from snapcraft.yaml

Requested reviews:
  Network-manager (network-manager)
Related bugs:
  Bug #1681513 in network-manager (Ubuntu): "Ubuntu 17.04/17.10: New feature in 
NetworkManager stops several WiFi adapters from working (MAC Address 
Randomization issue)"
  https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1681513

For more details, see:
https://code.launchpad.net/~alfonsosanchezbeato/network-manager/+git/network-manager/+merge/361245

* Remove duplicated configure hook
* Adapt dns options to UC series
* Allow installation on UC16 as dns is not an issue anymore
* Add support for connectivity check via ubuntu core options
* Disable MAC randomization feature
* Remove obsoleted no-system-libraries attribute from snapcraft.yaml
-- 
Your team Network-manager is requested to review the proposed merge of 
~alfonsosanchezbeato/network-manager:add-connectivity-check into 
network-manager:snap-1.10.
diff --git a/hooks/configure b/hooks/configure
deleted file mode 100755
index 4f0fe5b..0000000
--- a/hooks/configure
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/sh -ex
-# Copyright (C) 2016-2018 Canonical Ltd
-#
-# 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 2 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/>.
-
-# Configure hook has two missions:
-# 1. Set properties defaults on installation, so users can see them
-# 2. Re-start daemon if a property has changed
-
-. "$SNAP"/bin/snap-prop.sh
-
-props_file="$SNAP_DATA"/current_snap_props
-
-_create_props_content() {
-    printf "wifi_powersave=%s\n" "$wifi_powersave"
-    printf "wifi_wake_on_wlan=%s\n" "$wifi_wake_on_wlan"
-    printf "wifi_wake_on_password=%s\n" "$wifi_wake_on_password"
-    printf "ethernet_enable=%s\n" "$ethernet_enable"
-    printf "debug_enable=%s\n" "$debug_enable"
-}
-
-wifi_powersave=$(get_wifi_powersave)
-wifi_wake_on_wlan=$(get_wifi_wake_on_wlan)
-wifi_wake_on_password=$(get_wifi_wake_on_password)
-ethernet_enable=$(get_ethernet_enable)
-debug_enable=$(get_debug_enable)
-
-# Store always, so we show defaults when properties are set to empty strings
-snapctl set wifi.powersave="$wifi_powersave"
-snapctl set wifi.wake-on-wlan="$wifi_wake_on_wlan"
-snapctl set wifi.wake-on-wlan-password="$wifi_wake_on_password"
-snapctl set ethernet.enable="$ethernet_enable"
-snapctl set debug.enable="$debug_enable"
-
-content=$(_create_props_content)
-
-if [ ! -e "$props_file" ]; then
-    # Installation or refresh from old snap. Assign defaults.
-    echo "$content" > "$props_file"
-    return 0
-fi
-
-old_content=$(cat "$props_file")
-if [ "$content" = "$old_content" ]; then
-    # No change in properties, this must be a snap refresh
-    return 0
-fi
-
-# Some property changed, store new values and re-start daemon to apply changes
-echo "$content" > "$props_file"
-snapctl restart "$SNAP_NAME"
diff --git a/snap-common/bin/networkmanager b/snap-common/bin/networkmanager
index bec5f63..be4ca09 100755
--- a/snap-common/bin/networkmanager
+++ b/snap-common/bin/networkmanager
@@ -44,6 +44,15 @@ if [ -e "$SNAP_DATA"/NetworkManager.conf ]; then
     NM_CONF=$SNAP_DATA/NetworkManager.conf
 fi
 
+# Use right DNS settings depending on UC series
+. "$SNAP"/bin/utils.sh
+dns_conf_file="$SNAP_DATA"/conf.d/10-dns.conf
+if [ "$(get_target_system)" = "16" ]; then
+    printf "[main]\ndns=default\nrc-manager=resolvconf\n" > "$dns_conf_file"
+else
+    printf "[main]\ndns=systemd-resolved\n" > "$dns_conf_file"
+fi
+
 # If netplan is not configured to render by default to NetworkManager
 # configuration files we disable management of any ethernet device
 # as this will clash with any configuration netplan puts in place
diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
index da60892..7ca830a 100644
--- a/snap-common/bin/snap-config.sh
+++ b/snap-common/bin/snap-config.sh
@@ -149,6 +149,28 @@ _switch_debug_enable() {
     fi
 }
 
+# Enable/disable connectivity check
+# $1: uri
+# $2: interval
+# $3: response
+_switch_connectivity_check() {
+    path=$SNAP_DATA/conf.d/connectivity.conf
+    if [ -z "$1" ]; then
+        rm -f "$path"
+        return
+    fi
+
+    content=$(printf "[connectivity]\nuri=%s" "$1")
+    if [ -n "$2" ]; then
+        content=$(printf "%s\ninterval=%s" "$content" "$2")
+    fi
+    if [ -n "$3" ]; then
+        content=$(printf "%s\nresponse=%s" "$content" "$3")
+    fi
+
+    _replace_file_if_diff "$path" "$content"
+}
+
 . "$SNAP"/bin/snap-prop.sh
 
 apply_snap_config() {
@@ -156,4 +178,7 @@ apply_snap_config() {
     _switch_wifi_wake_on_wlan "$(get_wifi_wake_on_wlan)" "$(get_wifi_wake_on_password)"
     _switch_ethernet "$(get_ethernet_enable)"
     _switch_debug_enable "$(get_debug_enable)"
+    _switch_connectivity_check "$(get_property connectivity.uri)" \
+                               "$(get_property connectivity.interval)" \
+                               "$(get_property connectivity.response)"
 }
diff --git a/snap-common/bin/snap-prop.sh b/snap-common/bin/snap-prop.sh
index 3615660..3a0ec11 100644
--- a/snap-common/bin/snap-prop.sh
+++ b/snap-common/bin/snap-prop.sh
@@ -16,6 +16,12 @@
 
 # Getters for snap properties. They write the current value to stdout.
 
+# Generic one, that sets no defaults
+# $1: property name
+get_property() {
+    snapctl get "$1"
+}
+
 get_wifi_powersave() {
     value=$(snapctl get wifi.powersave) || true
     if [ -z "$value" ]; then
diff --git a/snap/hooks/utils.sh b/snap-common/bin/utils.sh
similarity index 100%
rename from snap/hooks/utils.sh
rename to snap-common/bin/utils.sh
old mode 100755
new mode 100644
diff --git a/snap-common/etc/NetworkManager/NetworkManager.conf b/snap-common/etc/NetworkManager/NetworkManager.conf
index e332099..c43397e 100644
--- a/snap-common/etc/NetworkManager/NetworkManager.conf
+++ b/snap-common/etc/NetworkManager/NetworkManager.conf
@@ -2,8 +2,6 @@
 plugins=ifupdown,keyfile
 # Not using dnsmasq yet. Need to get it properly integrated
 # into the snap or reuse the one shiped with the OS snap.
-dns=systemd-resolved
-
 
 # Use internal DHCP stack which is based on the systemd
 # implementation and is enough for our purpose until we
@@ -12,3 +10,6 @@ dhcp=internal
 
 [ifupdown]
 managed=false
+
+[device]
+wifi.scan-rand-mac-address=no
diff --git a/snap/hooks/configure b/snap/hooks/configure
index 4f0fe5b..34b41a6 100755
--- a/snap/hooks/configure
+++ b/snap/hooks/configure
@@ -28,6 +28,9 @@ _create_props_content() {
     printf "wifi_wake_on_password=%s\n" "$wifi_wake_on_password"
     printf "ethernet_enable=%s\n" "$ethernet_enable"
     printf "debug_enable=%s\n" "$debug_enable"
+    printf "connectivity_uri=%s\n" "$connectivity_uri"
+    printf "connectivity_interval=%s\n" "$connectivity_interval"
+    printf "connectivity_response=%s\n" "$connectivity_response"
 }
 
 wifi_powersave=$(get_wifi_powersave)
@@ -35,6 +38,9 @@ wifi_wake_on_wlan=$(get_wifi_wake_on_wlan)
 wifi_wake_on_password=$(get_wifi_wake_on_password)
 ethernet_enable=$(get_ethernet_enable)
 debug_enable=$(get_debug_enable)
+connectivity_uri=$(get_property "connectivity.uri")
+connectivity_interval=$(get_property "connectivity.interval")
+connectivity_response=$(get_property "connectivity.response")
 
 # Store always, so we show defaults when properties are set to empty strings
 snapctl set wifi.powersave="$wifi_powersave"
@@ -42,6 +48,9 @@ snapctl set wifi.wake-on-wlan="$wifi_wake_on_wlan"
 snapctl set wifi.wake-on-wlan-password="$wifi_wake_on_password"
 snapctl set ethernet.enable="$ethernet_enable"
 snapctl set debug.enable="$debug_enable"
+snapctl set connectivity.uri="$connectivity_uri"
+snapctl set connectivity.interval="$connectivity_interval"
+snapctl set connectivity.response="$connectivity_response"
 
 content=$(_create_props_content)
 
diff --git a/snap/hooks/install b/snap/hooks/install
deleted file mode 100755
index 8f4e7ca..0000000
--- a/snap/hooks/install
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh -e
-
-. "$SNAP"/meta/hooks/utils.sh
-
-target=$(get_target_system)
-
-if [ "$target" != "18" ] ; then
-    echo "This snap is only supported on Ubuntu Core 18."
-    exit 1
-fi
-
diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh
deleted file mode 100755
index 8f4e7ca..0000000
--- a/snap/hooks/post-refresh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh -e
-
-. "$SNAP"/meta/hooks/utils.sh
-
-target=$(get_target_system)
-
-if [ "$target" != "18" ] ; then
-    echo "This snap is only supported on Ubuntu Core 18."
-    exit 1
-fi
-
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index e43dea0..d9e1363 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -52,11 +52,6 @@ apps:
     slots: [service]
     plugs: [modem-manager, ppp, network-setup-observe, wpa, firewall-control, hardware-observe]
 parts:
-  hooks:
-    plugin: dump
-    source: hooks
-    organize:
-      configure: meta/hooks/configure
   networkmanager-common:
     plugin: dump
     source: snap-common
@@ -85,7 +80,6 @@ parts:
   networkmanager:
     plugin: autotools
     source: .
-    build-attributes: [no-system-libraries]
     build-packages:
       - intltool
       - libdbus-glib-1-dev
-- 
ubuntu-desktop mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop

Reply via email to