systemd/debian/systemd.postinst

125 lines
3.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /bin/sh
set -e
_systemctl() {
if [ -d /run/systemd/system ]; then
systemctl "$@"
fi
}
_update_catalog() {
journalctl --update-catalog || true
}
# Update Message Catalogs database in response to dpkg trigger
if [ "$1" = "triggered" ]; then
_update_catalog
exit 0
fi
# Cleanup state files from the auto-enabler which we used in wheezy
if dpkg --compare-versions "$2" lt "204-1"; then
rm -f /var/lib/systemd/enabled-units
rm -f /var/lib/systemd/run-debian-enable-units
rm -f /var/lib/systemd/*.symlinks
fi
if [ -n "$2" ]; then
_systemctl daemon-reexec || true
_systemctl try-restart systemd-journald.service || true
_systemctl try-restart systemd-logind.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.
systemctl enable tmp.mount || true
fi
fi
# Create /run/initctl → /dev/initctl compat symlink on upgrades
if [ -d /run/systemd/system ]; then
_systemctl restart systemd-initctl.socket || true
fi
if dpkg --compare-versions "$2" lt "40-1"; then
# /lib/init/rw has been replaced by /run, so try to remove it on upgrades
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=643699
_systemctl stop lib-init-rw.automount lib-init-rw.mount || true
if [ -d /lib/init/rw ]; then
rmdir --ignore-fail-on-non-empty /lib/init/rw || true
fi
# Create /run/initctl → /dev/initctl compat symlink on upgrades
if [ -d /run/systemd/system ]; then
ln -sf /dev/initctl /run/initctl
fi
fi
systemd-machine-id-setup
if ! getent group systemd-journal >/dev/null; then
addgroup --system systemd-journal
fi
# initial update of the Message Catalogs database
_update_catalog
# We dont ship /var/log/journal currently, so only run the following fix for
# systems where the administrator has explicitly enabled persistent logging by
# creating /var/log/journal.
if [ -d /var/log/journal ]; then
# Grant read access to /var/log/journal for members of the adm group
# via a filesystem ACL. This makes them able to read the journal.
# Failure is ignored since there might be file systems mounted without
# ACL support.
setfacl -R -nm g:adm:rx,d:g:adm:rx /var/log/journal || true
fi
setcap cap_dac_override,cap_sys_ptrace=ep /usr/bin/systemd-detect-virt || true
#DEBHELPER#