| 15 | beyerle@PS | 1 | #!/bin/bash
 | 
        
           |  |  | 2 | #
 | 
        
           |  |  | 3 | ###############################################################
 | 
        
           |  |  | 4 | #
 | 
        
           |  |  | 5 | # Installes the LiveCD on local harddisk
 | 
        
           |  |  | 6 | # 
 | 
        
           |  |  | 7 | # Boot LiveCD and run this script as root
 | 
        
           |  |  | 8 | #
 | 
        
           |  |  | 9 | # Urs Beyerle, PSI
 | 
        
           |  |  | 10 | #
 | 
        
           |  |  | 11 | ###############################################################
 | 
        
           |  |  | 12 |   | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 | ###############################################################
 | 
        
           |  |  | 15 | # Definitions
 | 
        
           |  |  | 16 | ###############################################################
 | 
        
           |  |  | 17 |   | 
        
           | 32 | beyerle@PS | 18 | # set PATH
 | 
        
           |  |  | 19 | PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin"
 | 
        
           |  |  | 20 |   | 
        
           | 29 | beyerle@PS | 21 | # RPMs that are no longer needed and can break future udpates
 | 
        
           |  |  | 22 | RPMS_TO_REMOVE="kernel-module-squashfs \
 | 
        
           |  |  | 23 |                 kernel-module-unionfs \
 | 
        
           |  |  | 24 |                 unionfs \
 | 
        
           |  |  | 25 |                 squashfs"
 | 
        
           |  |  | 26 |   | 
        
           | 30 | beyerle@PS | 27 | # RPMs that can break future Scientific Linux updates
 | 
        
           | 29 | beyerle@PS | 28 | # because there are not part of Scientific Linux
 | 
        
           | 43 | beyerle@PS | 29 | RPMS_TO_REMOVE_SL="kernel-module-ntfs \
 | 
        
           |  |  | 30 |                    nvidia.*psi"
 | 
        
           | 29 | beyerle@PS | 31 |   | 
        
           | 30 | beyerle@PS | 32 | # RPMs that can break future PSI SL updates
 | 
        
           | 29 | beyerle@PS | 33 | # because there are not part of PSI Scientific Linux
 | 
        
           |  |  | 34 | RPMS_TO_REMOVE_PSI=""
 | 
        
           |  |  | 35 |   | 
        
           | 15 | beyerle@PS | 36 | # files which should be restored from .ori files
 | 
        
           |  |  | 37 | FILES_RESTORE="/etc/init.d/netfs \
 | 
        
           |  |  | 38 |            /etc/init.d/autofs \
 | 
        
           |  |  | 39 |            /etc/init.d/halt \
 | 
        
           |  |  | 40 |            /etc/init.d/network
 | 
        
           |  |  | 41 |            /etc/init.d/functions \
 | 
        
           |  |  | 42 |            /etc/rc.d/rc.sysinit \
 | 
        
           |  |  | 43 |            /etc/sysconfig/afs \
 | 
        
           |  |  | 44 |            /etc/motd \
 | 
        
           |  |  | 45 |            /etc/redhat-release \
 | 
        
           | 29 | beyerle@PS | 46 | 	   /etc/rc.d/rc.local"
 | 
        
           | 15 | beyerle@PS | 47 |   | 
        
           | 33 | beyerle@PS | 48 | # LiveCD init scripts will be removed
 | 
        
           | 16 | beyerle@PS | 49 | LIVECD_INIT_SCRIPTS="runfirst \
 | 
        
           |  |  | 50 |                     runveryfirst \
 | 
        
           |  |  | 51 |                     runlast \
 | 
        
           | 33 | beyerle@PS | 52 |                     kudzu-auto \
 | 
        
           |  |  | 53 |                     login"
 | 
        
           | 15 | beyerle@PS | 54 |   | 
        
           |  |  | 55 | # Main directories which should be not be copied
 | 
        
           | 16 | beyerle@PS | 56 | DIR_NOT_COPY="/proc \
 | 
        
           |  |  | 57 |               /dev \
 | 
        
           |  |  | 58 |               /livecd \
 | 
        
           |  |  | 59 |               /boot \
 | 
        
           |  |  | 60 |               /afs \
 | 
        
           |  |  | 61 |               /sys \
 | 
        
           |  |  | 62 |               /mnt \
 | 
        
           | 36 | beyerle@PS | 63 |               /media \
 | 
        
           |  |  | 64 |               /initrd"
 | 
        
           | 15 | beyerle@PS | 65 |   | 
        
           |  |  | 66 | # Mount point of the new SL system
 | 
        
           |  |  | 67 | NEW=/mnt/harddisk
 | 
        
           |  |  | 68 |   | 
        
           | 21 | beyerle@PS | 69 | # Name of the script
 | 
        
           | 15 | beyerle@PS | 70 | SCRIPTNAME=$( basename $0 )
 | 
        
           |  |  | 71 |   | 
        
           | 16 | beyerle@PS | 72 |   | 
        
           |  |  | 73 |   | 
        
           | 21 | beyerle@PS | 74 |   | 
        
           | 15 | beyerle@PS | 75 | ###############################################################
 | 
        
           |  |  | 76 | # Functions
 | 
        
           |  |  | 77 | ###############################################################
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 | function usage() {
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 |    ## Usage
 | 
        
           |  |  | 82 |    # ----------------------------------------------------------
 | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 |    cat <<EOF
 | 
        
           | 21 | beyerle@PS | 85 |   | 
        
           | 22 | beyerle@PS | 86 |   $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
 | 
        
           | 15 | beyerle@PS | 87 |   | 
        
           | 26 | beyerle@PS | 88 |     Installes LiveCD on PARTITION and the bootloader grub into 
 | 
        
           |  |  | 89 |     the Master Boot Record (MBR) of DEVICE. The MBR will be 
 | 
        
           |  |  | 90 |     backed up to PARTITION.
 | 
        
           | 15 | beyerle@PS | 91 |   | 
        
           | 21 | beyerle@PS | 92 |   OPTIONS:
 | 
        
           | 15 | beyerle@PS | 93 |   | 
        
           | 34 | beyerle@PS | 94 |     -h   --help       : Print this screen
 | 
        
           |  |  | 95 |     -swap=[partition] : Use [partition] as swap
 | 
        
           |  |  | 96 |     -win=[partition]  : Your active Windows partition. If not given, 
 | 
        
           | 22 | beyerle@PS | 97 |                         $SCRIPTNAME tries to find it
 | 
        
           | 34 | beyerle@PS | 98 |     -nogrub           : Do not install grub. You have to install 
 | 
        
           | 26 | beyerle@PS | 99 |                         manually a bootloader (not recommended)
 | 
        
           | 34 | beyerle@PS | 100 |     -floppy           : Needed, if grub should be installed on floppy
 | 
        
           | 31 | beyerle@PS | 101 |                         In this case use -mbr=/dev/fd0 -floppy
 | 
        
           | 34 | beyerle@PS | 102 |     -norpmremove      : Do not remove RPMs that can break future 
 | 
        
           |  |  | 103 |                         updates (not recommended)
 | 
        
           |  |  | 104 |     -y                : Answer all questions with yes
 | 
        
           | 15 | beyerle@PS | 105 |   | 
        
           | 21 | beyerle@PS | 106 |   Example:
 | 
        
           |  |  | 107 |   | 
        
           | 22 | beyerle@PS | 108 |   $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
 | 
        
           | 21 | beyerle@PS | 109 |   | 
        
           |  |  | 110 |     Will install LiveCD on /dev/sda2 (= second partition on 
 | 
        
           |  |  | 111 |     first SATA disk). All data on /dev/sda2 will be deleted.
 | 
        
           |  |  | 112 |     /dev/sda3 has to be a Linux Swap partion. GRUB will be 
 | 
        
           |  |  | 113 |     installed in the MBR of /dev/sda (= first SATA disk).
 | 
        
           |  |  | 114 |   | 
        
           | 31 | beyerle@PS | 115 |   Remarks:
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 |     To display your hard disk partitions, user 'fdisk -l'.
 | 
        
           |  |  | 118 |     Use fdisk, qtparted or parted to create an empty Linux
 | 
        
           |  |  | 119 |     partition.
 | 
        
           |  |  | 120 |   | 
        
           | 15 | beyerle@PS | 121 | EOF
 | 
        
           |  |  | 122 | }
 | 
        
           |  |  | 123 |   | 
        
           |  |  | 124 |   | 
        
           | 21 | beyerle@PS | 125 | function exit_now() {
 | 
        
           |  |  | 126 |   | 
        
           |  |  | 127 |     local exitcode=$1
 | 
        
           |  |  | 128 |     umount $INSTALL_PART 2>/dev/null
 | 
        
           |  |  | 129 |     exit $exitcode
 | 
        
           |  |  | 130 | }
 | 
        
           |  |  | 131 |   | 
        
           |  |  | 132 |   | 
        
           |  |  | 133 |   | 
        
           | 15 | beyerle@PS | 134 | ###############################################################
 | 
        
           |  |  | 135 | # Main
 | 
        
           |  |  | 136 | ###############################################################
 | 
        
           |  |  | 137 |   | 
        
           | 16 | beyerle@PS | 138 | ### are we root?
 | 
        
           |  |  | 139 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 140 | if [ "$( whoami )" != "root" ]; then
 | 
        
           | 31 | beyerle@PS | 141 |     echo; echo "Please run this script as root: 'su - -c $SCRIPTNAME'"; echo
 | 
        
           | 21 | beyerle@PS | 142 |     exit_now 1
 | 
        
           | 15 | beyerle@PS | 143 | fi
 | 
        
           |  |  | 144 |   | 
        
           | 16 | beyerle@PS | 145 |   | 
        
           | 15 | beyerle@PS | 146 | ### read options from command-line
 | 
        
           | 16 | beyerle@PS | 147 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 148 | while [ $# -gt 0 ]; do
 | 
        
           |  |  | 149 |   | 
        
           |  |  | 150 |     case "$1" in
 | 
        
           |  |  | 151 |        -h)
 | 
        
           | 21 | beyerle@PS | 152 |             usage; exit_now;;
 | 
        
           | 22 | beyerle@PS | 153 |   | 
        
           | 21 | beyerle@PS | 154 |        --help)
 | 
        
           |  |  | 155 |             usage; exit_now;;
 | 
        
           | 22 | beyerle@PS | 156 |   | 
        
           | 24 | beyerle@PS | 157 |        -swap*)
 | 
        
           | 22 | beyerle@PS | 158 |            if echo $1 | grep -q '=' ; then
 | 
        
           |  |  | 159 | 	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
 | 
        
           |  |  | 160 | 	   else
 | 
        
           |  |  | 161 | 	       shift
 | 
        
           | 24 | beyerle@PS | 162 |                SWAP_PART=$1
 | 
        
           | 22 | beyerle@PS | 163 | 	   fi
 | 
        
           | 34 | beyerle@PS | 164 | 	   ;;
 | 
        
           | 22 | beyerle@PS | 165 |   | 
        
           | 24 | beyerle@PS | 166 |        -mbr*)
 | 
        
           | 22 | beyerle@PS | 167 |            if echo $1 | grep -q '=' ; then
 | 
        
           |  |  | 168 | 	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
 | 
        
           |  |  | 169 | 	   else
 | 
        
           |  |  | 170 | 	       shift
 | 
        
           | 24 | beyerle@PS | 171 |                MBR_DEV=$1
 | 
        
           | 22 | beyerle@PS | 172 | 	   fi
 | 
        
           | 34 | beyerle@PS | 173 | 	   ;;
 | 
        
           | 22 | beyerle@PS | 174 |   | 
        
           | 24 | beyerle@PS | 175 |        -win*)
 | 
        
           | 22 | beyerle@PS | 176 |            if echo $1 | grep -q '=' ; then
 | 
        
           |  |  | 177 | 	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
 | 
        
           |  |  | 178 | 	   else
 | 
        
           |  |  | 179 | 	       shift
 | 
        
           | 24 | beyerle@PS | 180 |                WIN_PART=$1
 | 
        
           | 22 | beyerle@PS | 181 | 	   fi
 | 
        
           | 34 | beyerle@PS | 182 | 	   ;;
 | 
        
           | 22 | beyerle@PS | 183 |   | 
        
           | 16 | beyerle@PS | 184 |        -nogrub)
 | 
        
           | 34 | beyerle@PS | 185 |             NOGRUB=$1;;
 | 
        
           | 22 | beyerle@PS | 186 |   | 
        
           | 29 | beyerle@PS | 187 |        -norpmremove)
 | 
        
           | 34 | beyerle@PS | 188 |             NORPMREMOVE=$1;;
 | 
        
           | 29 | beyerle@PS | 189 |   | 
        
           | 18 | beyerle@PS | 190 |        -floppy)
 | 
        
           | 34 | beyerle@PS | 191 |             FLOPPY=$1;;
 | 
        
           | 22 | beyerle@PS | 192 |   | 
        
           | 15 | beyerle@PS | 193 |        -y)
 | 
        
           | 34 | beyerle@PS | 194 |             YES=$1;;
 | 
        
           | 15 | beyerle@PS | 195 |   | 
        
           |  |  | 196 |        *)
 | 
        
           | 34 | beyerle@PS | 197 |             INSTALL_PART=$1;;
 | 
        
           | 15 | beyerle@PS | 198 |     esac
 | 
        
           |  |  | 199 |   | 
        
           | 34 | beyerle@PS | 200 |     shift
 | 
        
           |  |  | 201 |   | 
        
           | 15 | beyerle@PS | 202 | done
 | 
        
           |  |  | 203 | echo
 | 
        
           |  |  | 204 |   | 
        
           | 16 | beyerle@PS | 205 |   | 
        
           | 28 | beyerle@PS | 206 | ### display fdisk -l
 | 
        
           |  |  | 207 | ### -----------------------------------------------------------
 | 
        
           |  |  | 208 | echo "Output of 'fdisk -l' ..."
 | 
        
           |  |  | 209 | fdisk -l
 | 
        
           |  |  | 210 | echo
 | 
        
           |  |  | 211 |   | 
        
           |  |  | 212 |   | 
        
           | 30 | beyerle@PS | 213 | ### test if $INSTALL_PART is defined
 | 
        
           | 22 | beyerle@PS | 214 | ### -----------------------------------------------------------
 | 
        
           |  |  | 215 | if [ ! $INSTALL_PART ]; then
 | 
        
           |  |  | 216 |     echo "No partition defined for installation"
 | 
        
           | 30 | beyerle@PS | 217 |     echo "Please see '$SCRIPTNAME -h'"; echo
 | 
        
           | 22 | beyerle@PS | 218 |     exit_now 1
 | 
        
           |  |  | 219 | fi
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 |   | 
        
           | 15 | beyerle@PS | 222 | ### test if MBR_DEV is given
 | 
        
           | 16 | beyerle@PS | 223 | ### -----------------------------------------------------------
 | 
        
           |  |  | 224 | if [ ! $NOGRUB ]; then
 | 
        
           |  |  | 225 |     if [ ! $MBR_DEV ]; then
 | 
        
           | 18 | beyerle@PS | 226 | 	echo "No MBR device defined."
 | 
        
           | 30 | beyerle@PS | 227 | 	echo "Please see '$SCRIPTNAME -h'"; echo
 | 
        
           | 21 | beyerle@PS | 228 | 	exit_now 1
 | 
        
           | 16 | beyerle@PS | 229 |     fi
 | 
        
           | 15 | beyerle@PS | 230 | fi
 | 
        
           |  |  | 231 |   | 
        
           | 16 | beyerle@PS | 232 |   | 
        
           | 15 | beyerle@PS | 233 | ### test if $INSTALL_PART exists
 | 
        
           | 16 | beyerle@PS | 234 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 235 | fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
 | 
        
           |  |  | 236 | if [ "$?" != "0" ]; then
 | 
        
           | 28 | beyerle@PS | 237 |     echo "Partition $INSTALL_PART not found! See 'fdisk -l'"
 | 
        
           | 30 | beyerle@PS | 238 |     echo "Or you have to reboot first to make the partition table active"; echo
 | 
        
           | 21 | beyerle@PS | 239 |     exit_now 1
 | 
        
           | 15 | beyerle@PS | 240 | fi
 | 
        
           |  |  | 241 |   | 
        
           | 16 | beyerle@PS | 242 |   | 
        
           | 30 | beyerle@PS | 243 | ### test if $INSTALL_PART is a Linux partition
 | 
        
           | 16 | beyerle@PS | 244 | ### -----------------------------------------------------------
 | 
        
           | 30 | beyerle@PS | 245 | fdisk -l | grep "Linux$" | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
 | 
        
           |  |  | 246 | if [ "$?" != "0" ]; then
 | 
        
           |  |  | 247 |     echo "Partition $INSTALL_PART is not a Linux partition! (see 'fdisk -l')"
 | 
        
           |  |  | 248 |     echo "Use fdisk and/or qtparted to create a Linux partition!"
 | 
        
           |  |  | 249 |     echo "You have to reboot first to make the partition table active"; echo
 | 
        
           |  |  | 250 |     exit_now 1
 | 
        
           |  |  | 251 | fi
 | 
        
           | 15 | beyerle@PS | 252 |   | 
        
           |  |  | 253 |   | 
        
           | 30 | beyerle@PS | 254 | ### test if $SWAP_PART exists and is a Linux Swap partition
 | 
        
           | 16 | beyerle@PS | 255 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 256 | if [ $SWAP_PART ]; then
 | 
        
           |  |  | 257 |     fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
 | 
        
           |  |  | 258 |     if [ "$?" != "0" ]; then
 | 
        
           | 28 | beyerle@PS | 259 | 	echo "Swap partition $SWAP_PART not found! (see 'fdisk -l')"
 | 
        
           |  |  | 260 | 	echo "Or you have to reboot first to make the partition table active"; echo
 | 
        
           | 21 | beyerle@PS | 261 | 	exit_now 1
 | 
        
           | 15 | beyerle@PS | 262 |     fi
 | 
        
           | 30 | beyerle@PS | 263 |     fdisk -l | grep "Linux swap$" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
 | 
        
           | 15 | beyerle@PS | 264 |     if [ "$?" != "0" ]; then
 | 
        
           | 28 | beyerle@PS | 265 | 	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'fdisk -l')"
 | 
        
           | 30 | beyerle@PS | 266 | 	echo "Use fdisk and/or qtparted to create a Linux Swap partition!"
 | 
        
           | 28 | beyerle@PS | 267 | 	echo "You have to reboot first to make the partition table active"; echo
 | 
        
           | 21 | beyerle@PS | 268 | 	exit_now 1
 | 
        
           | 15 | beyerle@PS | 269 |     fi
 | 
        
           |  |  | 270 | fi
 | 
        
           |  |  | 271 |   | 
        
           |  |  | 272 |   | 
        
           | 30 | beyerle@PS | 273 | ### set $INSTALL_DEV (eg. /dev/sda)
 | 
        
           | 16 | beyerle@PS | 274 | ### -----------------------------------------------------------
 | 
        
           | 30 | beyerle@PS | 275 | INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
 | 
        
           |  |  | 276 | INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
 | 
        
           |  |  | 277 |   | 
        
           |  |  | 278 |   | 
        
           |  |  | 279 | ### print warning
 | 
        
           |  |  | 280 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 281 | echo                     "------------------------------------------------------------"
 | 
        
           |  |  | 282 | echo                     "   LiveCD will be installed on partition $INSTALL_PART"
 | 
        
           | 15 | beyerle@PS | 283 | [ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
 | 
        
           | 26 | beyerle@PS | 284 | [ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
 | 
        
           |  |  | 285 | echo                     "       !! All data on $INSTALL_PART will be lost !!"
 | 
        
           |  |  | 286 | echo                     "------------------------------------------------------------"
 | 
        
           | 15 | beyerle@PS | 287 | echo
 | 
        
           | 16 | beyerle@PS | 288 |   | 
        
           | 15 | beyerle@PS | 289 |   | 
        
           | 26 | beyerle@PS | 290 | ### continue?
 | 
        
           | 16 | beyerle@PS | 291 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 292 | if [ ! $YES ]; then
 | 
        
           |  |  | 293 |     echo -n "Continue (y/N)? "
 | 
        
           | 18 | beyerle@PS | 294 |     read key
 | 
        
           | 15 | beyerle@PS | 295 |     echo
 | 
        
           | 21 | beyerle@PS | 296 |     [ "$key" != "y" ] && exit_now 0
 | 
        
           | 15 | beyerle@PS | 297 | fi
 | 
        
           |  |  | 298 |   | 
        
           |  |  | 299 |   | 
        
           | 26 | beyerle@PS | 300 | ### format $SWAP_PART
 | 
        
           | 21 | beyerle@PS | 301 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 302 | if [ $SWAP_PART ]; then
 | 
        
           |  |  | 303 |     echo "Make swap on $SWAP_PART ..."
 | 
        
           |  |  | 304 |     mkswap $SWAP_PART
 | 
        
           | 24 | beyerle@PS | 305 |     echo
 | 
        
           |  |  | 306 | fi
 | 
        
           | 21 | beyerle@PS | 307 |   | 
        
           |  |  | 308 |   | 
        
           | 15 | beyerle@PS | 309 | ### format $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 310 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 311 | echo -n "Format $INSTALL_PART, please wait ... " 
 | 
        
           | 21 | beyerle@PS | 312 | mkfs.ext3 -q $INSTALL_PART || exit_now 1
 | 
        
           | 15 | beyerle@PS | 313 | echo "done."; echo
 | 
        
           |  |  | 314 |   | 
        
           |  |  | 315 |   | 
        
           |  |  | 316 | ### mount $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 317 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 318 | echo -n "Try to mount $INSTALL_PART to $NEW ... "
 | 
        
           |  |  | 319 | mkdir -p $NEW
 | 
        
           | 21 | beyerle@PS | 320 | mount $INSTALL_PART $NEW || exit_now 1
 | 
        
           | 15 | beyerle@PS | 321 | echo "done."; echo
 | 
        
           |  |  | 322 |   | 
        
           |  |  | 323 |   | 
        
           |  |  | 324 | ### copy root dirs
 | 
        
           | 16 | beyerle@PS | 325 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 326 | echo "Copy Live System to $INSTALL_PART ..."
 | 
        
           | 15 | beyerle@PS | 327 | root_dirs=$( ls / )
 | 
        
           |  |  | 328 | for dir in $root_dirs; do
 | 
        
           |  |  | 329 |     # check if dir is not in $DIR_NOT_COPY
 | 
        
           |  |  | 330 |     do_not_copy=""
 | 
        
           |  |  | 331 |     for not_dir in $DIR_NOT_COPY; do
 | 
        
           |  |  | 332 | 	if [ "$not_dir" = "/$dir" ]; then 
 | 
        
           |  |  | 333 | 	    do_not_copy="yes"
 | 
        
           |  |  | 334 | 	    break
 | 
        
           |  |  | 335 | 	fi
 | 
        
           |  |  | 336 |     done
 | 
        
           |  |  | 337 |     # do not copy links
 | 
        
           |  |  | 338 |     [ -L /$dir ] && do_not_copy="yes"
 | 
        
           |  |  | 339 |   | 
        
           | 21 | beyerle@PS | 340 |     fail=""
 | 
        
           | 15 | beyerle@PS | 341 |     if [ ! $do_not_copy ]; then
 | 
        
           |  |  | 342 | 	echo -n "  * Copy  /$dir ... "
 | 
        
           | 21 | beyerle@PS | 343 | 	cp -a /$dir $NEW || fail=true
 | 
        
           | 15 | beyerle@PS | 344 | 	echo "done."
 | 
        
           |  |  | 345 |     fi
 | 
        
           |  |  | 346 | done
 | 
        
           |  |  | 347 | echo
 | 
        
           | 21 | beyerle@PS | 348 | if [ $fail ]; then
 | 
        
           |  |  | 349 |     echo "ERROR: Not everything was copied to $INSTALL_PART"
 | 
        
           |  |  | 350 |     exit_now 1
 | 
        
           |  |  | 351 | fi
 | 
        
           | 15 | beyerle@PS | 352 |   | 
        
           |  |  | 353 |   | 
        
           | 16 | beyerle@PS | 354 | ### move /usr/opt back to /opt
 | 
        
           |  |  | 355 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 356 | if [ -d $NEW/usr/opt ]; then
 | 
        
           |  |  | 357 |     echo -n "Move /opt back ... "
 | 
        
           |  |  | 358 |     mv $NEW/usr/opt $NEW/
 | 
        
           |  |  | 359 |     echo "done."; echo
 | 
        
           |  |  | 360 | fi
 | 
        
           |  |  | 361 |   | 
        
           |  |  | 362 |   | 
        
           |  |  | 363 | ### create dirs which were not copied
 | 
        
           | 16 | beyerle@PS | 364 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 365 | for dir in $DIR_NOT_COPY; do
 | 
        
           |  |  | 366 |     mkdir $NEW/$dir
 | 
        
           |  |  | 367 | done
 | 
        
           | 26 | beyerle@PS | 368 | # we do not need this directories
 | 
        
           |  |  | 369 | rmdir $NEW/livecd
 | 
        
           |  |  | 370 | # if not yet existing, create
 | 
        
           |  |  | 371 | mkdir -p $NEW/srv
 | 
        
           |  |  | 372 | mkdir -p $NEW/selinux
 | 
        
           | 15 | beyerle@PS | 373 |   | 
        
           |  |  | 374 |   | 
        
           |  |  | 375 | ### copy back original files
 | 
        
           | 16 | beyerle@PS | 376 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 377 | echo -n "Restore original files ... " 
 | 
        
           |  |  | 378 | for file in $FILES_RESTORE; do
 | 
        
           | 28 | beyerle@PS | 379 |     [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
 | 
        
           | 15 | beyerle@PS | 380 | done
 | 
        
           |  |  | 381 | echo "done."; echo
 | 
        
           |  |  | 382 |   | 
        
           |  |  | 383 |   | 
        
           | 16 | beyerle@PS | 384 | ### define kernel version
 | 
        
           |  |  | 385 | ### -----------------------------------------------------------
 | 
        
           |  |  | 386 | rpm --quiet -q kernel     && UP_installed=true
 | 
        
           |  |  | 387 | rpm --quiet -q kernel-smp && SMP_installed=true
 | 
        
           |  |  | 388 | [ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
 | 
        
           |  |  | 389 | [ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
 | 
        
           |  |  | 390 | if [ ! $KERNEL_VERSION ]; then
 | 
        
           |  |  | 391 |     echo "ERROR: Kernel version could not be determined - installation failed"; echo
 | 
        
           | 21 | beyerle@PS | 392 |     exit_now 1
 | 
        
           | 16 | beyerle@PS | 393 | fi    
 | 
        
           | 15 | beyerle@PS | 394 |   | 
        
           | 18 | beyerle@PS | 395 |   | 
        
           | 22 | beyerle@PS | 396 |   | 
        
           | 24 | beyerle@PS | 397 | if [ ! $NOGRUB ]; then
 | 
        
           | 15 | beyerle@PS | 398 |   | 
        
           | 26 | beyerle@PS | 399 |     ### Backup Master Boot Record MBR
 | 
        
           |  |  | 400 |     ### -----------------------------------------------------------
 | 
        
           |  |  | 401 |     if [ ! $NOGRUB ]; then
 | 
        
           |  |  | 402 | 	# do we have already a backup?
 | 
        
           |  |  | 403 | 	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
 | 
        
           |  |  | 404 | 	if [ ! -e /tmp/$MBR_FILENAME ]; then
 | 
        
           |  |  | 405 | 	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
 | 
        
           |  |  | 406 | 	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
 | 
        
           |  |  | 407 | 	fi
 | 
        
           |  |  | 408 | 	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
 | 
        
           |  |  | 409 | 	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
 | 
        
           |  |  | 410 | 	echo
 | 
        
           |  |  | 411 |     fi
 | 
        
           |  |  | 412 |   | 
        
           |  |  | 413 |   | 
        
           | 24 | beyerle@PS | 414 |     ### install grub
 | 
        
           |  |  | 415 |     ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 416 |     echo "Run grub-install ... "
 | 
        
           | 24 | beyerle@PS | 417 |     mkdir -p $NEW/boot/grub
 | 
        
           |  |  | 418 |     if [ $FLOPPY ]; then
 | 
        
           |  |  | 419 | 	grub-install --root-directory=$NEW $MBR_DEV
 | 
        
           |  |  | 420 |     else
 | 
        
           |  |  | 421 | 	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
 | 
        
           |  |  | 422 |     fi
 | 
        
           |  |  | 423 |     echo "done."; echo
 | 
        
           | 15 | beyerle@PS | 424 |   | 
        
           |  |  | 425 |   | 
        
           | 24 | beyerle@PS | 426 |     ### check for device.map file 
 | 
        
           |  |  | 427 |     ### -----------------------------------------------------------
 | 
        
           |  |  | 428 |     DEVICE_MAP=$NEW/boot/grub/device.map
 | 
        
           |  |  | 429 |     if [ ! -e $NEW/boot/grub/device.map ]; then
 | 
        
           |  |  | 430 | 	echo "ERROR: $NEW/boot/grub/device.map not found"
 | 
        
           |  |  | 431 | 	exit_now 1
 | 
        
           |  |  | 432 |     fi
 | 
        
           | 15 | beyerle@PS | 433 |   | 
        
           | 22 | beyerle@PS | 434 |   | 
        
           | 24 | beyerle@PS | 435 |     ### convert dev syntax to grub syntax
 | 
        
           |  |  | 436 |     ### -----------------------------------------------------------
 | 
        
           |  |  | 437 |     GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
 | 
        
           |  |  | 438 |     GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
 | 
        
           | 22 | beyerle@PS | 439 |   | 
        
           | 15 | beyerle@PS | 440 |   | 
        
           | 24 | beyerle@PS | 441 |     ### find active Windows partition
 | 
        
           |  |  | 442 |     ### -----------------------------------------------------------
 | 
        
           |  |  | 443 |     if [ ! $WIN_PART ]; then
 | 
        
           |  |  | 444 |         # try to find active Windows partition
 | 
        
           |  |  | 445 | 	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
 | 
        
           |  |  | 446 |     fi
 | 
        
           |  |  | 447 |   | 
        
           |  |  | 448 |     if [ $WIN_PART ]; then
 | 
        
           |  |  | 449 | 	WIN_installed=true
 | 
        
           |  |  | 450 | 	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
 | 
        
           |  |  | 451 | 	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
 | 
        
           |  |  | 452 |         # convert dev syntax to grub syntax
 | 
        
           |  |  | 453 | 	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
 | 
        
           |  |  | 454 | 	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
 | 
        
           |  |  | 455 |   | 
        
           |  |  | 456 |         # $GRUB_WIN_PART should be something like (hd0,0)
 | 
        
           |  |  | 457 | 	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
 | 
        
           |  |  | 458 | 	echo "Will add entry for Windows in GRUB."
 | 
        
           |  |  | 459 | 	echo
 | 
        
           |  |  | 460 |     fi
 | 
        
           |  |  | 461 |   | 
        
           |  |  | 462 |   | 
        
           |  |  | 463 |     ### create grub.conf file
 | 
        
           |  |  | 464 |     ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 465 |     echo "Create grub.conf ..."
 | 
        
           | 24 | beyerle@PS | 466 |   | 
        
           | 28 | beyerle@PS | 467 |     TITLE="Linux"
 | 
        
           |  |  | 468 |     [ -e $NEW//etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
 | 
        
           |  |  | 469 |   | 
        
           | 24 | beyerle@PS | 470 |     cat > $NEW/boot/grub/grub.conf <<EOF
 | 
        
           | 15 | beyerle@PS | 471 | # grub.conf generated by $SCRIPTNAME
 | 
        
           |  |  | 472 | default=0
 | 
        
           |  |  | 473 | timeout=5
 | 
        
           |  |  | 474 | splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
 | 
        
           |  |  | 475 | #hiddenmenu
 | 
        
           | 16 | beyerle@PS | 476 | EOF
 | 
        
           |  |  | 477 |   | 
        
           | 24 | beyerle@PS | 478 |     if [ $UP_installed ]; then
 | 
        
           | 26 | beyerle@PS | 479 | 	echo "Add entry for UP kernel into grub.conf"
 | 
        
           | 24 | beyerle@PS | 480 | 	cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           | 28 | beyerle@PS | 481 | title $TITLE (${KERNEL_VERSION})
 | 
        
           | 15 | beyerle@PS | 482 |         root $GRUB_ROOT_PART
 | 
        
           |  |  | 483 | 	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
 | 
        
           |  |  | 484 | 	initrd /boot/initrd-$KERNEL_VERSION.img
 | 
        
           | 16 | beyerle@PS | 485 | EOF
 | 
        
           | 24 | beyerle@PS | 486 |     fi
 | 
        
           | 16 | beyerle@PS | 487 |   | 
        
           | 24 | beyerle@PS | 488 |     if [ $SMP_installed ]; then
 | 
        
           | 26 | beyerle@PS | 489 | 	echo "Add entry for SMP kernel into grub.conf"
 | 
        
           | 24 | beyerle@PS | 490 | 	cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           | 28 | beyerle@PS | 491 | title $TITLE (${KERNEL_VERSION}smp)
 | 
        
           | 16 | beyerle@PS | 492 |         root $GRUB_ROOT_PART
 | 
        
           |  |  | 493 | 	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
 | 
        
           |  |  | 494 | 	initrd /boot/initrd-${KERNEL_VERSION}smp.img
 | 
        
           |  |  | 495 | EOF
 | 
        
           | 24 | beyerle@PS | 496 |     fi
 | 
        
           | 16 | beyerle@PS | 497 |   | 
        
           | 24 | beyerle@PS | 498 |     if [ $WIN_installed ]; then
 | 
        
           | 26 | beyerle@PS | 499 | 	echo "Add entry for Windows into grub.conf"
 | 
        
           | 24 | beyerle@PS | 500 | 	cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           | 15 | beyerle@PS | 501 | title Windows
 | 
        
           |  |  | 502 |         rootnoverify $GRUB_WIN_PART
 | 
        
           |  |  | 503 |         chainloader +1
 | 
        
           |  |  | 504 | EOF
 | 
        
           | 24 | beyerle@PS | 505 |     fi
 | 
        
           |  |  | 506 |   | 
        
           |  |  | 507 |     chmod 600 $NEW/boot/grub/grub.conf
 | 
        
           |  |  | 508 |     ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
 | 
        
           |  |  | 509 |     ln -s ./grub.conf $NEW/boot/grub/menu.lst
 | 
        
           |  |  | 510 |     echo "done."; echo
 | 
        
           |  |  | 511 |   | 
        
           | 16 | beyerle@PS | 512 | fi
 | 
        
           | 15 | beyerle@PS | 513 |   | 
        
           |  |  | 514 |   | 
        
           | 27 | beyerle@PS | 515 | ### install kernel and other files into /boot
 | 
        
           | 16 | beyerle@PS | 516 | ### -----------------------------------------------------------
 | 
        
           | 21 | beyerle@PS | 517 | echo "Install kernel(s) ..."
 | 
        
           | 15 | beyerle@PS | 518 |   | 
        
           | 16 | beyerle@PS | 519 | [ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
 | 
        
           |  |  | 520 | [ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
 | 
        
           | 15 | beyerle@PS | 521 |   | 
        
           | 16 | beyerle@PS | 522 | if [ ! $BOOT_DIR ]; then
 | 
        
           |  |  | 523 |     echo "ERROR: No kernel found - installation failed"; echo
 | 
        
           | 21 | beyerle@PS | 524 |     exit_now 1
 | 
        
           | 16 | beyerle@PS | 525 | fi
 | 
        
           |  |  | 526 |   | 
        
           |  |  | 527 | cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
 | 
        
           |  |  | 528 | cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
 | 
        
           |  |  | 529 | cp -a $BOOT_DIR/System.map-*       $NEW/boot/
 | 
        
           |  |  | 530 | cp -a $BOOT_DIR/config-*           $NEW/boot/
 | 
        
           | 26 | beyerle@PS | 531 | cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
 | 
        
           | 16 | beyerle@PS | 532 | cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
 | 
        
           | 26 | beyerle@PS | 533 | cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
 | 
        
           |  |  | 534 | cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
 | 
        
           |  |  | 535 |   | 
        
           | 16 | beyerle@PS | 536 | echo "done."; echo
 | 
        
           |  |  | 537 |   | 
        
           |  |  | 538 |   | 
        
           | 21 | beyerle@PS | 539 | ### create /etc/fstab
 | 
        
           | 16 | beyerle@PS | 540 | ### -----------------------------------------------------------
 | 
        
           | 21 | beyerle@PS | 541 | cat > $NEW/etc/fstab <<EOF
 | 
        
           |  |  | 542 | $INSTALL_PART         /                    ext3    defaults        1 1
 | 
        
           |  |  | 543 | devpts            /dev/pts             devpts  gid=5,mode=620  0 0
 | 
        
           |  |  | 544 | tmpfs             /dev/shm             tmpfs   defaults        0 0
 | 
        
           |  |  | 545 | proc              /proc                proc    defaults        0 0
 | 
        
           |  |  | 546 | sysfs             /sys                 sysfs   defaults        0 0
 | 
        
           |  |  | 547 | EOF
 | 
        
           |  |  | 548 | if [ $SWAP_PART ]; then
 | 
        
           |  |  | 549 |     echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
 | 
        
           |  |  | 550 | fi
 | 
        
           |  |  | 551 |   | 
        
           |  |  | 552 |   | 
        
           |  |  | 553 | ### make initrd 
 | 
        
           |  |  | 554 | ### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
 | 
        
           |  |  | 555 | ### -----------------------------------------------------------
 | 
        
           |  |  | 556 | echo "Create initrd(s) ..."
 | 
        
           | 22 | beyerle@PS | 557 | # initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
 | 
        
           |  |  | 558 | sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
 | 
        
           |  |  | 559 |   | 
        
           | 16 | beyerle@PS | 560 | if [ $UP_installed ]; then
 | 
        
           | 21 | beyerle@PS | 561 |     depmod -a ${KERNEL_VERSION}
 | 
        
           | 22 | beyerle@PS | 562 |     /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
 | 
        
           | 21 | beyerle@PS | 563 |                     $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
 | 
        
           | 18 | beyerle@PS | 564 |     if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
 | 
        
           |  |  | 565 | 	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
 | 
        
           | 21 | beyerle@PS | 566 | 	exit_now 1
 | 
        
           | 18 | beyerle@PS | 567 |     fi
 | 
        
           | 16 | beyerle@PS | 568 | fi
 | 
        
           |  |  | 569 | if [ $SMP_installed ]; then
 | 
        
           | 21 | beyerle@PS | 570 |     depmod -a ${KERNEL_VERSION}smp
 | 
        
           | 22 | beyerle@PS | 571 |     /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
 | 
        
           | 21 | beyerle@PS | 572 |                     $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
 | 
        
           | 18 | beyerle@PS | 573 |     if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
 | 
        
           |  |  | 574 | 	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
 | 
        
           | 21 | beyerle@PS | 575 | 	exit_now 1
 | 
        
           | 18 | beyerle@PS | 576 |     fi
 | 
        
           | 16 | beyerle@PS | 577 | fi
 | 
        
           |  |  | 578 | echo "done."; echo
 | 
        
           |  |  | 579 |   | 
        
           |  |  | 580 |   | 
        
           | 15 | beyerle@PS | 581 | ### remove LiveCD init.d scripts
 | 
        
           | 16 | beyerle@PS | 582 | ### -----------------------------------------------------------
 | 
        
           |  |  | 583 | for file in $LIVECD_INIT_SCRIPTS; do
 | 
        
           | 33 | beyerle@PS | 584 |     rm -f $NEW/etc/rc.d/init.d/$file
 | 
        
           | 16 | beyerle@PS | 585 |     for n in 0 1 2 3 4 5 6; do
 | 
        
           |  |  | 586 | 	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
 | 
        
           |  |  | 587 |     done
 | 
        
           | 15 | beyerle@PS | 588 | done
 | 
        
           |  |  | 589 |   | 
        
           | 16 | beyerle@PS | 590 |   | 
        
           |  |  | 591 | ### restore cronjobs
 | 
        
           |  |  | 592 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 593 | mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
 | 
        
           |  |  | 594 | mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
 | 
        
           |  |  | 595 | mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/
 | 
        
           | 16 | beyerle@PS | 596 |   | 
        
           |  |  | 597 |   | 
        
           | 29 | beyerle@PS | 598 | ### prepare chroot to $NEW
 | 
        
           |  |  | 599 | ### -----------------------------------------------------------
 | 
        
           |  |  | 600 | mount --bind /dev $NEW/dev
 | 
        
           |  |  | 601 | mount --bind /sys $NEW/sys
 | 
        
           |  |  | 602 | mount -t proc proc $NEW/proc
 | 
        
           |  |  | 603 |   | 
        
           |  |  | 604 |   | 
        
           | 18 | beyerle@PS | 605 | ### turn on kudzu again
 | 
        
           |  |  | 606 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 607 | chroot $NEW chkconfig kudzu on
 | 
        
           | 18 | beyerle@PS | 608 |   | 
        
           |  |  | 609 |   | 
        
           | 29 | beyerle@PS | 610 | ### remove RPMs that can break future updates  
 | 
        
           |  |  | 611 | ### -----------------------------------------------------------
 | 
        
           |  |  | 612 | if [ ! $NORPMREMOVE ]; then
 | 
        
           |  |  | 613 |     echo "Remove RPMs that may break future updates ..."
 | 
        
           |  |  | 614 |     chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
 | 
        
           |  |  | 615 |   | 
        
           |  |  | 616 |     # Scientific Linux RPMs
 | 
        
           |  |  | 617 |     RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
 | 
        
           |  |  | 618 |   | 
        
           |  |  | 619 |     # PSI Scientific Linux RPMs
 | 
        
           |  |  | 620 |     if [ -e /etc/sysconfig/cfengine ]; then
 | 
        
           |  |  | 621 | 	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
 | 
        
           |  |  | 622 |     fi
 | 
        
           |  |  | 623 |   | 
        
           |  |  | 624 |     for rpm in $RPMSTOREMOVE; do
 | 
        
           |  |  | 625 | 	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
 | 
        
           |  |  | 626 | 	for rpm_remove in $rpms_remove; do	
 | 
        
           |  |  | 627 | 	    chroot $NEW rpm -e --nodeps $rpm_remove 2>/dev/null
 | 
        
           |  |  | 628 | 	    [ "$?" = "0" ] && echo "$rpm_remove removed"
 | 
        
           |  |  | 629 | 	done
 | 
        
           |  |  | 630 |     done
 | 
        
           |  |  | 631 |     echo "done."; echo
 | 
        
           |  |  | 632 | fi
 | 
        
           |  |  | 633 |   | 
        
           |  |  | 634 |   | 
        
           | 43 | beyerle@PS | 635 | ### disable nvidia driver 
 | 
        
           |  |  | 636 | ### -----------------------------------------------------------
 | 
        
           |  |  | 637 | # not in case of a PSI installation
 | 
        
           |  |  | 638 | if [ ! -e /etc/sysconfig/cfengine ]; then
 | 
        
           |  |  | 639 |     if [ -e $new/etc/X11/xorg.conf.nv_SAVED ]; then
 | 
        
           |  |  | 640 |         # copy back original xorg.conf
 | 
        
           |  |  | 641 | 	mv $new/etc/X11/xorg.conf.nv_SAVED $new/etc/X11/xorg.conf
 | 
        
           |  |  | 642 |         # disable nvidia libs
 | 
        
           |  |  | 643 | 	LIB=lib
 | 
        
           |  |  | 644 | 	[ $( arch ) = "x86_64" ] && LIB=lib64
 | 
        
           |  |  | 645 | 	mv $new/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia $new/usr/X11R6/$LIB/modules/extensions/libGLcore.a
 | 
        
           |  |  | 646 | 	mv $new/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia $new/usr/X11R6/$LIB/modules/extensions/libglx.a
 | 
        
           |  |  | 647 | 	rm -f $new/usr/X11R6/$LIB/libGL.so*
 | 
        
           |  |  | 648 | 	rm -f $new/usr/$LIB/libGLcore.so
 | 
        
           |  |  | 649 |     fi
 | 
        
           |  |  | 650 | fi
 | 
        
           |  |  | 651 |   | 
        
           |  |  | 652 |   | 
        
           | 15 | beyerle@PS | 653 | ### umount $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 654 | ### -----------------------------------------------------------
 | 
        
           | 29 | beyerle@PS | 655 | umount $NEW/dev
 | 
        
           |  |  | 656 | umount $NEW/sys
 | 
        
           |  |  | 657 | umount $NEW/proc
 | 
        
           | 16 | beyerle@PS | 658 | umount $INSTALL_PART
 | 
        
           | 15 | beyerle@PS | 659 |   | 
        
           | 22 | beyerle@PS | 660 |   | 
        
           |  |  | 661 | ### print summary
 | 
        
           |  |  | 662 | ### -----------------------------------------------------------
 | 
        
           | 26 | beyerle@PS | 663 | echo                     "--------------------------------------------------------------"
 | 
        
           |  |  | 664 | echo                     "  LiveCD installed on partition $INSTALL_PART"
 | 
        
           |  |  | 665 | [ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
 | 
        
           | 22 | beyerle@PS | 666 | echo
 | 
        
           | 28 | beyerle@PS | 667 | [ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
 | 
        
           |  |  | 668 | [ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
 | 
        
           | 26 | beyerle@PS | 669 | [ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
 | 
        
           |  |  | 670 | [ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
 | 
        
           |  |  | 671 | echo 
 | 
        
           |  |  | 672 | [ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
 | 
        
           |  |  | 673 | echo                     "--------------------------------------------------------------"
 | 
        
           |  |  | 674 | echo                     "End of $SCRIPTNAME"
 | 
        
           |  |  | 675 | echo
 |