| 1 |
#! /bin/sh |
| 2 |
# |
| 3 |
# initscripts postinst |
| 4 |
# |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
. "$DPKG_ROOT/lib/init/vars.sh" |
| 9 |
. "$DPKG_ROOT/lib/init/tmpfs.sh" |
| 10 |
. "$DPKG_ROOT/lib/init/mount-functions.sh" |
| 11 |
|
| 12 |
case "$1" in |
| 13 |
configure) |
| 14 |
PREV_VER=$2 |
| 15 |
;; |
| 16 |
triggered) |
| 17 |
if [ ! -d /run/systemd/system ]; then |
| 18 |
for trigger in "$2" ; do |
| 19 |
case "$trigger" in |
| 20 |
*/lib/systemd/system/udev.service) |
| 21 |
if [ ! -e "$trigger" ]; then |
| 22 |
invoke-rc.d udev stop |
| 23 |
elif [ ! -e "/run/udev" ]; then |
| 24 |
invoke-rc.d udev start |
| 25 |
else |
| 26 |
invoke-rc.d udev reload |
| 27 |
fi |
| 28 |
;; |
| 29 |
esac |
| 30 |
done |
| 31 |
fi |
| 32 |
exit 0 |
| 33 |
;; |
| 34 |
abort-upgrade|abort-remove|abort-deconfigure) |
| 35 |
exit 0 |
| 36 |
;; |
| 37 |
esac |
| 38 |
|
| 39 |
umask 022 |
| 40 |
|
| 41 |
INITSCRIPTS="mountkernfs.sh mount-configfs brightness hostname.sh mountdevsubfs.sh checkroot.sh \ |
| 42 |
checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \ |
| 43 |
mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \ |
| 44 |
udev umountroot umountfs umountnfs.sh sendsigs killprocs single motd \ |
| 45 |
bootlogs rc.local rmnologin hwclock.sh kmod" |
| 46 |
|
| 47 |
for F in $INITSCRIPTS; do |
| 48 |
if [ -x "$DPKG_ROOT/etc/init.d/$F" ]; then |
| 49 |
update-rc.d $F defaults >/dev/null || exit $? |
| 50 |
fi |
| 51 |
done |
| 52 |
|
| 53 |
mkdir -p "$DPKG_ROOT/etc/systemd/system" |
| 54 |
for F in $INITSCRIPTS; do |
| 55 |
SERVICE="$(basename $F .sh).service" |
| 56 |
if [ -x "$DPKG_ROOT/etc/init.d/$F" ] && [ ! -e "$DPKG_ROOT/etc/systemd/system/$SERVICE" ]; then |
| 57 |
ln -s /dev/null "$DPKG_ROOT/etc/systemd/system/$SERVICE" |
| 58 |
fi |
| 59 |
done |
| 60 |
|
| 61 |
# |
| 62 |
# Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12) |
| 63 |
# versions. We have the same functionality in mount{kern,devsub}fs.sh |
| 64 |
# |
| 65 |
# |
| 66 |
# In 2.86.ds1-10 the "mountvirtfs" script was replaced by |
| 67 |
# mountkernfs.sh and mountdevsubfs.sh. It was removed completely in |
| 68 |
# 2.86.ds1-16. |
| 69 |
# |
| 70 |
for F in mountkernfs devpts.sh mountvirtfs |
| 71 |
do |
| 72 |
rm -f /etc/init.d/$F |
| 73 |
update-rc.d $F remove >/dev/null |
| 74 |
done |
| 75 |
|
| 76 |
# |
| 77 |
# Create initial log files |
| 78 |
# |
| 79 |
[ "$PREV_VER" ] || chmod 755 "$DPKG_ROOT/var/log/fsck" || : |
| 80 |
for F in "$DPKG_ROOT/var/log/fsck/checkroot" "$DPKG_ROOT/var/log/fsck/checkfs" |
| 81 |
do |
| 82 |
if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1 |
| 83 |
then |
| 84 |
echo "(Nothing has been logged yet.)" >| "$F" |
| 85 |
chown root:adm "$F" |
| 86 |
chmod 640 "$F" |
| 87 |
fi |
| 88 |
done |
| 89 |
|
| 90 |
# |
| 91 |
# Create /dev/pts, /dev/shm directories |
| 92 |
# |
| 93 |
# The 'mountpoint -q /dev' assumes that the system providing /dev is the same |
| 94 |
# system that this package is installed to. This check thus only makes sense |
| 95 |
# if "$DPKG_ROOT" is empty. |
| 96 |
# Checking "$DPKG_ROOT" for being empty also makes sure that "uname -s" is not |
| 97 |
# called in chrootless mode, where the uname output of the outer system does |
| 98 |
# not necessarily correspond to the kernel of the targeted system. |
| 99 |
if [ -z "$DPKG_ROOT" ] && [ "$(uname -s)" = Linux ] |
| 100 |
then |
| 101 |
# |
| 102 |
# Only create /dev/{pts,shm} if /dev is on the |
| 103 |
# root file system. If some package has mounted a |
| 104 |
# seperate /dev (ramfs from udev, devfs) it is |
| 105 |
# responsible for the presence of those subdirs. |
| 106 |
# (it is OK for these to fail under fakechroot) |
| 107 |
# |
| 108 |
if ! mountpoint -q /dev |
| 109 |
then |
| 110 |
[ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts || [ "$FAKECHROOT" = true ]; } |
| 111 |
[ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm || [ "$FAKECHROOT" = true ]; } |
| 112 |
fi |
| 113 |
fi |
| 114 |
|
| 115 |
# |
| 116 |
# Install runsystem.sysv on Hurd. |
| 117 |
# |
| 118 |
# This block is hurd-specific. Run it based on the output of "uname -s" if |
| 119 |
# $DPKG_ROOT is empty (the normal case). Run it based on there being an |
| 120 |
# alternative called 'runsystem' managing the link /etc/hurd/runsystem if |
| 121 |
# $DPKG_ROOT is not empty (for chrootless installations). |
| 122 |
if { [ -z "$DPKG_ROOT" ] && [ "$(uname -s)" = GNU ]; } \ |
| 123 |
|| { [ -n "$DPKG_ROOT" ] && update-alternatives --query runsystem 2>/dev/null | grep --quiet '^Link: /etc/hurd/runsystem$'; } |
| 124 |
then |
| 125 |
get_runsystem() { |
| 126 |
update-alternatives --query runsystem \ |
| 127 |
| sed -n -e '/^Value:/s|.*\.||p' |
| 128 |
} |
| 129 |
|
| 130 |
current="$(get_runsystem)" |
| 131 |
update-alternatives --quiet \ |
| 132 |
--install /etc/hurd/runsystem runsystem \ |
| 133 |
/etc/hurd/runsystem.sysv 10 \ |
| 134 |
--slave /sbin/halt halt /sbin/halt-sysv \ |
| 135 |
--slave /sbin/poweroff poweroff /sbin/poweroff-sysv \ |
| 136 |
--slave /sbin/reboot reboot /sbin/reboot-sysv |
| 137 |
new="$(get_runsystem)" |
| 138 |
|
| 139 |
if [ "$current" != "$new" ]; then |
| 140 |
echo "Switching from runsystem.$current to runsystem.$new." |
| 141 |
echo |
| 142 |
fi |
| 143 |
|
| 144 |
echo "You can use update-alternatives --config runsystem to select" |
| 145 |
echo "the runsystem to use." |
| 146 |
echo |
| 147 |
echo "You must use halt-hurd or reboot-hurd to halt or reboot the" |
| 148 |
echo "system whenever you change the runsystem." |
| 149 |
fi |
| 150 |
|
| 151 |
# Ensure we have a random seed on first boot. |
| 152 |
if [ "$PREV_VER" = "" ]; then |
| 153 |
if which invoke-rc.d >/dev/null 2>&1 |
| 154 |
then |
| 155 |
invoke-rc.d urandom start || true |
| 156 |
else |
| 157 |
/etc/init.d/urandom start || true |
| 158 |
fi |
| 159 |
fi |
| 160 |
|
| 161 |
#DEBHELPER# |