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