mirror of
https://git.proxmox.com/git/systemd
synced 2025-12-29 17:16:51 +00:00
Drop networkd-if-up.d@.service and its invocation from net.agent again. It does not work when restarting networkd and requires too much overhead. Instead, add a suid root helper systemd-networkd-dispatcher which calls run-parts, and patch networkd to run the wrapper at the appropriate time. Add reference to LP: #1492129.
154 lines
5.2 KiB
Bash
154 lines
5.2 KiB
Bash
#! /bin/sh
|
|
|
|
set -e
|
|
|
|
_systemctl() {
|
|
if [ -d /run/systemd/system ]; then
|
|
systemctl "$@"
|
|
fi
|
|
}
|
|
|
|
_update_catalog() {
|
|
journalctl --update-catalog || true
|
|
}
|
|
|
|
# Update Message Catalogs database and reload in response to dpkg triggers
|
|
if [ "$1" = "triggered" ]; then
|
|
shift
|
|
for trigger in "$@"; do
|
|
case $trigger in
|
|
/usr/lib/systemd/catalog)
|
|
_update_catalog
|
|
;;
|
|
/etc/init.d)
|
|
_systemctl daemon-reload
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
fi
|
|
|
|
# Enable getty and remote-fs.target by default on new installs, and on
|
|
# upgrades from old systemd versions (where the symlinks included as deb
|
|
# content, and will thus have been removed by dpkg during the upgrade).
|
|
if dpkg --compare-versions "$2" lt "214-1"; then
|
|
systemctl enable getty@tty1.service || true
|
|
systemctl enable remote-fs.target || true
|
|
fi
|
|
|
|
# Enable timesyncd by default on new installs installs and upgrades
|
|
if dpkg --compare-versions "$2" lt "218-11~"; then
|
|
systemctl enable systemd-timesyncd.service || true
|
|
fi
|
|
|
|
# Do a one-time migration of the local time setting
|
|
if dpkg --compare-versions "$2" lt "33-1"; then
|
|
if [ -f /etc/default/rcS ]; then
|
|
. /etc/default/rcS
|
|
fi
|
|
if [ "$UTC" = "no" ] && [ ! -e /etc/adjtime ]; then
|
|
printf "0.0 0 0.0\n0\nLOCAL" > /etc/adjtime
|
|
fi
|
|
fi
|
|
|
|
# Do a one-time migration of the TMPTIME setting
|
|
if dpkg --compare-versions "$2" lt "204-9"; then
|
|
# Fix up potentially broken tmp.conf, see Debian#738862
|
|
if [ -e /etc/tmpfiles.d/tmp.conf ]; then
|
|
sed -i '/^# Clear \/var\/tmp/d' /etc/tmpfiles.d/tmp.conf
|
|
sed -i 's,^\(d /var/tmp\),#\1,g' /etc/tmpfiles.d/tmp.conf
|
|
fi
|
|
|
|
if [ -f /etc/default/rcS ]; then
|
|
. /etc/default/rcS
|
|
fi
|
|
if [ ! -e /etc/tmpfiles.d/tmp.conf ]; then
|
|
case "$TMPTIME" in
|
|
-*|infinite|infinity)
|
|
cat > /etc/tmpfiles.d/tmp.conf <<EOF
|
|
# Avoid clearing /tmp by shipping an empty /etc/tmpfiles.d/tmp.conf file
|
|
# which overrides /usr/lib/tmpfiles.d/tmp.conf.
|
|
# This file was automatically created because of local modifications in
|
|
# /etc/default/rcS where TMPTIME was set to infinite.
|
|
EOF
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
|
|
# Do a one-time migration of the RAMTMP setting
|
|
if dpkg --compare-versions "$2" lt "204-8"; then
|
|
if [ -f /etc/default/rcS ]; then
|
|
. /etc/default/rcS
|
|
fi
|
|
if [ -f /etc/default/tmpfs ]; then
|
|
. /etc/default/tmpfs
|
|
fi
|
|
if [ "$RAMTMP" = "yes" ]; then
|
|
# systemctl enable will work even when systemd is not the active PID 1.
|
|
if [ ! -e /etc/systemd/system/tmp.mount ]; then
|
|
cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
|
|
fi
|
|
systemctl enable tmp.mount || true
|
|
fi
|
|
fi
|
|
|
|
# Create /etc/machine-id
|
|
systemd-machine-id-setup
|
|
|
|
# Setup system users and groups
|
|
addgroup --system systemd-journal
|
|
|
|
adduser --quiet --system --group --no-create-home --home /run/systemd \
|
|
--gecos "systemd Time Synchronization" systemd-timesync
|
|
adduser --quiet --system --group --no-create-home --home /run/systemd/netif \
|
|
--gecos "systemd Network Management" systemd-network
|
|
adduser --quiet --system --group --no-create-home --home /run/systemd/resolve \
|
|
--gecos "systemd Resolver" systemd-resolve
|
|
adduser --quiet --system --group --no-create-home --home /run/systemd \
|
|
--gecos "systemd Bus Proxy" systemd-bus-proxy
|
|
|
|
# Initial update of the Message Catalogs database
|
|
_update_catalog
|
|
|
|
# Make systemd-detect-virt utility usable for non-root users
|
|
setcap cap_dac_override,cap_sys_ptrace=ep /usr/bin/systemd-detect-virt || true
|
|
|
|
# systemd-networkd-dispatcher is a suid root helper for networkd
|
|
chown root:systemd-network /lib/systemd/systemd-networkd-dispatcher
|
|
chmod 4754 /lib/systemd/systemd-networkd-dispatcher
|
|
|
|
# Re-run systemctl enable for any service that was enabled when preinst was run.
|
|
if dpkg --compare-versions "$2" ge "204" && [ -e /run/systemd/was-enabled ]; then
|
|
while read UNIT ; do
|
|
# 220-6 stopped shipping tmp.mount, transition it on machines which had
|
|
# it enabled
|
|
if [ "$UNIT" = tmp.mount ] && dpkg --compare-versions "$2" lt-nl "220-6~"; then
|
|
if [ ! -e /etc/systemd/system/tmp.mount ]; then
|
|
echo "moving enabled tmp.mount to /etc/systemd/system/..."
|
|
cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
|
|
# clean up the symlink, to have it re-created below
|
|
systemctl disable $UNIT
|
|
fi
|
|
fi
|
|
systemctl enable $UNIT || true
|
|
done </run/systemd/was-enabled || true
|
|
fi
|
|
|
|
if [ -n "$2" ]; then
|
|
_systemctl daemon-reexec || true
|
|
_systemctl try-restart systemd-logind.service || true
|
|
_systemctl try-restart systemd-networkd.service || true
|
|
_systemctl try-restart systemd-resolved.service || true
|
|
_systemctl try-restart systemd-timesyncd.service || true
|
|
fi
|
|
|
|
# Cleanup hwclock-save.service, which was shipped in jessie.
|
|
if dpkg --compare-versions "$2" lt-nl "219-8"; then
|
|
for t in reboot halt poweroff ; do
|
|
rm -f /etc/systemd/system/${t}.target.wants/hwclock-save.service
|
|
rmdir --ignore-fail-on-non-empty /etc/systemd/system/${t}.target.wants 2> /dev/null || true
|
|
done
|
|
fi
|
|
#DEBHELPER#
|