rendered paste body#!/bin/sh
# Put this script in /etc/mkinitrd/scripts/ and regenerate your initrd (by
# "mkinitrd -o /boot/initrd.img-`uname -r`" or reinstall your kernel package.
# Figure out swap device from the first device listed in /proc/swaps
swap_device=`awk 'BEGIN{getline;getline;print$1}' < /proc/swaps`
swap_type=`awk 'BEGIN{getline;getline;print$2}' < /proc/swaps`
if [ "x$swap_type" = "xpartition" ] ; then
resume2=`perl -e "@a=stat '$swap_device';printf 'swap:%04x', \\$a[6]"`
else
echo "Unable to determine swap device! You will need to set resume2= on your"
echo "kernel command-line manually."
fi
[ -n "$resume2" ] && resume2="echo $resume2 > /proc/suspend2/resume2"
# Modify linuxrc script
mv $INITRDDIR/linuxrc $INITRDDIR/linuxrc.real
cat <<EOT > $INITRDDIR/linuxrc
#!/bin/sh
export PATH=/sbin:/bin
mount -t proc proc /proc
. /loadmodules
$resume2
echo > /proc/suspend2/do_resume
umount /proc
. ./linuxrc.real
EOT
chmod 777 $INITRDDIR/linuxrc