| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | set -e |
|---|
| 4 | |
|---|
| 5 | chrooted() { |
|---|
| 6 | # borrowed from udev's postinst |
|---|
| 7 | if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then |
|---|
| 8 | # the devicenumber/inode pair of / is the same as that of |
|---|
| 9 | # /sbin/init's root, so we're *not* in a chroot and hence |
|---|
| 10 | # return false. |
|---|
| 11 | return 1 |
|---|
| 12 | fi |
|---|
| 13 | return 0 |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | case "$1" in |
|---|
| 17 | install) |
|---|
| 18 | mkdir -p /etc/initramfs-tools/conf.d |
|---|
| 19 | |
|---|
| 20 | # First time install. Can we autodetect the RESUME partition? |
|---|
| 21 | if [ -r /proc/swaps ]; then |
|---|
| 22 | RESUME=$(tail -n $(($(wc -l /proc/swaps | awk ' { print $1 } ') - 1)) /proc/swaps | sort -rk3 | head -n 1 | awk ' { print $1 } ') |
|---|
| 23 | fi |
|---|
| 24 | |
|---|
| 25 | # Inherit initrd-tools settings if possible. |
|---|
| 26 | if [ -e /etc/mkinitrd/mkinitrd.conf ]; then |
|---|
| 27 | . /etc/mkinitrd/mkinitrd.conf |
|---|
| 28 | fi |
|---|
| 29 | # write conf.d/resume if not in a chroot |
|---|
| 30 | if [ -n "${RESUME}" ] && ! chrooted; then |
|---|
| 31 | echo "RESUME=${RESUME}" > /etc/initramfs-tools/conf.d/resume |
|---|
| 32 | fi |
|---|
| 33 | |
|---|
| 34 | # Add initrd-tools modules, while trying to minimize prompting |
|---|
| 35 | if [ -e /etc/mkinitrd/modules ]; then |
|---|
| 36 | cp /etc/mkinitrd/modules /etc/initramfs-tools/ |
|---|
| 37 | sed -i \ |
|---|
| 38 | -e 's/\/etc\/mkinitrd\/modules: Kernel modules to load for initrd./List of modules that you want to include in your initramfs./g' \ |
|---|
| 39 | -e 's/mkinitrd/update-initramfs/g' \ |
|---|
| 40 | -e '/# This file should/,/one per line\./d' \ |
|---|
| 41 | -e 's/Comments begin with.*/Syntax: module_name [args ...]/' \ |
|---|
| 42 | -e 's/^# ext2$/# raid1/' \ |
|---|
| 43 | -e 's/^# wd io=0x300$/# sd_mod/' \ |
|---|
| 44 | -e '/^ide-generic/d' \ |
|---|
| 45 | -e '/^ide-disk/d' \ |
|---|
| 46 | -e '/^ext2/d' \ |
|---|
| 47 | -e '/^ext3/d' \ |
|---|
| 48 | /etc/initramfs-tools/modules |
|---|
| 49 | fi |
|---|
| 50 | |
|---|
| 51 | if [ -e /etc/mkinitrd/DSDT ]; then |
|---|
| 52 | cp /etc/mkinitrd/DSDT /etc/initramfs-tools/DSDT.aml |
|---|
| 53 | fi |
|---|
| 54 | ;; |
|---|
| 55 | esac |
|---|
| 56 | |
|---|
| 57 | #DEBHELPER# |
|---|