Skip to content

Commit

Permalink
Merge pull request #3991 from HiassofT/le92-nfs-backports
Browse files Browse the repository at this point in the history
[le92] NFS / netboot backports
  • Loading branch information
chewitt committed Dec 9, 2019
2 parents da2c9c3 + 29d9d08 commit d97ed1c
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 17 deletions.
@@ -1,11 +1,11 @@
[Unit]
Description=Wait on network
Requisite=connman.service
After=connman.service
Before=network-online.target
DefaultDependencies=no
Conflicts=shutdown.target
ConditionPathExists=/storage/.cache/libreelec/network_wait
ConditionPathExists=!/dev/.kernel_ipconfig

[Service]
Type=oneshot
Expand Down
9 changes: 0 additions & 9 deletions packages/network/connman/package.mk
Expand Up @@ -59,12 +59,6 @@ post_makeinstall_target() {
mkdir -p $INSTALL/usr/lib/connman
cp -P $PKG_DIR/scripts/connman-setup $INSTALL/usr/lib/connman

mkdir -p $INSTALL/etc
ln -sf /run/connman/resolv.conf $INSTALL/etc/resolv.conf

# /etc/hosts must be writeable
ln -sf /run/connman/hosts $INSTALL/etc/hosts

mkdir -p $INSTALL/etc/connman
cp ../src/main.conf $INSTALL/etc/connman
sed -i $INSTALL/etc/connman/main.conf \
Expand All @@ -78,9 +72,6 @@ post_makeinstall_target() {
-e "s|^# PersistentTetheringMode.*|PersistentTetheringMode = true|g" \
-e "s|^# NetworkInterfaceBlacklist = vmnet,vboxnet,virbr,ifb|NetworkInterfaceBlacklist = vmnet,vboxnet,virbr,ifb,docker,veth,zt|g"

mkdir -p $INSTALL/usr/config
cp $PKG_DIR/config/hosts.conf $INSTALL/usr/config

mkdir -p $INSTALL/usr/share/connman/
cp $PKG_DIR/config/settings $INSTALL/usr/share/connman/
}
Expand Down
8 changes: 8 additions & 0 deletions packages/network/connman/scripts/connman-setup
Expand Up @@ -15,3 +15,11 @@
else
export CONNMAN_MAIN="--config=/etc/connman/main.conf"
fi

# switch resolv.conf management to connman and use current contents
# as a fallback
if [ -f /run/libreelec/resolv.conf ]; then
cat /run/libreelec/resolv.conf > /run/connman/resolv.conf
fi
rm -f /run/libreelec/resolv.conf
ln -s /run/connman/resolv.conf /run/libreelec/resolv.conf
7 changes: 2 additions & 5 deletions packages/network/connman/system.d/connman.service
Expand Up @@ -3,18 +3,15 @@ Description=Connection service
DefaultDependencies=false
Conflicts=shutdown.target
Before=network.target multi-user.target shutdown.target
After=dbus.service
After=dbus.service network-base.service
Wants=network.target
ConditionPathExists=!/dev/.kernel_ipconfig

[Service]
Type=dbus
BusName=net.connman
Restart=on-failure
EnvironmentFile=-/run/libreelec/debug/connman.conf
ExecStartPre=-/bin/sh -c "echo -e 'nameserver 8.8.8.8\nnameserver 8.8.4.4' > /etc/resolv.conf"
ExecStartPre=-/bin/sh -c "cat /storage/.cache/hostname > /proc/sys/kernel/hostname"
ExecStartPre=-/bin/sh -c "cat /storage/.config/hosts.conf > /etc/hosts"
ExecStartPre=/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
ExecStart=/bin/sh -c ". /usr/lib/connman/connman-setup; exec /usr/sbin/connmand -nr $CONNMAN_MAIN $CONNMAN_DEBUG"
StandardOutput=null
RestartSec=2
Expand Down
2 changes: 1 addition & 1 deletion packages/network/connman/system.d/network-online.service
@@ -1,10 +1,10 @@
[Unit]
Description=Wait for network to be configured by ConnMan
Requisite=connman.service
After=connman.service
Before=network-online.target
DefaultDependencies=no
Conflicts=shutdown.target
ConditionPathExists=!/dev/.kernel_ipconfig

[Service]
Type=oneshot
Expand Down
9 changes: 8 additions & 1 deletion packages/sysutils/busybox/scripts/init
Expand Up @@ -203,7 +203,7 @@ mount_nfs() {

[ "$NFS_OPTIONS" = "$1" ] && NFS_OPTIONS=

mount_common "$NFS_EXPORT" "$2" "$3,nolock,soft,timeo=3,retrans=2,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs"
mount_common "$NFS_EXPORT" "$2" "$3,nolock,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs"
}

mount_ubifs() {
Expand Down Expand Up @@ -1082,6 +1082,9 @@ for arg in $(cat /proc/cmdline); do
bigfont=*)
BIGFONT="${arg#*=}"
;;
ip=*)
KERNEL_IPCONFIG="yes"
;;
esac
done

Expand Down Expand Up @@ -1150,6 +1153,10 @@ if [ "$FLASH_NETBOOT" = "yes" ]; then
echo "" > /sysroot/dev/.flash_netboot
fi

if [ "$KERNEL_IPCONFIG" = "yes" ]; then
echo "" > /sysroot/dev/.kernel_ipconfig
fi

# swap can not be used over nfs.(see scripts/mount-swap)
if [ "$STORAGE_NETBOOT" = "yes" ]; then
echo "" > /sysroot/dev/.storage_netboot
Expand Down
File renamed without changes.
86 changes: 86 additions & 0 deletions packages/sysutils/systemd/config/timesyncd.conf.d/README
@@ -0,0 +1,86 @@
TIMESYNCD.CONF(5) timesyncd.conf TIMESYNCD.CONF(5)

NAME
timesyncd.conf, timesyncd.conf.d - Network Time Synchronization
configuration files

SYNOPSIS
/etc/systemd/timesyncd.conf

/etc/systemd/timesyncd.conf.d/*.conf

/run/systemd/timesyncd.conf.d/*.conf

/usr/lib/systemd/timesyncd.conf.d/*.conf

DESCRIPTION
These configuration files control NTP network time synchronization. See
systemd.syntax(5) for a general description of the syntax.

CONFIGURATION DIRECTORIES AND PRECEDENCE
The default configuration is defined during compilation, so a
configuration file is only needed when it is necessary to deviate from
those defaults. By default, the configuration file in /etc/systemd/
contains commented out entries showing the defaults as a guide to the
administrator. This file can be edited to create local overrides.

When packages need to customize the configuration, they can install
configuration snippets in /usr/lib/systemd/*.conf.d/. Files in /etc/
are reserved for the local administrator, who may use this logic to
override the configuration files installed by vendor packages. The main
configuration file is read before any of the configuration directories,
and has the lowest precedence; entries in a file in any configuration
directory override entries in the single configuration file. Files in
the *.conf.d/ configuration subdirectories are sorted by their filename
in lexicographic order, regardless of which of the subdirectories they
reside in. When multiple files specify the same option, for options
which accept just a single value, the entry in the file with the
lexicographically latest name takes precedence. For options which
accept a list of values, entries are collected as they occur in files
sorted lexicographically. It is recommended to prefix all filenames in
those subdirectories with a two-digit number and a dash, to simplify
the ordering of the files.

To disable a configuration file supplied by the vendor, the recommended
way is to place a symlink to /dev/null in the configuration directory
in /etc/, with the same filename as the vendor configuration file.

OPTIONS
The following settings are configured in the "[Time]" section:

NTP=
A space-separated list of NTP server host names or IP addresses.
During runtime this list is combined with any per-interface NTP
servers acquired from systemd-networkd.service(8).
systemd-timesyncd will contact all configured system or
per-interface servers in turn until one is found that responds.
When the empty string is assigned, the list of NTP servers is
reset, and all assignments prior to this one will have no effect.
This setting defaults to an empty list.

FallbackNTP=
A space-separated list of NTP server host names or IP addresses to
be used as the fallback NTP servers. Any per-interface NTP servers
obtained from systemd-networkd.service(8) take precedence over this
setting, as do any servers set via NTP= above. This setting is
hence only used if no other NTP server information is known. When
the empty string is assigned, the list of NTP servers is reset, and
all assignments prior to this one will have no effect. If this
option is not given, a compiled-in list of NTP servers is used
instead.

RootDistanceMaxSec=
Maximum acceptable root distance. Takes a time value (in seconds).
Defaults to 5 seconds.

PollIntervalMinSec=, PollIntervalMaxSec=
The minimum and maximum poll intervals for NTP messages. Each
setting takes a time value (in seconds). PollIntervalMinSec= must
not be smaller than 16 seconds. PollIntervalMaxSec= must be larger
than PollIntervalMinSec=. PollIntervalMinSec= defaults to 32
seconds, and PollIntervalMaxSec= defaults to 2048 seconds.

SEE ALSO
systemd(1), systemd-timesyncd.service(8), systemd-networkd.service(8)

systemd 241 TIMESYNCD.CONF(5)
10 changes: 10 additions & 0 deletions packages/sysutils/systemd/package.mk
Expand Up @@ -208,6 +208,12 @@ post_makeinstall_target() {

mkdir -p $INSTALL/usr/sbin
cp $PKG_DIR/scripts/kernel-overlays-setup $INSTALL/usr/sbin
cp $PKG_DIR/scripts/network-base-setup $INSTALL/usr/sbin
cp $PKG_DIR/scripts/systemd-timesyncd-setup $INSTALL/usr/sbin

# /etc/resolv.conf and /etc/hosts must be writable
ln -sf /run/libreelec/resolv.conf $INSTALL/etc/resolv.conf
ln -sf /run/libreelec/hosts $INSTALL/etc/hosts

# provide 'halt', 'shutdown', 'reboot' & co.
ln -sf /usr/bin/systemctl $INSTALL/usr/sbin/halt
Expand All @@ -230,6 +236,7 @@ post_makeinstall_target() {
ln -sf /storage/.config/logind.conf.d $INSTALL/etc/systemd/logind.conf.d
safe_remove $INSTALL/etc/systemd/sleep.conf.d
ln -sf /storage/.config/sleep.conf.d $INSTALL/etc/systemd/sleep.conf.d
ln -sf /storage/.config/timesyncd.conf.d $INSTALL/etc/systemd/timesyncd.conf.d
safe_remove $INSTALL/etc/sysctl.d
ln -sf /storage/.config/sysctl.d $INSTALL/etc/sysctl.d
safe_remove $INSTALL/etc/tmpfiles.d
Expand Down Expand Up @@ -268,4 +275,7 @@ post_install() {
enable_service usercache.service
enable_service kernel-overlays.service
enable_service hwdb.service
enable_service network-base.service
enable_service systemd-timesyncd.service
enable_service systemd-timesyncd-setup.service
}
@@ -0,0 +1,84 @@
From 9074b57fd5a5c8ae20b15b59ed9abe9a7f0147b0 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 15 Nov 2019 14:00:54 +0100
Subject: [PATCH] mount: do not update exec deps on mountinfo changes

Fixes: #13978
---
src/core/mount.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/core/mount.c b/src/core/mount.c
index 1d1d2683da4..dfed691c43f 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -550,6 +550,32 @@ static int mount_verify(Mount *m) {
return 0;
}

+static int mount_add_non_exec_dependencies(Mount *m) {
+ int r;
+ assert(m);
+
+ /* Adds in all dependencies directly responsible for ordering the mount, as opposed to dependencies
+ * resulting from the ExecContext and such. */
+
+ r = mount_add_device_dependencies(m);
+ if (r < 0)
+ return r;
+
+ r = mount_add_mount_dependencies(m);
+ if (r < 0)
+ return r;
+
+ r = mount_add_quota_dependencies(m);
+ if (r < 0)
+ return r;
+
+ r = mount_add_default_dependencies(m);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
static int mount_add_extras(Mount *m) {
Unit *u = UNIT(m);
int r;
@@ -577,18 +603,6 @@ static int mount_add_extras(Mount *m) {
return r;
}

- r = mount_add_device_dependencies(m);
- if (r < 0)
- return r;
-
- r = mount_add_mount_dependencies(m);
- if (r < 0)
- return r;
-
- r = mount_add_quota_dependencies(m);
- if (r < 0)
- return r;
-
r = unit_patch_contexts(u);
if (r < 0)
return r;
@@ -601,7 +615,7 @@ static int mount_add_extras(Mount *m) {
if (r < 0)
return r;

- r = mount_add_default_dependencies(m);
+ r = mount_add_non_exec_dependencies(m);
if (r < 0)
return r;

@@ -1574,7 +1588,7 @@ static int mount_setup_existing_unit(

unit_remove_dependencies(u, UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT);

- r = mount_add_extras(MOUNT(u));
+ r = mount_add_non_exec_dependencies(MOUNT(u));
if (r < 0)
return r;
}
26 changes: 26 additions & 0 deletions packages/sysutils/systemd/scripts/network-base-setup
@@ -0,0 +1,26 @@
#!/bin/sh

# setup hostname
if [ -f /storage/.cache/hostname ]; then
cat /storage/.cache/hostname > /proc/sys/kernel/hostname
fi

# setup /etc/hosts
rm -f /run/libreelec/hosts
if [ -f /storage/.config/hosts.conf ]; then
cat /storage/.config/hosts.conf > /run/libreelec/hosts
fi

# setup /etc/resolv.conf
rm -f /run/libreelec/resolv.conf
if [ -f /storage/.config/resolv.conf ]; then
cat /storage/.config/resolv.conf > /run/libreelec/resolv.conf
elif [ -f /dev/.kernel_ipconfig -a -f /proc/net/pnp ]; then
cat /proc/net/pnp > /run/libreelec/resolv.conf
else
cat << EOF > /run/libreelec/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
fi

22 changes: 22 additions & 0 deletions packages/sysutils/systemd/scripts/systemd-timesyncd-setup
@@ -0,0 +1,22 @@
#!/bin/sh
KERNEL_NTP="${1:-/proc/net/ipconfig/ntp_servers}"
NTP_SERVERS=""
if [ -f /proc/net/ipconfig/ntp_servers ]; then
for srv in $(cat /proc/net/ipconfig/ntp_servers); do
if [ -n "$srv" -a "$srv" != "0.0.0.0" ]; then
if [ -z "$NTP_SERVERS" ]; then
NTP_SERVERS="$srv"
else
NTP_SERVERS="${NTP_SERVERS} $srv"
fi
fi
done
if [ -n "$NTP_SERVERS" ]; then
mkdir -p /run/systemd/timesyncd.conf.d/
cat << EOF > /run/systemd/timesyncd.conf.d/kernel-ntp-servers.conf
[Time]
NTP=$NTP_SERVERS
EOF
fi
fi

12 changes: 12 additions & 0 deletions packages/sysutils/systemd/system.d/network-base.service
@@ -0,0 +1,12 @@
[Unit]
Description=Base Network Configuration
DefaultDependencies=no
After=local-fs.target systemd-tmpfiles-setup.service userconfig.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/network-base-setup
RemainAfterExit=yes

[Install]
WantedBy=network.target
@@ -0,0 +1,2 @@
[Unit]
DefaultDependencies=no
12 changes: 12 additions & 0 deletions packages/sysutils/systemd/system.d/systemd-timesyncd-setup.service
@@ -0,0 +1,12 @@
[Unit]
Description=Setup NTP servers for timesyncd
DefaultDependencies=no
After=systemd-remount-fs.service systemd-sysusers.service

[Service]
Type=oneshot
ExecStart=/usr/sbin/systemd-timesyncd-setup
RemainAfterExit=yes

[Install]
WantedBy=sysinit.target
@@ -0,0 +1,3 @@
[Unit]
ConditionPathExists=/dev/.kernel_ipconfig
After=systemd-timesyncd-setup.service network-base.service

0 comments on commit d97ed1c

Please sign in to comment.