Package systemd: Scripts

Post install

systemd-machine-id-setup >/dev/null 2>&1 || :

systemctl daemon-reexec &>/dev/null || {
  # systemd v239 had bug #9553 in D-Bus authentication of the private socket,
  # which was later fixed in v240 by #9625.
  #
  # The end result is that a `systemctl daemon-reexec` call as root will fail
  # when upgrading from systemd v239, which means the system will not start
  # running the new version of systemd after this post install script runs.
  #
  # To work around this issue, let's fall back to using a `kill -TERM 1` to
  # re-execute the daemon when the `systemctl daemon-reexec` call fails.
  #
  # In order to prevent issues when the reason why the daemon-reexec failed is
  # not the aforementioned bug, let's only use this fallback when:
  #   - we're upgrading this RPM package; and
  #   - we confirm that systemd is running as PID1 on this system.
  if [ $1 -gt 1 ] && [ -d /run/systemd/system ] ; then
    kill -TERM 1 &>/dev/null || :
  fi
}

# Move old stuff around in /var/lib
[ -d /var/lib/systemd/random-seed ] && rm -rf /var/lib/systemd/random-seed >/dev/null 2>&1 || :
[ -e /var/lib/random-seed ] && mv /var/lib/random-seed /var/lib/systemd/random-seed >/dev/null 2>&1 || :
[ -e /var/lib/backlight ] && mv /var/lib/backlight /var/lib/systemd/backlight >/dev/null 2>&1 || :

/lib/systemd/systemd-random-seed save >/dev/null 2>&1 || :

# rm symlinks for network.service
[ -L /etc/systemd/system/network.target.wants/network.service ] && rm -f /etc/systemd/system/network.target.wants/network.service  >/dev/null 2>&1 || :
[ -L /etc/systemd/system/multi-user.target.wants/network.service ] && rm -f /etc/systemd/system/multi-user.target.wants/network.service  >/dev/null 2>&1 || :

# rm symlinks for prefdm.service
[ -L /etc/systemd/system/graphical.target.wants/prefdm.service ] && rm -f /etc/systemd/system/graphical.target.wants/prefdm.service  >/dev/null 2>&1 || :

if [ $1 -eq 1 ] ; then
     # create /var/log/journal only on initial installation
     mkdir -p /var/log/journal
fi

# Make sure new journal files will be owned by the "systemd-journal" group
chgrp systemd-journal /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2> /dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2> /dev/null` >/dev/null 2>&1 || :
chmod g+s  /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2> /dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2> /dev/null` >/dev/null 2>&1 || :

# Apply ACL to the journal directory
setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/ >/dev/null 2>&1 || :

# remove obsolete systemd-readahead file and services symlink
rm -f /.readahead > /dev/null 2>&1 || :
[ -L /etc/systemd/system/default.target.wants/systemd-readahead-collect.service ] && rm -f /etc/systemd/system/default.target.wants/systemd-readahead-collect.service
[ -L /etc/systemd/system/default.target.wants/systemd-readahead-replay.service ] && rm -f /etc/systemd/system/default.target.wants/systemd-readahead-replay.service
[ -L /etc/systemd/system/system-update.target.wants/systemd-readahead-drop.service ] && rm -f /etc/systemd/system/system-update.target.wants/systemd-readahead-drop.service


if [ $1 -eq 1 ] ; then
        # Enable the services we install by default
        systemctl preset-all >/dev/null 2>&1 || :
        systemctl --global preset-all >/dev/null 2>&1 || :
fi


# Migrate /etc/sysconfig/clock
SYSCONFIG_CLOCK=/etc/sysconfig/clock
if [ ! -L /etc/localtime -a -e "$SYSCONFIG_CLOCK" ] ; then
       . "$SYSCONFIG_CLOCK" >/dev/null 2>&1 || :
       if [ -n "$ZONE" -a -e "/usr/share/zoneinfo/$ZONE" ] ; then
              ln -sf "../usr/share/zoneinfo/$ZONE" /etc/localtime >/dev/null 2>&1 || :
       fi
fi
#rm -f "$SYSCONFIG_CLOCK" >/dev/null 2>&1 || :

# Migrate /etc/sysconfig/i18n
SYSCONFIG_I18N=/etc/sysconfig/i18n
if [ -e "$SYSCONFIG_I18N" -a ! -e /etc/locale.conf ]; then
        unset LANG
        unset LC_CTYPE
        unset LC_NUMERIC
        unset LC_TIME
        unset LC_COLLATE
        unset LC_MONETARY
        unset LC_MESSAGES
        unset LC_PAPER
        unset LC_NAME
        unset LC_ADDRESS
        unset LC_TELEPHONE
        unset LC_MEASUREMENT
        unset LC_IDENTIFICATION
        . "$SYSCONFIG_I18N" >/dev/null 2>&1 || :
        [ -n "$LANG" ] && echo LANG=$LANG > /etc/locale.conf 2>&1 || :
        [ -n "$LC_CTYPE" ] && echo LC_CTYPE=$LC_CTYPE >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_NUMERIC" ] && echo LC_NUMERIC=$LC_NUMERIC >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_TIME" ] && echo LC_TIME=$LC_TIME >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_COLLATE" ] && echo LC_COLLATE=$LC_COLLATE >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_MONETARY" ] && echo LC_MONETARY=$LC_MONETARY >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_MESSAGES" ] && echo LC_MESSAGES=$LC_MESSAGES >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_PAPER" ] && echo LC_PAPER=$LC_PAPER >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_NAME" ] && echo LC_NAME=$LC_NAME >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_ADDRESS" ] && echo LC_ADDRESS=$LC_ADDRESS >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_TELEPHONE" ] && echo LC_TELEPHONE=$LC_TELEPHONE >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_MEASUREMENT" ] && echo LC_MEASUREMENT=$LC_MEASUREMENT >> /etc/locale.conf 2>&1 || :
        [ -n "$LC_IDENTIFICATION" ] && echo LC_IDENTIFICATION=$LC_IDENTIFICATION >> /etc/locale.conf 2>&1 || :
fi
#rm -f "$SYSCONFIG_I18N" >/dev/null 2>&1 || :

# Migrate /etc/sysconfig/keyboard and /etc/sysconfig/consolefont
SYSCONFIG_KEYBOARD=/etc/sysconfig/keyboard
SYSCONFIG_CONSOLEFONT=/etc/sysconfig/consolefont
if [ -e "$SYSCONFIG_KEYBOARD" -a -e "$SYSCONFIG_CONSOLEFONT" -a ! -e /etc/vconsole.conf ]; then
        unset SYSFONT
        unset SYSFONTACM
        unset UNIMAP
        unset KEYTABLE
        [ -e "$SYSCONFIG_KEYBOARD" ] && . "$SYSCONFIG_KEYBOARD" >/dev/null 2>&1 || :
        [ -e "$SYSCONFIG_CONSOLEFONT" ] && . "$SYSCONFIG_CONSOLEFONT" >/dev/null 2>&1 || :
        [ -n "$SYSFONT" ] && echo FONT=$SYSFONT > /etc/vconsole.conf 2>&1 || :
        [ -n "$SYSFONTACM" ] && echo FONT_MAP=$SYSFONTACM >> /etc/vconsole.conf 2>&1 || :
        [ -n "$UNIMAP" ] && echo FONT_UNIMAP=$UNIMAP >> /etc/vconsole.conf 2>&1 || :
        [ -n "$KEYTABLE" ] && echo KEYMAP=$KEYTABLE >> /etc/vconsole.conf 2>&1 || :
fi
#rm -f "$SYSCONFIG_KEYBOARD" >/dev/null 2>&1 || :
#rm -f "$SYSCONFIG_CONSOLEFONT" >/dev/null 2>&1 || :

# Migrate HOSTNAME= from /etc/sysconfig/network
SYSCONFIG_NETWORK=/etc/sysconfig/network
if [ -e "$SYSCONFIG_NETWORK" -a ! -e /etc/hostname ]; then
        unset HOSTNAME
        . "$SYSCONFIG_NETWORK" >/dev/null 2>&1 || :
        [ -n "$HOSTNAME" ] && echo $HOSTNAME > /etc/hostname 2>&1 || :
fi
#sed -i '/^HOSTNAME=/d' "$SYSCONFIG_NETWORK" >/dev/null 2>&1 || :



 
if sd_booted; then 
    systemctl daemon-reload 
    if [ $1 -eq 1 ]; then 
        # Initial installation 
        systemctl --no-reload preset systemd-timedated.service systemd-hostnamed.service systemd-journald.service systemd-localed.service systemd-userdbd.service systemd-oomd.service || : 
    else 
        # Package upgrade, not uninstall 
        /lib/systemd/systemd-update-helper mark-restart-system-units systemd-timedated.service systemd-hostnamed.service systemd-journald.service systemd-localed.service systemd-userdbd.service systemd-oomd.service || : 
    fi 
fi
Pre install

1
2
3
4
groupadd -r -f systemd-journal >/dev/null 2>&1 ||:
groupadd -r -f systemd-oom >/dev/null 2>&1 ||:
useradd -g systemd-oom -c 'systemd Userspace OOM Killer' \
    -d /var/empty -s /dev/null -r -l -M systemd-oom >/dev/null 2>&1 ||: