HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux host 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: w230 (1248)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //snap/network-manager/current/bin/networkmanager
#!/bin/sh
# 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/>.
set -ex

# Create all necessary directories we need at runtime
mkdir -p "$SNAP_DATA"/conf/system-connections
mkdir -p "$SNAP_DATA"/run

# Create DHCP lease directory
mkdir -p /run/NetworkManager/dhcp

# A directory where users can place any additional configuration
# files for NetworkManager
mkdir -p "$SNAP_DATA"/conf.d

# State dir where network-manager stores several things like the
# secret key used for IPv6
mkdir -p "$SNAP_DATA"/state
mkdir -p "$SNAP_DATA"/state/dhcp

# Folders needed by dnsmasq
mkdir -p "$SNAP_DATA"/var/lib/misc
mkdir -p "$SNAP_DATA"/etc
mkdir -p "$SNAP_DATA"/var/run

# Apply current snapctl settings
. "$SNAP"/bin/snap-config.sh
apply_snap_config

# Select which config we're going to use. We offer our users
# to provide their own configuration file in $SNAP_DATA but
# will fallback if no one exists to the default one we ship
# in $SNAP
NM_CONF=$SNAP/etc/NetworkManager/NetworkManager.conf
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_series_major_version)" = "16" ]; then
    printf "[main]\ndns=default\nrc-manager=resolvconf\n" > "$dns_conf_file"
else
    printf "[main]\ndns=systemd-resolved\nrc-manager=symlink\n" > \
           "$dns_conf_file"
fi

# Identify if we are in debug mode or not
LOG_LEVEL=INFO
if [ -f "$SNAP_DATA"/.debug_enabled ]; then
    LOG_LEVEL=DEBUG
fi

# Run available startup hooks to have a point to store custom
# logic outside of this script. More of the things from above
# should be moved into these.
for hook in "$SNAP"/startup-hooks/* ; do
    [ -x "$hook" ] && /bin/sh -x "$hook"
done

# Unset user/group for openvpn so the plugin does not try to set them
export NM_OPENVPN_USER="" NM_OPENVPN_GROUP=""

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$SNAP"/usr/lib/NetworkManager

exec "$SNAP"/usr/sbin/NetworkManager \
    --config-dir="$SNAP_DATA"/conf.d/ \
    --config="$NM_CONF" \
    --log-level="$LOG_LEVEL" \
    --no-daemon