| 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 |   | 
        
           |  |  | 18 | # files which should be restored from .ori files
 | 
        
           |  |  | 19 | FILES_RESTORE="/etc/init.d/netfs \
 | 
        
           |  |  | 20 |            /etc/init.d/autofs \
 | 
        
           |  |  | 21 |            /etc/init.d/halt \
 | 
        
           |  |  | 22 |            /etc/init.d/network
 | 
        
           |  |  | 23 |            /etc/init.d/functions \
 | 
        
           |  |  | 24 |            /etc/rc.d/rc.sysinit \
 | 
        
           |  |  | 25 |            /etc/sysconfig/afs \
 | 
        
           |  |  | 26 |            /etc/motd \
 | 
        
           |  |  | 27 |            /etc/redhat-release \
 | 
        
           | 16 | beyerle@PS | 28 | 	   /etc/rc.d/rc.local \
 | 
        
           | 15 | beyerle@PS | 29 |            /etc/rc.d/rc.sysinit"
 | 
        
           |  |  | 30 |   | 
        
           | 16 | beyerle@PS | 31 | LIVECD_INIT_SCRIPTS="runfirst \
 | 
        
           |  |  | 32 |                     runveryfirst \
 | 
        
           |  |  | 33 |                     runlast \
 | 
        
           |  |  | 34 |                     kudzu-auto"
 | 
        
           | 15 | beyerle@PS | 35 |   | 
        
           |  |  | 36 | # Main directories which should be not be copied
 | 
        
           | 16 | beyerle@PS | 37 | DIR_NOT_COPY="/proc \
 | 
        
           |  |  | 38 |               /dev \
 | 
        
           |  |  | 39 |               /livecd \
 | 
        
           |  |  | 40 |               /boot \
 | 
        
           |  |  | 41 |               /afs \
 | 
        
           |  |  | 42 |               /sys \
 | 
        
           |  |  | 43 |               /mnt \
 | 
        
           |  |  | 44 |               /media"
 | 
        
           | 15 | beyerle@PS | 45 |   | 
        
           |  |  | 46 | # Mount point of the new SL system
 | 
        
           |  |  | 47 | NEW=/mnt/harddisk
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | SCRIPTNAME=$( basename $0 )
 | 
        
           |  |  | 50 |   | 
        
           | 16 | beyerle@PS | 51 |   | 
        
           |  |  | 52 |   | 
        
           | 15 | beyerle@PS | 53 | ###############################################################
 | 
        
           |  |  | 54 | # Functions
 | 
        
           |  |  | 55 | ###############################################################
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 | function usage() {
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |    ## Usage
 | 
        
           |  |  | 60 |    # ----------------------------------------------------------
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 |    cat <<EOF
 | 
        
           |  |  | 63 |   | 
        
           | 16 | beyerle@PS | 64 |    $SCRIPTNAME [OPTIONS] -mbr [DEVICE] [PARTITION]
 | 
        
           | 15 | beyerle@PS | 65 |   | 
        
           | 16 | beyerle@PS | 66 |    Installes LiveCD on PARTITION and the boot loader grub
 | 
        
           |  |  | 67 |    into the Master Boot Record (MBR) of DEVICE.
 | 
        
           | 15 | beyerle@PS | 68 |   | 
        
           |  |  | 69 |    OPTIONS:
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |     -h                  print this screen
 | 
        
           |  |  | 72 |     -swap [partition]  	use [partition] as swap
 | 
        
           | 16 | beyerle@PS | 73 |     -nogrub             do not install grub
 | 
        
           | 15 | beyerle@PS | 74 |     -y                  answer all questions with yes
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 | EOF
 | 
        
           |  |  | 77 | }
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |   | 
        
           |  |  | 80 | ###############################################################
 | 
        
           |  |  | 81 | # Main
 | 
        
           |  |  | 82 | ###############################################################
 | 
        
           |  |  | 83 |   | 
        
           | 16 | beyerle@PS | 84 | ### are we root?
 | 
        
           |  |  | 85 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 86 | if [ "$( whoami )" != "root" ]; then
 | 
        
           |  |  | 87 |     echo "Please run this script as root."
 | 
        
           |  |  | 88 |     # exit 1
 | 
        
           |  |  | 89 | fi
 | 
        
           |  |  | 90 |   | 
        
           | 16 | beyerle@PS | 91 |   | 
        
           | 15 | beyerle@PS | 92 | ### read options from command-line
 | 
        
           | 16 | beyerle@PS | 93 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 94 | while [ $# -gt 0 ]; do
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 |     case "$1" in
 | 
        
           |  |  | 97 |        -h)
 | 
        
           |  |  | 98 |             usage; exit;;
 | 
        
           |  |  | 99 |        -swap)
 | 
        
           |  |  | 100 |             shift; SWAP_PART=$1; shift; continue;;
 | 
        
           |  |  | 101 |        -mbr)
 | 
        
           |  |  | 102 |             shift; MBR_DEV=$1; shift; continue;;
 | 
        
           | 16 | beyerle@PS | 103 |        -nogrub)
 | 
        
           |  |  | 104 |             NOGRUB=$1; shift; continue;;
 | 
        
           | 15 | beyerle@PS | 105 |        -y)
 | 
        
           |  |  | 106 |             YES=$1; shift; continue;;
 | 
        
           |  |  | 107 |   | 
        
           |  |  | 108 |        *)
 | 
        
           |  |  | 109 |             INSTALL_PART=$1; break;;
 | 
        
           |  |  | 110 |     esac
 | 
        
           |  |  | 111 |   | 
        
           |  |  | 112 | done
 | 
        
           |  |  | 113 | echo
 | 
        
           |  |  | 114 |   | 
        
           | 16 | beyerle@PS | 115 |   | 
        
           | 15 | beyerle@PS | 116 | ### test if MBR_DEV is given
 | 
        
           | 16 | beyerle@PS | 117 | ### -----------------------------------------------------------
 | 
        
           |  |  | 118 | if [ ! $NOGRUB ]; then
 | 
        
           |  |  | 119 |     if [ ! $MBR_DEV ]; then
 | 
        
           |  |  | 120 | 	echo "No MBR device defined - where should grub be installed?"
 | 
        
           |  |  | 121 | 	echo "Please see '$SCRIPTNAME -h'."; echo
 | 
        
           |  |  | 122 | 	exit 1
 | 
        
           |  |  | 123 |     fi
 | 
        
           | 15 | beyerle@PS | 124 | fi
 | 
        
           |  |  | 125 |   | 
        
           | 16 | beyerle@PS | 126 |   | 
        
           | 15 | beyerle@PS | 127 | ### test if $INSTALL_PART defined and exists
 | 
        
           | 16 | beyerle@PS | 128 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 129 | if [ ! $INSTALL_PART ]; then
 | 
        
           |  |  | 130 |     echo "No partition defined for installation"
 | 
        
           |  |  | 131 |     echo "Please see '$SCRIPTNAME -h'."; echo
 | 
        
           |  |  | 132 |     exit 1
 | 
        
           |  |  | 133 | fi
 | 
        
           |  |  | 134 |   | 
        
           | 16 | beyerle@PS | 135 |   | 
        
           | 15 | beyerle@PS | 136 | ### test if $INSTALL_PART exists
 | 
        
           | 16 | beyerle@PS | 137 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 138 | fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
 | 
        
           |  |  | 139 | if [ "$?" != "0" ]; then
 | 
        
           |  |  | 140 |     echo "Partition $INSTALL_PART not found! (see 'disk -l')"; echo
 | 
        
           |  |  | 141 |     exit 1
 | 
        
           |  |  | 142 | fi
 | 
        
           |  |  | 143 |   | 
        
           | 16 | beyerle@PS | 144 |   | 
        
           | 15 | beyerle@PS | 145 | ### set $INSTALL_DEV (eg. /dev/sda)
 | 
        
           | 16 | beyerle@PS | 146 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 147 | INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
 | 
        
           |  |  | 148 | INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
 | 
        
           |  |  | 149 |   | 
        
           |  |  | 150 |   | 
        
           |  |  | 151 | ### test if $SWAP_PART exists
 | 
        
           | 16 | beyerle@PS | 152 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 153 | if [ $SWAP_PART ]; then
 | 
        
           |  |  | 154 |     fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
 | 
        
           |  |  | 155 |     if [ "$?" != "0" ]; then
 | 
        
           |  |  | 156 | 	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
 | 
        
           |  |  | 157 | 	exit 1
 | 
        
           |  |  | 158 |     fi
 | 
        
           |  |  | 159 |     fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
 | 
        
           |  |  | 160 |     if [ "$?" != "0" ]; then
 | 
        
           |  |  | 161 | 	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"; echo
 | 
        
           |  |  | 162 | 	exit 1
 | 
        
           |  |  | 163 |     fi
 | 
        
           |  |  | 164 | fi
 | 
        
           |  |  | 165 |   | 
        
           |  |  | 166 |   | 
        
           |  |  | 167 | ### print warning
 | 
        
           | 16 | beyerle@PS | 168 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 169 | echo "-----------------------------------------------------------"
 | 
        
           |  |  | 170 | echo "   LiveCD will be installed on partition $INSTALL_PART."
 | 
        
           |  |  | 171 | [ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
 | 
        
           | 16 | beyerle@PS | 172 |   | 
        
           | 15 | beyerle@PS | 173 | echo
 | 
        
           | 16 | beyerle@PS | 174 | [ ! $NOGRUB ] && echo " !! Master Boot Record of $MBR_DEV will be overwritten !!"
 | 
        
           |  |  | 175 |   | 
        
           | 15 | beyerle@PS | 176 | echo "     !! All data on $INSTALL_PART will be lost !!"
 | 
        
           |  |  | 177 | echo "-----------------------------------------------------------"
 | 
        
           |  |  | 178 | echo
 | 
        
           |  |  | 179 |   | 
        
           |  |  | 180 |   | 
        
           |  |  | 181 | ### continue ?
 | 
        
           | 16 | beyerle@PS | 182 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 183 | if [ ! $YES ]; then
 | 
        
           |  |  | 184 |     echo -n "Continue (y/N)? "
 | 
        
           |  |  | 185 |     read -n 1 key
 | 
        
           |  |  | 186 |     echo
 | 
        
           |  |  | 187 |     [ "$key" != "y" ] && exit 0
 | 
        
           |  |  | 188 | fi
 | 
        
           |  |  | 189 | echo
 | 
        
           |  |  | 190 |   | 
        
           |  |  | 191 |   | 
        
           |  |  | 192 | ### format $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 193 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 194 | echo -n "Format $INSTALL_PART, please wait ... " 
 | 
        
           |  |  | 195 | mkfs.ext3 -q $INSTALL_PART || exit 1
 | 
        
           |  |  | 196 | echo "done."; echo
 | 
        
           |  |  | 197 |   | 
        
           |  |  | 198 |   | 
        
           |  |  | 199 | ### mount $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 200 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 201 | echo -n "Try to mount $INSTALL_PART to $NEW ... "
 | 
        
           |  |  | 202 | mkdir -p $NEW
 | 
        
           |  |  | 203 | mount $INSTALL_PART $NEW || exit 1
 | 
        
           |  |  | 204 | echo "done."; echo
 | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 |   | 
        
           |  |  | 207 | ### copy root dirs
 | 
        
           | 16 | beyerle@PS | 208 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 209 | echo "Copy Live System to $INSTALL_PART:"
 | 
        
           |  |  | 210 | root_dirs=$( ls / )
 | 
        
           |  |  | 211 | for dir in $root_dirs; do
 | 
        
           |  |  | 212 |     # check if dir is not in $DIR_NOT_COPY
 | 
        
           |  |  | 213 |     do_not_copy=""
 | 
        
           |  |  | 214 |     for not_dir in $DIR_NOT_COPY; do
 | 
        
           |  |  | 215 | 	if [ "$not_dir" = "/$dir" ]; then 
 | 
        
           |  |  | 216 | 	    do_not_copy="yes"
 | 
        
           |  |  | 217 | 	    break
 | 
        
           |  |  | 218 | 	fi
 | 
        
           |  |  | 219 |     done
 | 
        
           |  |  | 220 |     # do not copy links
 | 
        
           |  |  | 221 |     [ -L /$dir ] && do_not_copy="yes"
 | 
        
           |  |  | 222 |   | 
        
           |  |  | 223 |     if [ ! $do_not_copy ]; then
 | 
        
           |  |  | 224 | 	echo -n "  * Copy  /$dir ... "
 | 
        
           |  |  | 225 | 	cp -a /$dir $NEW
 | 
        
           |  |  | 226 | 	echo "done."
 | 
        
           |  |  | 227 |     fi
 | 
        
           |  |  | 228 | done
 | 
        
           |  |  | 229 | echo
 | 
        
           |  |  | 230 |   | 
        
           |  |  | 231 |   | 
        
           | 16 | beyerle@PS | 232 | ### move /usr/opt back to /opt
 | 
        
           |  |  | 233 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 234 | if [ -d $NEW/usr/opt ]; then
 | 
        
           |  |  | 235 |     echo -n "Move /opt back ... "
 | 
        
           |  |  | 236 |     mv $NEW/usr/opt $NEW/
 | 
        
           |  |  | 237 |     echo "done."; echo
 | 
        
           |  |  | 238 | fi
 | 
        
           |  |  | 239 |   | 
        
           |  |  | 240 |   | 
        
           |  |  | 241 | ### create dirs which were not copied
 | 
        
           | 16 | beyerle@PS | 242 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 243 | for dir in $DIR_NOT_COPY; do
 | 
        
           |  |  | 244 |     mkdir $NEW/$dir
 | 
        
           |  |  | 245 | done
 | 
        
           |  |  | 246 | rmdir $NEW/livecd $NEW/mnt
 | 
        
           |  |  | 247 |   | 
        
           |  |  | 248 |   | 
        
           |  |  | 249 | ### copy back original files
 | 
        
           | 16 | beyerle@PS | 250 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 251 | echo -n "Restore original files ... " 
 | 
        
           |  |  | 252 | for file in $FILES_RESTORE; do
 | 
        
           |  |  | 253 |     [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
 | 
        
           |  |  | 254 | done
 | 
        
           |  |  | 255 | echo "done."; echo
 | 
        
           |  |  | 256 |   | 
        
           |  |  | 257 |   | 
        
           | 16 | beyerle@PS | 258 | ### do some mounts for chroot $NEW
 | 
        
           |  |  | 259 | ### -----------------------------------------------------------
 | 
        
           |  |  | 260 | mount --bind /dev $NEW/dev
 | 
        
           |  |  | 261 | mount --bind /sys $NEW/sys 
 | 
        
           |  |  | 262 | mount -t proc proc $NEW/proc
 | 
        
           | 15 | beyerle@PS | 263 |   | 
        
           |  |  | 264 |   | 
        
           | 16 | beyerle@PS | 265 | ### install grub
 | 
        
           |  |  | 266 | ### -----------------------------------------------------------
 | 
        
           |  |  | 267 | echo "Run grub-install: "; echo
 | 
        
           |  |  | 268 | mkdir -p $NEW/boot/grub
 | 
        
           | 15 | beyerle@PS | 269 | grub-install --root-directory=$NEW $MBR_DEV
 | 
        
           |  |  | 270 | echo "done."; echo
 | 
        
           |  |  | 271 |   | 
        
           |  |  | 272 |   | 
        
           | 16 | beyerle@PS | 273 | ### define kernel version
 | 
        
           |  |  | 274 | ### -----------------------------------------------------------
 | 
        
           |  |  | 275 | rpm --quiet -q kernel     && UP_installed=true
 | 
        
           |  |  | 276 | rpm --quiet -q kernel-smp && SMP_installed=true
 | 
        
           |  |  | 277 | [ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
 | 
        
           |  |  | 278 | [ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
 | 
        
           |  |  | 279 | if [ ! $KERNEL_VERSION ]; then
 | 
        
           |  |  | 280 |     echo "ERROR: Kernel version could not be determined - installation failed"; echo
 | 
        
           |  |  | 281 |     exit 1
 | 
        
           |  |  | 282 | fi    
 | 
        
           | 15 | beyerle@PS | 283 |   | 
        
           | 16 | beyerle@PS | 284 | ### convert dev syntax to grub syntax
 | 
        
           |  |  | 285 | ### -----------------------------------------------------------
 | 
        
           |  |  | 286 | device_map=$NEW/boot/grub/device.map
 | 
        
           |  |  | 287 | GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $device_map | awk '{ print $1 }' )
 | 
        
           |  |  | 288 | GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
 | 
        
           | 15 | beyerle@PS | 289 |   | 
        
           |  |  | 290 |   | 
        
           | 16 | beyerle@PS | 291 | ### define active Windows partition -  to be fixed  !!!
 | 
        
           |  |  | 292 | ### -----------------------------------------------------------
 | 
        
           |  |  | 293 | WIN_installed=true
 | 
        
           |  |  | 294 | GRUB_WIN_PART=(hd0,0)
 | 
        
           | 15 | beyerle@PS | 295 |   | 
        
           |  |  | 296 |   | 
        
           |  |  | 297 | ### create grub.conf file
 | 
        
           | 16 | beyerle@PS | 298 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 299 | echo "Create grub.conf"
 | 
        
           |  |  | 300 |   | 
        
           |  |  | 301 | cat > $NEW/boot/grub/grub.conf <<EOF
 | 
        
           |  |  | 302 | # grub.conf generated by $SCRIPTNAME
 | 
        
           |  |  | 303 | default=0
 | 
        
           |  |  | 304 | timeout=5
 | 
        
           |  |  | 305 | splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
 | 
        
           |  |  | 306 | #hiddenmenu
 | 
        
           | 16 | beyerle@PS | 307 | EOF
 | 
        
           |  |  | 308 |   | 
        
           |  |  | 309 | if [ $UP_installed ]; then
 | 
        
           |  |  | 310 |     cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           |  |  | 311 | title Scientific Linux (${KERNEL_VERSION})
 | 
        
           | 15 | beyerle@PS | 312 |         root $GRUB_ROOT_PART
 | 
        
           |  |  | 313 | 	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
 | 
        
           |  |  | 314 | 	initrd /boot/initrd-$KERNEL_VERSION.img
 | 
        
           | 16 | beyerle@PS | 315 | EOF
 | 
        
           |  |  | 316 | fi
 | 
        
           |  |  | 317 |   | 
        
           |  |  | 318 | if [ $SMP_installed ]; then
 | 
        
           |  |  | 319 |     cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           |  |  | 320 | title Scientific Linux (${KERNEL_VERSION}smp)
 | 
        
           |  |  | 321 |         root $GRUB_ROOT_PART
 | 
        
           |  |  | 322 | 	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
 | 
        
           |  |  | 323 | 	initrd /boot/initrd-${KERNEL_VERSION}smp.img
 | 
        
           |  |  | 324 | EOF
 | 
        
           |  |  | 325 | fi
 | 
        
           |  |  | 326 |   | 
        
           |  |  | 327 | if [ $WIN_installed ]; then
 | 
        
           |  |  | 328 |     cat >> $NEW/boot/grub/grub.conf <<EOF
 | 
        
           | 15 | beyerle@PS | 329 | title Windows
 | 
        
           |  |  | 330 |         rootnoverify $GRUB_WIN_PART
 | 
        
           |  |  | 331 |         chainloader +1
 | 
        
           |  |  | 332 | EOF
 | 
        
           | 16 | beyerle@PS | 333 | fi
 | 
        
           | 15 | beyerle@PS | 334 |   | 
        
           |  |  | 335 | chmod 600 $NEW/boot/grub/grub.conf
 | 
        
           |  |  | 336 | ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
 | 
        
           |  |  | 337 | ln -s ./grub.conf $NEW/boot/grub/menu.lst
 | 
        
           |  |  | 338 | echo "done."; echo
 | 
        
           |  |  | 339 |   | 
        
           |  |  | 340 |   | 
        
           | 16 | beyerle@PS | 341 | ### install kernel into /boot
 | 
        
           |  |  | 342 | ### -----------------------------------------------------------
 | 
        
           |  |  | 343 | echo "Install kernel(s)"
 | 
        
           | 15 | beyerle@PS | 344 |   | 
        
           | 16 | beyerle@PS | 345 | [ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
 | 
        
           |  |  | 346 | [ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
 | 
        
           | 15 | beyerle@PS | 347 |   | 
        
           | 16 | beyerle@PS | 348 | if [ ! $BOOT_DIR ]; then
 | 
        
           |  |  | 349 |     echo "ERROR: No kernel found - installation failed"; echo
 | 
        
           |  |  | 350 |     exit 1
 | 
        
           |  |  | 351 | fi
 | 
        
           |  |  | 352 |   | 
        
           |  |  | 353 | cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
 | 
        
           |  |  | 354 | cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
 | 
        
           |  |  | 355 | cp -a $BOOT_DIR/System.map-*       $NEW/boot/
 | 
        
           |  |  | 356 | cp -a $BOOT_DIR/config-*           $NEW/boot/
 | 
        
           |  |  | 357 | cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
 | 
        
           |  |  | 358 | echo "done."; echo
 | 
        
           |  |  | 359 |   | 
        
           |  |  | 360 |   | 
        
           |  |  | 361 | ### make initrd
 | 
        
           |  |  | 362 | ### -----------------------------------------------------------
 | 
        
           |  |  | 363 | echo "Create initrd(s)"
 | 
        
           |  |  | 364 | if [ $UP_installed ]; then
 | 
        
           |  |  | 365 |     chroot $NEW \
 | 
        
           |  |  | 366 |     /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install ${KERNEL_VERSION}
 | 
        
           |  |  | 367 | fi
 | 
        
           |  |  | 368 | if [ $SMP_installed ]; then
 | 
        
           |  |  | 369 |     chroot $NEW \
 | 
        
           |  |  | 370 |     /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install ${KERNEL_VERSION}smp
 | 
        
           |  |  | 371 | fi
 | 
        
           |  |  | 372 | echo "done."; echo
 | 
        
           |  |  | 373 |   | 
        
           |  |  | 374 |   | 
        
           | 15 | beyerle@PS | 375 | ### create /etc/fstab
 | 
        
           | 16 | beyerle@PS | 376 | ### -----------------------------------------------------------
 | 
        
           | 15 | beyerle@PS | 377 | cat > $NEW/etc/fstab <<EOF
 | 
        
           |  |  | 378 | $INSTALL_PART         /                    ext3    defaults        1 1
 | 
        
           |  |  | 379 | devpts            /dev/pts             devpts  gid=5,mode=620  0 0
 | 
        
           |  |  | 380 | tmpfs             /dev/shm             tmpfs   defaults        0 0
 | 
        
           |  |  | 381 | proc              /proc                proc    defaults        0 0
 | 
        
           |  |  | 382 | sysfs             /sys                 sysfs   defaults        0 0
 | 
        
           |  |  | 383 | EOF
 | 
        
           |  |  | 384 |   | 
        
           |  |  | 385 | if [ $SWAP_PART ]; then
 | 
        
           |  |  | 386 |     echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
 | 
        
           |  |  | 387 | fi
 | 
        
           |  |  | 388 |   | 
        
           |  |  | 389 |   | 
        
           |  |  | 390 | ### remove LiveCD init.d scripts
 | 
        
           | 16 | beyerle@PS | 391 | ### -----------------------------------------------------------
 | 
        
           |  |  | 392 | for file in $LIVECD_INIT_SCRIPTS; do
 | 
        
           |  |  | 393 |     rm -f $NEW/etc/init.d/$file
 | 
        
           |  |  | 394 |     for n in 0 1 2 3 4 5 6; do
 | 
        
           |  |  | 395 | 	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
 | 
        
           |  |  | 396 |     done
 | 
        
           | 15 | beyerle@PS | 397 | done
 | 
        
           |  |  | 398 |   | 
        
           | 16 | beyerle@PS | 399 |   | 
        
           |  |  | 400 | ### restore cronjobs
 | 
        
           |  |  | 401 | ### -----------------------------------------------------------
 | 
        
           |  |  | 402 | mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
 | 
        
           |  |  | 403 | mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
 | 
        
           |  |  | 404 | mv /etc/cron_backup/* /etc/cron.daily/
 | 
        
           |  |  | 405 |   | 
        
           |  |  | 406 |   | 
        
           | 15 | beyerle@PS | 407 | ### umount $INSTALL_PART
 | 
        
           | 16 | beyerle@PS | 408 | ### -----------------------------------------------------------
 | 
        
           |  |  | 409 | umount $NEW/dev
 | 
        
           |  |  | 410 | umount $NEW/sys 
 | 
        
           |  |  | 411 | umount $NEW/proc
 | 
        
           |  |  | 412 | umount $INSTALL_PART
 | 
        
           | 15 | beyerle@PS | 413 |   |