1 diff --git a/distrobuilder/lxc.generator b/distrobuilder/lxc.generator
2 index dc5b506..0265da8 100644
3 --- a/distrobuilder/lxc.generator
4 +++ b/distrobuilder/lxc.generator
5 @@ -21,16 +21,6 @@ is_incus_vm() {
6 [ -e /dev/virtio-ports/org.linuxcontainers.incus ]
9 -# is_in_path succeeds if the given file exists in on of the paths
11 - # Don't use $PATH as that may not include all relevant paths
12 - for path in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin; do
13 - [ -e "${path}/$1" ] && return 0
20 # fix_ro_paths avoids udevd issues with /sys and /proc being writable
22 @@ -42,38 +32,6 @@ fix_ro_paths() {
26 -# fix_nm_link_state forces the network interface to a DOWN state ahead of NetworkManager starting up
27 -fix_nm_link_state() {
28 - [ -e "/sys/class/net/$1" ] || return 0
30 - if [ -f /sbin/ip ]; then
32 - elif [ -f /bin/ip ]; then
37 - cat <<-EOF > /run/systemd/system/network-device-down.service
38 - # This file was created by distrobuilder
40 - Description=Turn off network device
41 - Before=NetworkManager.service
42 - Before=systemd-networkd.service
45 - # do not turn off if there is a default route to 169.254.0.1, i.e. the device is a routed nic
46 - ExecCondition=/bin/sh -c '! /usr/bin/grep -qs 00000000.0100FEA9 /proc/net/route'
47 - ExecStart=-${ip_path} link set $1 down
49 - RemainAfterExit=true
52 - WantedBy=default.target
54 - mkdir -p /run/systemd/system/default.target.wants
55 - ln -sf /run/systemd/system/network-device-down.service /run/systemd/system/default.target.wants/network-device-down.service
58 # fix_systemd_override_unit generates a unit specific override
59 fix_systemd_override_unit() {
60 dropin_dir="/run/systemd/${1}.d"
61 @@ -113,16 +71,7 @@ fix_systemd_mask() {
62 # fix_systemd_udev_trigger overrides the systemd-udev-trigger.service to match the latest version
63 # of the file which uses "ExecStart=-" instead of "ExecStart=".
64 fix_systemd_udev_trigger() {
66 - if [ -f /usr/bin/udevadm ]; then
67 - cmd=/usr/bin/udevadm
68 - elif [ -f /sbin/udevadm ]; then
70 - elif [ -f /bin/udevadm ]; then
77 mkdir -p /run/systemd/system/systemd-udev-trigger.service.d
78 cat <<-EOF > /run/systemd/system/systemd-udev-trigger.service.d/zzz-lxc-override.conf
79 @@ -134,38 +83,13 @@ fix_systemd_udev_trigger() {
83 -# fix_systemd_sysctl overrides the systemd-sysctl.service to use "ExecStart=-" instead of "ExecStart=".
84 -fix_systemd_sysctl() {
85 - cmd=/usr/lib/systemd/systemd-sysctl
86 - ! [ -e "${cmd}" ] && cmd=/lib/systemd/systemd-sysctl
87 - mkdir -p /run/systemd/system/systemd-sysctl.service.d
88 - cat <<-EOF > /run/systemd/system/systemd-sysctl.service.d/zzz-lxc-override.conf
89 - # This file was created by distrobuilder
97 -# Nothing to do in Incus VM but deployed in case it is later converted to a container
98 -is_incus_vm && exit 0
100 # Exit immediately if not an Incus/LXC container
101 is_lxc_container || exit 0
103 -# Check for NetworkManager
106 -is_in_path NetworkManager && nm_exists=1
108 # Determine systemd version
109 -for path in /usr/lib/systemd/systemd /lib/systemd/systemd; do
110 - [ -x "${path}" ] || continue
112 - systemd_version="$("${path}" --version | head -n1 | cut -d' ' -f2 | cut -d'~' -f1)"
115 +systemd_version="$(systemd --version | head -n1 | cut -d' ' -f2)"
117 # Determine distro name and release
119 @@ -196,7 +120,6 @@ fi
121 # Ignore failures on some units.
122 fix_systemd_udev_trigger
126 fix_systemd_mask dev-hugepages.mount
127 @@ -226,11 +149,6 @@ if [ -d /etc/udev ]; then
131 -# Workarounds for NetworkManager in containers
132 -if [ "${nm_exists}" -eq 1 ]; then
133 - fix_nm_link_state eth0
136 # Allow masking units created by the lxc system-generator.
137 for d in /etc/systemd/system /usr/lib/systemd/system /lib/systemd/system; do
138 if ! [ -d "${d}" ]; then