Revision 806, 9.5 KB checked in by daisuke, 14 years ago (diff) |
---|
diff -up mkinitrd-6.0.93/mkinitrd.tuxonice mkinitrd-6.0.93/mkinitrd
old | new | LD_SO_CONF=/etc/ld.so.conf |
---|---|---|
74 | 74 | LD_SO_CONF_D=/etc/ld.so.conf.d/ |
75 | 75 | |
76 | 76 | [ -e /etc/sysconfig/mkinitrd ] && . /etc/sysconfig/mkinitrd |
77 | [ -e /etc/sysconfig/mkinitrd-suspend2 ] && . /etc/sysconfig/mkinitrd-suspend2 | |
78 | [ -e /etc/sysconfig/mkinitrd-tuxonice ] && . /etc/sysconfig/mkinitrd-tuxonice | |
77 | 79 | |
78 | 80 | CONFMODS="$MODULES" |
79 | 81 | MODULES="" |
… | … | modulefile=/etc/modules.conf |
91 | 93 | rc=0 |
92 | 94 | nolvm="" |
93 | 95 | nodmraid="" |
94 | ||
96 | tuxoniceuserui="none" | |
97 | tuxoniceversion="30001" | |
98 | tuxonicefwtarget="" | |
99 | splashtheme="suspend2" | |
100 | ||
101 | DSDT="/boot/DSDT.aml" | |
102 | SWSUSPPROC="/proc/suspend2" | |
103 | USERUIPROC="userui_program" | |
104 | FWLOCPROC="filewriter_target" | |
105 | RESUMETAR="resume2" | |
106 | FWIDENT="Suspend2" | |
107 | UIPREFIX="suspend2" | |
95 | 108 | IMAGESIZE=8000 |
96 | 109 | PRESCSIMODS="" |
97 | 110 | fstab="/etc/fstab" |
… | … | usage () { |
111 | 124 | $cmd " [--image-version] [--force-raid-probe | --omit-raid-modules]" |
112 | 125 | $cmd " [--with=<module>] [--force-lvm-probe | --omit-lvm-modules]" |
113 | 126 | $cmd " [--builtin=<module>] [--omit-dmraid] [--net-dev=<interface>]" |
127 | $cmd " [--tuxonice-userui=<none | auto | text | fb>]" | |
128 | $cmd " [--tuxonice-version=<version-string>] [--splash=<theme>]" | |
129 | $cmd " [--dsdt-location=<location of DSDT-file>]" | |
114 | 130 | $cmd " [--fstab=<fstab>] [--nocompress] <initrd-image> <kernel-version>" |
115 | 131 | $cmd "" |
116 | 132 | $cmd " (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)" |
… | … | handlegraphics() { |
745 | 761 | qpopd |
746 | 762 | } |
747 | 763 | |
764 | IsANumber() { | |
765 | case "$1" in *[!0-9]*|"") return 1 ;; esac | |
766 | return 0 | |
767 | } | |
768 | ||
769 | check_filewriter() { | |
770 | # Filewriterhandling for Software Suspend 2 | |
771 | # we will check for /etc/hibernate/hibernate.conf and the filewriter | |
772 | # settings there | |
773 | local resume2 fwlocopt fwloc fwsize oldtarget newresume2 | |
774 | ||
775 | if [ -e $1/$RESUMETAR ]; then | |
776 | resume2=$(cat $1/$RESUMETAR) | |
777 | # if filewriter is already active use that information | |
778 | if [ $(echo "$resume2"X | dd bs=5 count=1 2>/dev/null) = "file:" ]; then tuxonicefwtarget=$resume2; return; fi | |
779 | else | |
780 | # if resume2 does not exist the current kernel is not Suspend 2 enabled, | |
781 | # so there is no way to determine filewriters target information anyway | |
782 | return | |
783 | fi | |
784 | ||
785 | if [ ! -e $1/$2 ]; then return; fi | |
786 | if [ -e /etc/hibernate/tuxonice.conf ]; then | |
787 | fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/tuxonice.conf|tail -n 1) | |
788 | elif [ -e /etc/hibernate/suspend2.conf ]; then | |
789 | fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/suspend2.conf|tail -n 1) | |
790 | elif [ ! -e /etc/hibernate/hibernate.conf ]; then | |
791 | return; | |
792 | else | |
793 | fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/hibernate.conf|tail -n 1) | |
794 | fi | |
795 | ||
796 | if [ ! "$fwlocopt" ]; then return; fi | |
797 | fwloc=$(echo $fwlocopt | awk '{ print $2 }') | |
798 | fwsize=$(echo $fwlocopt | awk '{ print $3 }') | |
799 | ||
800 | if [ ! -e "$fwloc" ]; then | |
801 | if ! IsANumber "$fwsize"; then return; fi | |
802 | { | |
803 | echo "$FWIDENT" | |
804 | dd if=/dev/zero bs=1M count=$fwsize 2>/dev/null | |
805 | ||
806 | } > "$fwloc" | |
807 | fi | |
808 | ||
809 | oldtarget=$(cat $1/$2) | |
810 | sync | |
811 | echo "$fwloc" > $1/$2 | |
812 | newresume2=$(cat $1/$RESUMETAR) | |
813 | echo "$oldtarget" > $1/$2 | |
814 | echo "$resume2" > $1/$RESUMETAR | |
815 | ||
816 | if [ $(echo $newresume2 | dd bs=5 count=1 2>/dev/null) = "file:" ]; then tuxonicefwtarget=$newresume2; fi | |
817 | } | |
818 | ||
819 | inst_tuxonice() { | |
820 | # TuxOnIce stuff | |
821 | emit "echo Activating tux on ice" | |
822 | userui="$tuxoniceuserui"; | |
823 | if [ "x$tuxoniceuserui" == "xauto" ]; then | |
824 | if [ -f /sbin/${UIPREFIX}ui_fbsplash ]; then | |
825 | userui="fb"; | |
826 | elif [ -f /sbin/${UIPREFIX}ui_text ]; then | |
827 | userui="text"; | |
828 | else | |
829 | userui="none"; | |
830 | fi | |
831 | fi | |
832 | if [ "x$userui" != "xnone" ]; then | |
833 | if [ "x$userui" == "xfb" ]; then | |
834 | if [ -f /sbin/${UIPREFIX}ui_fbsplash ]; then | |
835 | inst /sbin/${UIPREFIX}ui_fbsplash "$2" /bin/${UIPREFIX}ui_fbsplash | |
836 | if [ -e /etc/splash/${splashtheme} ]; then | |
837 | mkdir "$2/etc/splash" | |
838 | cp -prH /etc/splash/${splashtheme}/ "$2/etc/splash/" | |
839 | fi | |
840 | # check if splashtheme is a symlink and add one to initrd if that is the case | |
841 | if [ -L /etc/splash/${splashtheme} ]; then | |
842 | dlink=` find /etc/splash/${splashtheme} -printf '%l' ` | |
843 | dlink=$(basename $dlink) | |
844 | ln -sf ${splashtheme} "$2/etc/splash/$dlink" | |
845 | fi | |
846 | if [ -e $2/etc/splash/{$splashtheme} ]; then | |
847 | if [ ! -e $2/etc/splash/TuxOnIce ]; then | |
848 | ln -sf ${splashtheme} "$2/etc/splash/TuxOnIce" | |
849 | fi | |
850 | if [ ! -e $2/etc/splash/suspend2 ]; then | |
851 | ln -sf ${splashtheme} "$2/etc/splash/suspend2" | |
852 | fi | |
853 | fi | |
854 | if [ -f /sbin/splash_helper ]; then | |
855 | inst /sbin/splash_helper "$2" /bin/splash_helper | |
856 | fi | |
857 | emit "echo /bin/${UIPREFIX}ui_fbsplash > $1/$4" | |
858 | else | |
859 | error "WARNING: framebuffer UI for suspend not found, skipping." | |
860 | fi | |
861 | elif [ "x$userui" == "xtext" ]; then | |
862 | if [ -f /sbin/${UIPREFIX}ui_text ]; then | |
863 | inst /sbin/${UIPREFIX}ui_text "$2" /bin/${UIPREFIX}ui_text | |
864 | emit "echo /bin/${UIPREFIX}ui_text > $1/$4" | |
865 | else | |
866 | error "WARNING: text UI for suspend not found, skipping." | |
867 | fi | |
868 | else | |
869 | error "WARNING: unknown UI \"$userui\" specified." | |
870 | fi | |
871 | fi | |
872 | ||
873 | # First try to resume with the parameter present on the kernel commandline | |
874 | emit "echo Trying to resume from target specified as $RESUMETAR on cmdline." | |
875 | emit "echo 1 > $1/do_resume" | |
876 | ||
877 | # Then we will try the swapdevice/filetarget that was present while creating the initrd | |
878 | emit "echo Trying to resume from $3." | |
879 | emit "echo $3 > $1/$RESUMETAR" | |
880 | emit "echo 1 > $1/do_resume" | |
881 | } | |
882 | ||
748 | 883 | savedargs=$* |
749 | 884 | while [ $# -gt 0 ]; do |
750 | 885 | case $1 in |
… | … | while [ $# -gt 0 ]; do |
945 | 1080 | shift |
946 | 1081 | fi |
947 | 1082 | ;; |
1083 | --splash*) | |
1084 | if echo $1 | grep -q '=' ; then | |
1085 | splashtheme=`echo $1 | sed 's/^--splash=//'` | |
1086 | else | |
1087 | splashtheme=$2 | |
1088 | shift | |
1089 | fi | |
1090 | ;; | |
1091 | --tuxonice-userui*) | |
1092 | if echo $1 | grep -q '=' ; then | |
1093 | tuxoniceuserui=`echo $1 | sed 's/^--tuxonice-userui=//'` | |
1094 | else | |
1095 | tuxoniceuserui=$2 | |
1096 | shift | |
1097 | fi | |
1098 | ;; | |
1099 | --tuxonice-version*) | |
1100 | if echo $1 | grep -q '=' ; then | |
1101 | tuxoniceversion=`echo $1 | sed 's/^--tuxonice-version=//'` | |
1102 | else | |
1103 | tuxoniceversion=$2 | |
1104 | shift | |
1105 | fi | |
1106 | ;; | |
1107 | --suspend2-userui*) | |
1108 | if echo $1 | grep -q '=' ; then | |
1109 | tuxoniceuserui=`echo $1 | sed 's/^--suspend2-userui=//'` | |
1110 | else | |
1111 | tuxoniceuserui=$2 | |
1112 | shift | |
1113 | fi | |
1114 | ;; | |
1115 | --suspend2-version*) | |
1116 | if echo $1 | grep -q '=' ; then | |
1117 | tuxoniceversion=`echo $1 | sed 's/^--suspend2-version=//'` | |
1118 | else | |
1119 | tuxoniceversion=$2 | |
1120 | shift | |
1121 | fi | |
1122 | ;; | |
1123 | --dsdt-location*) | |
1124 | if echo $1 | grep -q '=' ; then | |
1125 | DSDT=`echo $1 | sed 's/^--dsdt-location=//'` | |
1126 | else | |
1127 | DSDT=$2 | |
1128 | shift | |
1129 | fi | |
1130 | ;; | |
948 | 1131 | --help) |
949 | 1132 | usage -n |
950 | 1133 | ;; |
… | … | while [ $# -gt 0 ]; do |
962 | 1145 | shift |
963 | 1146 | done |
964 | 1147 | |
1148 | if [ "$tuxoniceversion" -lt "20108" ]; then | |
1149 | SWSUSPPROC="/proc/software_suspend" | |
1150 | elif [ "$tuxoniceversion" -ge "20208" ]; then | |
1151 | SWSUSPPROC="/sys/power/suspend2" | |
1152 | USERUIPROC="user_interface/program" | |
1153 | FWLOCPROC="filewriter/target" | |
1154 | fi | |
1155 | if [ "$tuxoniceversion" -ge "20211" ]; then | |
1156 | RESUMETAR="resume" | |
1157 | fi | |
1158 | if [ "$tuxoniceversion" -ge "20212" ]; then | |
1159 | SWSUSPPROC="/sys/power/tuxonice" | |
1160 | FWIDENT="TuxOnIce" | |
1161 | UIPREFIX="tuxonice" | |
1162 | fi | |
1163 | ||
965 | 1164 | if [ -z "$target" -o -z "$kernel" ]; then |
966 | 1165 | usage |
967 | 1166 | fi |
… | … | fi |
1186 | 1385 | mkdir -p $MNTIMAGE |
1187 | 1386 | mkdir -p $MNTIMAGE/lib/firmware |
1188 | 1387 | mkdir -p $MNTIMAGE/lib/modules/$kernel |
1388 | mkdir -p $MNTIMAGE/lib/splash | |
1189 | 1389 | mkdir -p $MNTIMAGE/bin |
1190 | 1390 | mkdir -p $MNTIMAGE/etc |
1191 | 1391 | mkdir -p $MNTIMAGE/dev |
… | … | excludemods() { |
1220 | 1420 | echo $output |
1221 | 1421 | } |
1222 | 1422 | |
1423 | if [ -e "$DSDT" ]; then | |
1424 | inst "$DSDT" "$MNTIMAGE/DSDT.aml" | |
1425 | fi | |
1426 | ||
1223 | 1427 | if [ -n "$excludemodules" ]; then |
1224 | 1428 | MODULES=$(excludemods $MODULES) |
1225 | 1429 | availmodules=$(excludemods $availmodules) |
… | … | done |
1253 | 1457 | mknod $MNTIMAGE/dev/tty c 5 0 |
1254 | 1458 | mknod $MNTIMAGE/dev/console c 5 1 |
1255 | 1459 | mknod $MNTIMAGE/dev/ptmx c 5 2 |
1460 | mknod $MNTIMAGE/dev/fb0 c 29 0 | |
1256 | 1461 | |
1257 | 1462 | if [ -n "$raiddevices" ]; then |
1258 | 1463 | inst /sbin/mdadm "$MNTIMAGE" |
… | … | mknod /dev/console c 5 1 |
1496 | 1701 | mknod /dev/ptmx c 5 2 |
1497 | 1702 | mknod /dev/fb c 29 0 |
1498 | 1703 | mknod /dev/hvc0 c 229 0 |
1704 | mknod /dev/fb0 c 29 0 | |
1499 | 1705 | EOF |
1500 | 1706 | |
1501 | 1707 | # XXX really we need to openvt too, in case someting changes the |
… | … | for cryptdev in ${!cryptolv@} ; do |
1628 | 1834 | emitcrypto `eval echo '$'$cryptdev` |
1629 | 1835 | done |
1630 | 1836 | |
1631 | if [ -z "$noresume" -a -n "$thawdev" ]; then | |
1632 | emit "resume $thawdev" | |
1837 | if [ -z "$noresume" ]; then | |
1838 | if [ -n "$thawdev" ]; then | |
1839 | emit "resume $thawdev" | |
1840 | fi | |
1841 | check_filewriter $SWSUSPPROC $FWLOCPROC | |
1842 | swsuspdev="$thawdev" | |
1843 | if [ -n "$tuxonicefwtarget" ]; then | |
1844 | inst_tuxonice $SWSUSPPROC $MNTIMAGE $tuxonicefwtarget $USERUIPROC | |
1845 | elif [ -n "$swsuspdev" ]; then | |
1846 | if [[ "$swsuspdev" =~ ^(UUID=|LABEL=) ]]; then | |
1847 | swsuspdev=$(resolve_device_name "$swsuspdev") | |
1848 | fi | |
1849 | ||
1850 | inst_tuxonice $SWSUSPPROC $MNTIMAGE swap:$swsuspdev $USERUIPROC | |
1851 | fi | |
1633 | 1852 | fi |
1634 | 1853 | |
1635 | 1854 | if [ -n "$loopfs" ]; then |