home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- #
- # initscripts postinst
- #
-
- set -e
-
- case "$1" in
- configure)
- PREV_VER=$2
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- exit 0
- ;;
- esac
-
- umask 022
-
- #
- # Function like update-rc.d but simpler & faster.
- # Usage: updatercd basename start|stop NN runlevel .
- #
- # Heuristic: use the real update-rc.d if file-rc is detected,
- # or if the /etc/rc2.d directory is not present.
- #
- updatercd() {
-
- [ -f /etc/init.d/$1 ] || return 0
-
- if \
- [ -d /usr/share/file-rc/. ] \
- || [ -d /usr/lib/file-rc/. ] \
- || [ ! -d /etc/rc2.d/. ]
- then
- # Funniness on next line is because we are running with set -e
- update-rc.d "$@" >/dev/null && return 0 || return $?
- fi
-
- base=$1
- shift
-
- tmp="$(echo /etc/rc?.d/[SK]??$base)"
- case "$tmp" in
- "/etc/rc?.d/[SK]??$base") : ;;
- *) return ;;
- esac
-
- while [ "$1" != "" ]
- do
- if [ "$1" = stop ]
- then
- tlet=K
- else
- tlet=S
- fi
- case "$2" in
- ?) lev=0$2 ;;
- *) lev=$2 ;;
- esac
- shift 2
- while [ "$1" != "." ]
- do
- cd /etc/rc$1.d
- ln -sf ../init.d/$base $tlet$lev$base
- shift
- done
- shift
- done
- }
-
- #
- # Initialize rcS default file.
- #
- if [ ! -f /etc/default/rcS ]
- then
- cp -p /usr/share/initscripts/default.rcS /etc/default/rcS
- fi
-
- #
- # In 2.86.ds1-7 the "single" script was moved.
- # We have to remove the old links _before_ we install new ones.
- #
- if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-7"
- then
- update-rc.d -f single remove >/dev/null 2>&1 || :
- fi
-
- #
- # Okay, we could do this with update-rc.d, but that would probably
- # be pretty slow. This way we win some speed.
- # DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES.
- #
- # Links in runlevel S
- #
- updatercd mountkernfs.sh start 1 S .
- updatercd hostname.sh start 2 S .
- updatercd mountdevsubfs.sh start 11 S .
- #updatercd modutils start 15 S .
- #updatercd bootlogd start 18 S .
- updatercd checkroot.sh start 20 S .
- updatercd mtab.sh start 22 S .
- updatercd checkfs.sh start 30 S .
- updatercd mountall.sh start 35 S .
- updatercd mountall-bootclean.sh start 36 S .
- updatercd waitnfs.sh start 45 S .
- updatercd mountnfs-bootclean.sh start 46 S .
- updatercd bootmisc.sh start 80 S .
- updatercd urandom start 85 S . start 30 0 6 .
- #
- # Links in runlevels other than S
- #
- updatercd sendsigs start 20 0 6 .
- updatercd umountnfs.sh start 31 0 6 .
- updatercd umountfs start 40 0 6 .
- updatercd umountroot start 60 0 6 .
- updatercd halt start 90 0 .
- updatercd reboot start 90 6 .
- updatercd killprocs start 30 1 .
- updatercd single start 90 1 .
- updatercd rc.local start 99 2 3 4 5 .
- updatercd rmnologin start 99 2 3 4 5 .
- #updatercd stop-bootlogd-single start 99 S .
- #updatercd stop-bootlogd start 99 2 3 4 5 .
-
- #
- # Remove scripts that were left behind by older versions
- #
- for F in mountkernfs devpts.sh mountvirtfs mountdevsubfs mtab
- do
- rm -f /etc/init.d/$F
- update-rc.d $F remove >/dev/null 2>&1 || :
- done
-
- rm -f /etc/init.d/bootclean.sh
-
- #
- # Create /var/run and /var/lock
- #
- if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu12"
- then
- # We need to quickly bind / to another location so we can make them
- # just in case /var is a mountpoint or a symlink to one.
- mkdir /.root
- mount -n --bind / /.root
-
- mkdir -p /.root/var/run /.root/var/lock
-
- umount /.root
- rmdir /.root
- fi
-
- #
- # Mount /var/run and /var/lock
- #
- if [ "$PREV_VER" ] && dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu12"
- then
- # Make /var/run a tmpfs, and move everything onto it. This will
- # probably break a few running things. If already a tmpfs, try
- # cleaning up the one underneath
- mkdir /tmp/.var.run
- if mountpoint -q /var/run; then
- mount -n --move /var/run /tmp/.var.run
- else
- mount -n -t tmpfs varrun /tmp/.var.run
- (cd /var/run && find -print0 | cpio -p0dm /tmp/.var.run) 2>/dev/null || true
- fi
- find /var/run ! -type d -exec rm -f -- {} \; || true
- mount -n --move /tmp/.var.run /var/run
- rmdir /tmp/.var.run
-
- # And do the same for /var/lock
- mkdir /tmp/.var.lock
- if mountpoint -q /var/lock; then
- mount -n --move /var/lock /tmp/.var.lock
- else
- mount -n -t tmpfs varlock /tmp/.var.lock
- (cd /var/lock && find -print0 | cpio -p0dm /tmp/.var.lock) 2>/dev/null || true
- fi
- find /var/lock ! -type d -exec rm -f -- {} \; || true
- mount -n --move /tmp/.var.lock /var/lock
- rmdir /tmp/.var.lock
-
- if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
- /usr/share/update-notifier/notify-reboot-required
- fi
- fi
-
- #
- # Create initial log files
- #
- [ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
- for F in /var/log/dmesg /var/log/boot /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
-
- #
- # Set up nologin symlink so that dynamic-login-disabling will work
- # (when DELAYLOGIN is set to "yes")
- #
- if [ ! -L /etc/nologin ] && [ ! -e /etc/nologin ]
- then
- rm -f /var/lib/initscripts/nologin
- ln -s /var/lib/initscripts/nologin /etc/nologin
- fi
-
- #
- # Set up motd stuff, putting variable file in /var/run/
- #
- if [ ! -f /etc/motd.tail ]
- then
- if [ -f /etc/motd ]
- then
- sed 1d /etc/motd > /etc/motd.tail
- [ -s /etc/motd.tail ] || rm -f /etc/motd.tail
- fi
- fi
- if [ ! -f /var/run/motd ]
- then
- if [ -f /etc/motd ]
- then
- cat /etc/motd > /var/run/motd
- else
- :>/var/run/motd
- fi
- fi
- if [ ! -L /etc/motd ]
- then
- [ -f /etc/default/rcS ] && . /etc/default/rcS
- if [ "$EDITMOTD" = no ]
- then
- cat /var/run/motd > /etc/motd.static
- ln -sf motd.static /etc/motd
- else
- ln -sf /var/run/motd /etc/motd
- fi
- fi
-
- #
- # Mount kernel virtual filesystems...not.
- # This causes problems in pbuilder.
- #
- #
- #if [ -x /etc/init.d/mountkernfs.sh ]
- #then
- # if which invoke-rc.d >/dev/null 2>&1
- # then
- # invoke-rc.d mountkernfs.sh start || :
- # else
- # /etc/init.d/mountkernfs.sh start
- # fi
- #fi
-
- #
- # 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.
- #
- if ! mountpoint -q /dev
- then
- [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts ; }
- [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm ; }
- fi
- fi
-
- #
- # Create /etc/rc.local
- #
- if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu19"
- 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.
-
- exit 0
- EOF
- # make sure it's enabled by default.
- chmod 755 /etc/rc.local
- fi
- fi
-
- #
- # Mount virtual filesystems under /dev...not.
- # This causes problems in pbuilder.
- #
- #if [ -x /etc/init.d/mountdevsubfs.sh ]
- #then
- # if which invoke-rc.d >/dev/null 2>&1
- # then
- # invoke-rc.d mountdevsubfs.sh start || :
- # else
- # /etc/init.d/mountdevsubfs.sh start
- # fi
- #fi
-
- :
-