244 lines
6.6 KiB
Bash
Executable File
244 lines
6.6 KiB
Bash
Executable File
#! /bin/sh
|
|
#
|
|
# initscripts postinst
|
|
#
|
|
|
|
set -e
|
|
|
|
. /lib/init/vars.sh
|
|
. /lib/init/tmpfs.sh
|
|
. /lib/init/mount-functions.sh
|
|
|
|
# Set this as a variable to hide from lintian the fact that we're removing
|
|
# it; otherwise, a wrong lintian check + ftp fatal autoreject prevents us
|
|
# from uploading this legitimate code, even though the previous upload was
|
|
# accepted without incident.
|
|
devshm=/dev/shm
|
|
|
|
case "$1" in
|
|
configure)
|
|
PREV_VER=$2
|
|
;;
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
umask 022
|
|
|
|
compat_link () {
|
|
SRC=$1
|
|
DEST=$2
|
|
|
|
ssrc="$(stat -L --format="%d %i" "$SRC" 2>/dev/null || :)"
|
|
sdest="$(stat -L --format="%d %i" "$DEST" 2>/dev/null || :)"
|
|
|
|
if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then
|
|
echo "guest environment detected: Linking $DEST to $SRC"
|
|
(
|
|
if [ -e $DEST ]; then
|
|
if [ -L $DEST ]; then
|
|
echo "$DEST is already a symlink; not replacing with link to $SRC"
|
|
exit 0
|
|
elif [ -d $DEST ]; then
|
|
rmdir $DEST || exit 1
|
|
else
|
|
echo "$DEST isn't a directory or a symlink"
|
|
exit 1
|
|
fi
|
|
fi
|
|
ln -fs $SRC $DEST
|
|
) || {
|
|
echo "Can't symlink $DEST to $SRC; please fix manually."
|
|
return 1
|
|
}
|
|
if which restorecon >/dev/null 2>&1; then
|
|
restorecon "$DEST"
|
|
fi
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
# In 2.88dsf-23 the "mountoverflowtmp" script was dropped entirely.
|
|
if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-23" ; then
|
|
update-rc.d -f mountoverflowtmp remove >/dev/null
|
|
fi
|
|
# In 2.88dsf-41+jessie1 the "mtab.sh" script was dropped entirely.
|
|
if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-41+jessie1" ; then
|
|
update-rc.d -f mtab.sh remove >/dev/null
|
|
fi
|
|
|
|
# Comment out obsolete options in rcS.
|
|
if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-23" ; then
|
|
if [ -f /etc/default/rcS ]; then
|
|
sed -i \
|
|
-e 's:^\(RAMRUN=.*\)$:#\1 # OBSOLETE; see /etc/default/tmpfs and tmpfs(5).:' \
|
|
-e 's:^\(RAMLOCK=.*\)$:#\1 # OBSOLETE; see /etc/default/tmpfs and tmpfs(5).:' \
|
|
-e ':^RAMSHM=:i# OBSOLETE; see /etc/default/tmpfs and tmpfs(5).' \
|
|
-e ':^RAMTMP=:i# OBSOLETE; see /etc/default/tmpfs and tmpfs(5).' \
|
|
-e 's:^\(EDITMOTD=.*\)$:#\1 # OBSOLETE.:' /etc/default/rcS
|
|
fi
|
|
fi
|
|
|
|
INITSCRIPTS="mountkernfs.sh brightness hostname.sh mountdevsubfs.sh checkroot.sh \
|
|
checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \
|
|
mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \
|
|
umountroot umountfs umountnfs.sh sendsigs killprocs single motd \
|
|
bootlogs rc.local rmnologin"
|
|
|
|
for F in $INITSCRIPTS; do
|
|
if [ -x /etc/init.d/$F ]; then
|
|
update-rc.d $F defaults >/dev/null || exit $?
|
|
fi
|
|
done
|
|
|
|
mkdir -p /etc/systemd/system
|
|
for F in $INITSCRIPTS; do
|
|
SERVICE="$(basename $F .sh).service"
|
|
if [ -x /etc/init.d/$F ] && [ ! -e /etc/systemd/system/$SERVICE ]; then
|
|
ln -s /dev/null /etc/systemd/system/$SERVICE
|
|
fi
|
|
done
|
|
|
|
#
|
|
# Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12)
|
|
# versions. We have the same functionality in mount{kern,devsub}fs.sh
|
|
#
|
|
#
|
|
# In 2.86.ds1-10 the "mountvirtfs" script was replaced by
|
|
# mountkernfs.sh and mountdevsubfs.sh. It was removed completely in
|
|
# 2.86.ds1-16.
|
|
#
|
|
for F in mountkernfs devpts.sh mountvirtfs
|
|
do
|
|
rm -f /etc/init.d/$F
|
|
update-rc.d $F remove >/dev/null
|
|
done
|
|
|
|
#
|
|
# When installing for the first time or upgrading from a version
|
|
# before or equal to 2.88dsf-14, a reboot is needed to make the /run
|
|
# tmpfs available. Flag this using notify-reboot-required. /run is
|
|
# available in some form before the reboot, so the need for a reboot
|
|
# isn't particularly urgent.
|
|
#
|
|
if dpkg --compare-versions "$PREV_VER" le "2.88dsf-13.3" \
|
|
&& [ -x /usr/share/update-notifier/notify-reboot-required ]; then
|
|
/usr/share/update-notifier/notify-reboot-required
|
|
fi
|
|
|
|
#
|
|
# Create initial log files
|
|
#
|
|
[ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
|
|
for F in /var/log/dmesg /var/log/fsck/checkroot /var/log/fsck/checkfs
|
|
do
|
|
if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
|
|
then
|
|
echo "(Nothing has been logged yet.)" >| "$F"
|
|
chown root:adm "$F"
|
|
chmod 640 "$F"
|
|
fi
|
|
done
|
|
|
|
#
|
|
# Create /dev/pts, /dev/shm directories
|
|
#
|
|
if [ "$(uname -s)" = Linux ]
|
|
then
|
|
#
|
|
# Only create /dev/{pts,shm} if /dev is on the
|
|
# root file system. If some package has mounted a
|
|
# seperate /dev (ramfs from udev, devfs) it is
|
|
# responsible for the presence of those subdirs.
|
|
# (it is OK for these to fail under fakechroot)
|
|
#
|
|
if ! mountpoint -q /dev
|
|
then
|
|
[ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts || [ "$FAKECHROOT" = true ]; }
|
|
[ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm || [ "$FAKECHROOT" = true ]; }
|
|
fi
|
|
fi
|
|
|
|
#
|
|
# Install runsystem.sysv on Hurd.
|
|
#
|
|
if [ "$(uname -s)" = GNU ]
|
|
then
|
|
get_runsystem() {
|
|
update-alternatives --query runsystem \
|
|
| sed -n -e '/^Value:/s|.*\.||p'
|
|
}
|
|
|
|
current="$(get_runsystem)"
|
|
update-alternatives --quiet \
|
|
--install /etc/hurd/runsystem runsystem \
|
|
/etc/hurd/runsystem.sysv 10 \
|
|
--slave /sbin/halt halt /sbin/halt-sysv \
|
|
--slave /sbin/poweroff poweroff /sbin/poweroff-sysv \
|
|
--slave /sbin/reboot reboot /sbin/reboot-sysv
|
|
new="$(get_runsystem)"
|
|
|
|
if [ "$current" != "$new" ]; then
|
|
echo "Switching from runsystem.$current to runsystem.$new."
|
|
echo
|
|
fi
|
|
|
|
echo "You can use update-alternatives --config runsystem to select"
|
|
echo "the runsystem to use."
|
|
echo
|
|
echo "You must use halt-hurd or reboot-hurd to halt or reboot the"
|
|
echo "system whenever you change the runsystem."
|
|
fi
|
|
|
|
# Ensure we have a random seed on first boot.
|
|
if [ "$PREV_VER" = "" ]; then
|
|
if which invoke-rc.d >/dev/null 2>&1
|
|
then
|
|
invoke-rc.d urandom start || true
|
|
else
|
|
/etc/init.d/urandom start || true
|
|
fi
|
|
fi
|
|
|
|
#
|
|
# Create /etc/rc.local on first time install and when upgrading from
|
|
# versions before "2.86.ds1-16"
|
|
#
|
|
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-16"
|
|
then
|
|
if [ ! -e /etc/rc.local ]; then
|
|
cat << EOF > /etc/rc.local
|
|
#!/bin/sh -e
|
|
#
|
|
# rc.local
|
|
#
|
|
# This script is executed at the end of each multiuser runlevel.
|
|
# Make sure that the script will "exit 0" on success or any other
|
|
# value on error.
|
|
#
|
|
# In order to enable or disable this script just change the execution
|
|
# bits.
|
|
#
|
|
# By default this script does nothing.
|
|
|
|
[ -d /etc/boot.d ] && run-parts /etc/boot.d
|
|
|
|
exit 0
|
|
EOF
|
|
# make sure it's enabled by default.
|
|
chmod 755 /etc/rc.local
|
|
fi
|
|
fi
|
|
|
|
# Automatically added by dh_installdeb/12.1
|
|
dpkg-maintscript-helper rm_conffile /etc/init.d/bootlogd 2.88dsf-42 initscripts -- "$@"
|
|
dpkg-maintscript-helper rm_conffile /etc/init.d/stop-bootlogd 2.88dsf-42 initscripts -- "$@"
|
|
dpkg-maintscript-helper rm_conffile /etc/init.d/stop-bootlogd-single 2.88dsf-42 initscripts -- "$@"
|
|
dpkg-maintscript-helper rm_conffile /etc/init.d/motd 2.93-3\~ initscripts -- "$@"
|
|
# End automatically added section
|
|
|
|
|
|
:
|