diff options
Diffstat (limited to 'scripts/install-system')
-rw-r--r--[-rwxr-xr-x] | scripts/install-system | 586 |
1 files changed, 490 insertions, 96 deletions
diff --git a/scripts/install-system b/scripts/install-system index a704d4a7..9980e210 100755..100644 --- a/scripts/install-system +++ b/scripts/install-system @@ -30,6 +30,7 @@ if [ -e /etc/default/vyatta ] ; then . /etc/default/vyatta fi + : ${vyatta_prefix:=/opt/vyatta} : ${vyatta_exec_prefix:=$vyatta_prefix} : ${vyatta_bindir:=${vyatta_exec_prefix}/bin} @@ -40,6 +41,9 @@ ofrconfdir=${vyatta_sysconfdir}/config fdconfdir=/media/floppy/config rootfsdir=/mnt/rootfs +# By default this is not a union install +# UNION=false + # install log file name INSTALL_LOG="install.log" # root partition minimum size in MB @@ -201,12 +205,227 @@ probe_drives () { done } + +warn_of_dire_consequences () { + # Give the user a requisite warning that we are about to nuke their drive + response='' + while [ -z $response ] + do + echo "This will destroy all data on /dev/$INSTALL_DRIVE." + echo -n "Continue? (Yes/No) [No]: " + response=$(get_response "No" "Yes No Y N") + + if [ "$response" == "no" ] || [ "$response" == "n" ]; then + echo "Ok then. Exiting..." + exit 1 + fi + done +} + + + +check_for_old_raid () { + # First, trigger construction of previously configured RAID groups + echo -n "Looking for pre-existing RAID groups..." + raid_config=`mdadm --examine --scan` + if [ -z "$raid_config" ]; then + echo "none found." + return + fi + + echo "found some." + echo "Trying to configure pre-existing RAID groups..." + mdadm --assemble --scan --auto=yes --symlink=no + + # Identify physical drives + raid_drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | grep "md" | egrep -v "^$") + + if [ -z "$raid_drives" ]; then + echo "Unable to configure any RAID groups." + return + fi + + numraids=`echo $raid_drives | wc -w` + + if [ $numraids -eq 1 ]; then + echo "The following RAID group is now configured:" + else + echo "The following RAID groups are now configured:" + fi + + for drive in $raid_drives + do + cat /proc/mdstat | grep --after-context 2 ^$drive | sed -e 's/^/\t/' + done + + if [ $numraids -eq 1 ]; then + echo -n "Would you like to use this one? (Yes/No) [Yes]:" + else + echo -n "Would you like to use one of these? (Yes/No) [Yes]:" + fi + + response=$(get_response "Yes" "Yes No Y N") + if [ "$response" == "no" ] || [ "$response" == "n" ]; then + echo "Ok. Not using existing RAID groups." + echo "Stopping existing RAID groups:" + mdadm --stop --scan + return + fi + + if [ $numraids -eq 1 ]; then + INSTALL_DRIVE=$raid_drives + else + # take the first drive as the default + INSTALL_DRIVE=$(echo $raid_drives | /usr/bin/awk '{ print $1 }') + echo -n "Which one would you like to use? ($raid_drives) [$INSTALL_DRIVE]: " + INSTALL_DRIVE=$(get_response "$INSTALL_DRIVE" "$drives") + fi + + echo "Using RAID partition $INSTALL_DRIVE" + + warn_of_dire_consequences + + ROOT_PARTITION=$INSTALL_DRIVE + + # make sure we aren't working on a mounted part + unmount "$INSTALL_DRIVE" + + # check for an old config on the partition + check_config_partition "$ROOT_PARTITION" + + # create the ext3 fs on the part + make_filesystem "$ROOT_PARTITION" + + INSTALL_METHOD=RAID +} + +check_for_new_raid () { + # Identify physical drives + drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]$" | egrep -v "^$") + + numdrives=`echo $drives | wc -w` + + if [ $numdrives -ne 2 ]; then + # debug + echo "check_for_new_raid: don't have 2 drives" + return + fi + + drive1=`echo $drives | awk '{ print $1 }'` + drive2=`echo $drives | awk '{ print $2 }'` + + drivesize1=$(get_drive_size $drive1) + drivesize2=$(get_drive_size $drive2) + + if [ $drivesize1 -ne $drivesize2 ]; then + # debug + echo "check_for_new_raid: have 2 drives, but different sizes" + return + fi + + echo "You have two identical disk drives:" + echo -e "\t$drive1 \t$drivesize1 MB" + echo -e "\t$drive2 \t$drivesize2 MB" + + echo -n "Would you like to configure RAID-1 mirroring on them? (Yes/No) [Yes]:" + response=$(get_response "Yes" "Yes No Y N") + if [ "$response" == "no" ] || [ "$response" == "n" ]; then + echo "Ok. Not configuring RAID-1." + return + fi + + # Configure RAID-1 + echo "This process will erase all data on both drives." + echo -n "Are you sure you want to do this? (Yes/No) [No]: " + response=$(get_response "Yes" "Yes No Y N") + if [ "$response" == "no" ] || [ "$response" == "n" ]; then + echo "Ok. Not configuring RAID-1." + return + fi + + for drive in $drives + do + echo "Deleting old partitions on drive $drive" + # remove any existing partitions on that drive + delete_partitions "$drive" + done + + # Need to leave space on both disks between the MBR and the start + # of the first partition for grub. Grub needs to embed a large + # boot image there when booting off RAID devices. + # + # Partition creation variables are in units of megabytes. + part_start_offset=2 + part_diag_size=60 + + echo "Would you like me to create a $part_diag_size MB partition for diagnostics?" + echo -n "(Yes/No) [No]: " + diag_response=$(get_response "No" "Yes No Y N") + if [ "$diag_response" == "yes" ] || [ "$diag_response" == "y" ]; then + for drive in $drives + do + echo "Creating diag partition on drive $drive" + create_partitions "$drive" $part_diag_size $part_start_offset "no" + sfdisk --change-id /dev/$drive 1 0x6 + done + data_dev=2 + let part_start_offset+=$part_diag_size + else + data_dev=1 + fi + + for drive in $drives + do + echo "Creating data partition: /dev/${drive}${data_dev}" + size=$(get_drive_size $drive) + let size-=$part_start_offset + create_partitions "$drive" $size $part_start_offset "no" + sfdisk --change-id /dev/$drive $data_dev 0xfd + done + + # Must give partition device time to settle + sleep 5 + echo + + for drive in $drives + do + echo "Erasing any previous RAID metadata that may exist on /dev/${drive}${data_dev}" + mdadm --zero-superblock /dev/${drive}${data_dev} + done + + echo "Creating RAID-1 group on partitions: /dev/${drive1}${data_dev} /dev/${drive2}${data_dev}" + + raid_dev=md0 + mdadm --create /dev/$raid_dev --level=1 --raid-disks=2 /dev/${drive1}${data_dev} /dev/${drive2}${data_dev} + + if [ $? = 0 -a -e /dev/$raid_dev ]; then + echo "RAID-1 group created successfully:" + cat /proc/mdstat | grep --after-context 2 ^$raid_dev | sed -e 's/^/\t/' + else + echo "Unable to create RAID-1 group!" + return + fi + + INSTALL_DRIVE=$raid_dev + ROOT_PARTITION=$INSTALL_DRIVE + + # Give device time to settle... + sleep 5 + + # create the ext3 fs on the part + make_filesystem "$ROOT_PARTITION" + + INSTALL_METHOD=RAID +} + + # Takes an argument to display text before choice # Sets INSTALL_DRIVE. Note that select_drive should be wrapped # in the verification loop, not the included get_response. select_drive () { # list the drives in /proc/partitions. Remove partitions and empty lines. - drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]$" | egrep -v "^$") + # the first grep pattern looks for devices named c0d0, hda, and sda. + drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "c[0-9]d[0-9]$|[hs]d[a-z]$" | egrep -v "^$") # take the first drive as the default INSTALL_DRIVE=$(echo $drives | /usr/bin/awk '{ print $1 }') @@ -219,12 +438,16 @@ select_drive () { display="$display $drive\t$size"MB"\n" done - # Display the drives and ask the user which one to install to - echo -e "$display" - echo - echo -n "$1 [$INSTALL_DRIVE]:" + while true + do + # Display the drives and ask the user which one to install to + echo -e "$display" + echo + echo -n "$1 [$INSTALL_DRIVE]:" + response=$(get_response "$INSTALL_DRIVE" "$drives") && break + done + INSTALL_DRIVE="$response" - INSTALL_DRIVE=$(get_response "$INSTALL_DRIVE" "$drives") echo # Assume no dma if the disk is smaller than 10G (such as a CF drive) @@ -241,6 +464,7 @@ select_drive () { select_partition () { minsize=$1 text=$2 + exclude=$3 echo -n "Looking for appropriate partitions: " progress_indicator start @@ -251,13 +475,28 @@ select_partition () { # list only the partitions in /proc/partitions. parts=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 " "} }' | egrep "[0-9]" | egrep -v "loop" | tr -d '\n') + # remove any partitions we have already previously used + if [ -n "$exclude" ]; then + for part in $parts; + do + temp=$(echo $part | egrep -v $exclude) + parts_temp="$parts_temp $temp" + done + parts=$parts_temp + fi + # Get the partition sizes for display # only show linux partitions that have sizes, i.e. remove loops display='' + myparts='' for part in $parts do - rootdev=$(echo $part | sed 's/[0-9]//g') - parttype=$(fdisk -l /dev/$rootdev | grep $part | grep Linux) + if [ ${part:0:2} = "md" ]; then + parttype="RAID" + else + rootdev=$(echo $part | sed 's/[0-9]//g') + parttype=$(fdisk -l /dev/$rootdev | grep $part | grep Linux) + fi if [ -n "$parttype" ]; then lsize=$(get_drive_size $part) if [ "$lsize" -a $lsize -ge $minsize ]; then @@ -352,7 +591,8 @@ delete_partitions () { ldrive=$1 # get the partitions on the drive - partitions=$(cat /proc/partitions | grep $ldrive[0-9] | awk '{ print $4 }' | sed 's/[a-z]//g') + # in the first grep below we add the optional [p] in order to accomdate cciss drives + partitions=$(cat /proc/partitions | grep $ldrive[p]*[0-9] | awk '{ print $4 }' | sed 's/\(.*\)\([0-9]$\)/\2/g' | grep -v "^$") # now for each part, blow it away for part in $partitions @@ -386,7 +626,7 @@ make_filesystem () { status=$? if [ "$status" != 0 ]; then echo -e "Error: couldn't create the root filesystem.\nSee $INSTALL_LOG for further details.\nExiting..." - echo -e "Error: couldn't create the root filesystem.\n/sbin/mke2fs -j /dev/$lDRIVE\n$output" + echo -e "Error: couldn't create the root filesystem.\n/sbin/mke2fs -j /dev/$ldrive\n$output" exit 1 fi progress_indicator stop @@ -400,6 +640,8 @@ make_filesystem () { create_partitions() { ldrive=$1 root_part_size=$2 + start_offset=$3 + initialize_fs=$4 # Make sure there is enough space on drive size=$(get_drive_size "$ldrive") @@ -411,7 +653,7 @@ create_partitions() { echo "Creating root partition on /dev/$ldrive" >> $INSTALL_LOG # make the root partition - output=$(parted /dev/$ldrive mkpart primary 0 $root_part_size) + output=$(parted /dev/$ldrive mkpart primary $start_offset $root_part_size) status=$? if [ "$status" != 0 ]; then echo -e "Error creating primary partition on $ldrive.\nPlease see $INSTALL_LOG for more details.\nExiting..." @@ -419,21 +661,31 @@ create_partitions() { exit 1 fi - ROOT_PARTITION=$ldrive"1" + # set the partition number on the device. + if [ -n "$( echo $ldrive | grep cciss )" ]; then + # if this is a cciss + ROOT_PARTITION=$ldrive"p1" + else + # else... the rest of the world + ROOT_PARTITION=$ldrive"1" + fi # udev takes time to re-add the device file, so wait for it while [ ! -b "/dev/$ROOT_PARTITION" ] do sleep 1 done - # make the root and config ext3 file systems. - make_filesystem "$ROOT_PARTITION" + if [ "$initialize_fs" = "yes" ]; then + # make the root and config ext3 file systems. + make_filesystem "$ROOT_PARTITION" + fi } # Install the root filesystem # $1 is the partition to install on install_root_filesystem () { ldrive=$1 + version=$(egrep -i version /opt/vyatta/etc/version | awk '{ print $3 }') dpkg="/usr/bin/dpkg --force-all --root=$rootfsdir" echo "Mounting /dev/$ldrive " @@ -452,49 +704,69 @@ install_root_filesystem () { exit 1 fi - echo -n "Copying system image files to /dev/$ROOT_PARTITION: " - progress_indicator start - # Mount the squashfs for copying - output=$(mkdir -p /mnt/squashfs) - output=$(mount /live/image/live/filesystem.squashfs /mnt/squashfs -t squashfs -o loop) - status=$? + if [ -z $UNION ]; then + echo -n "Copying system image files to /dev/$ROOT_PARTITION: " + progress_indicator start + # Mount the squashfs for copying + output=$(mkdir -p /mnt/squashfs) + if [ -f /live/image/live/filesystem.squashfs ]; then + output=$(mount /live/image/live/filesystem.squashfs /mnt/squashfs -t squashfs -o loop) + status=$? + elif [ -f /live/image/boot/$version/$version.squashfs ]; then + output=$(mount /live/image/boot/$version/$version.squashfs /mnt/squashfs -t squashfs -o loop) + status=$? + else + echo -e "Error: Unable to find a squash image. \nExiting..." + fi - if [ "$status" != 0 ]; then - echo -e "Error trying to mount the squashfs.\nPlease see install log for more details.\nExiting..." - echo -e "Error trying to mount the squashfs.\nmount /live/image/live/filesystem.squashfs /mnt/squashfs -t squashfs -o loop\n$output" >> $INSTALL_LOG - exit 1 - fi + if [ "$status" != 0 ]; then + echo -e "Error trying to mount the squashfs.\nPlease see install log for more details.\nExiting..." + echo -e "Error trying to mount the squashfs.\nmount /live/image/live/filesystem.squashfs /mnt/squashfs -t squashfs -o loop\n$output" >> $INSTALL_LOG + exit 1 + fi - output=$(cp -pR /mnt/squashfs/* $rootfsdir/) - status=$? + output=$(cp -pR /mnt/squashfs/* $rootfsdir/) + status=$? - if [ "$status" != 0 ]; then - echo -e "Error trying to copy the rootfs.\nPlease see install log for more details.\nExiting. -.." - echo -e "Error trying to copy the rootfs.\ncp -pR /mnt/squashfs/* $rootfsdir/\n$output" >> $INSTALL_LOG - exit 1 - fi + if [ "$status" != 0 ]; then + echo -e "Error trying to copy the rootfs.\nPlease see install log for more details.\nExiting..." + echo -e "Error trying to copy the rootfs.\ncp -pR /mnt/squashfs/* $rootfsdir/\n$output" >> $INSTALL_LOG + exit 1 + fi - # unmount the squashfs. No big deal if it fails. - output=$(umount /mnt/squashfs) + # unmount the squashfs. No big deal if it fails. + output=$(umount /mnt/squashfs) - # create the fstab - local rootdev="/dev/$ROOT_PARTITION"; - uuid=$(dumpe2fs -h $rootdev 2>/dev/null | awk '/^Filesystem UUID/ {print $3}') - if [ -z "$uuid" ] - then - echo "Unable to read filesystem UUID. Exiting." - exit 1 - else - echo -e "UUID=$uuid\t/\text3\tdefaults\t0 1" >> $rootfsdir/etc/fstab - fi + # create the fstab + local rootdev="/dev/$ROOT_PARTITION"; + uuid=$(dumpe2fs -h $rootdev 2>/dev/null | awk '/^Filesystem UUID/ {print $3}') + if [ -z "$uuid" ] + then + echo "Unable to read filesystem UUID. Exiting." + exit 1 + else + echo -e "UUID=$uuid\t/\text3\tdefaults\t0 1" >> $rootfsdir/etc/fstab + fi - #setup the hostname file - cp /etc/hostname $rootfsdir/etc/ - cp /etc/hosts $rootfsdir/etc/ + #setup the hostname file + cp /etc/hostname $rootfsdir/etc/ + cp /etc/hosts $rootfsdir/etc/ - progress_indicator stop - echo "OK" + progress_indicator stop + echo "OK" + else + mkdir -p $rootfsdir/boot/$version + if [ -f /live/image/live/filesystem.squashfs ]; then + echo Copying squashfs image... + cp /live/image/live/filesystem.squashfs $rootfsdir/boot/$version/$version.squashfs + echo Copying kernel and initrd images... + cp -ar /boot/initrd.img-* $rootfsdir/boot/$version/ + cp -ar /boot/vmlinuz-* $rootfsdir/boot/$version/ + else + echo Copying image files... + cp -ar /live/image/boot/$version $rootfsdir/boot/ + fi + fi } # copy the configuration to the config partition @@ -565,9 +837,23 @@ copy_config () { change_password() { local user=$1 - local pwd - read pwd - local epwd=$(mkpasswd -H md5 $pwd | sed 's:/:\\/:g') + local pwd1="1" + local pwd2="2" + + until [ "$pwd1" == "$pwd2" ] + do + read -p "Enter $user password:" -r -s pwd1 <>/dev/tty 1>&0 + echo + read -p "Retype $user password:" -r -s pwd2 <>/dev/tty 1>&0 + echo + + if [ "$pwd1" != "$pwd2" ] + then echo "Passwords do not match" + fi + done + + # escape any slashes in resulting password + local epwd=$(mkpasswd -H md5 "$pwd1" | sed 's:/:\\/:g') sed -i \ -e "/ user $user {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$epwd\"/" \ @@ -579,9 +865,7 @@ system_setup () { local response=$(get_response "Yes" "Yes No Y N") if [ "$response" == "yes" ] || [ "$response" == "y" ]; then - echo -n 'System administrator (root) password: ' change_password root - echo -n 'Router administrator (vyatta) password: ' change_password vyatta fi } @@ -589,10 +873,12 @@ system_setup () { # setup grub on the boot sector of a user queried drive install_grub () { - orig_install_drive="$INSTALL_DRIVE" # we now use INSTALL_DRIVE to reference the grub boot drive. # that way I can re-use select_drive. I'm lazy that way. - INSTALL_DRIVE='' + + if [ ${INSTALL_DRIVE:0:2} != "md" ]; then + INSTALL_DRIVE='' + fi mkdir -p $rootfsdir/boot/grub # Let the user choose the boot sector @@ -609,7 +895,7 @@ install_grub () { # Install grub in the boot sector of the primary drive progress_indicator start - grub-install --no-floppy --root-directory=$rootfsdir /dev/$INSTALL_DRIVE >>$INSTALL_LOG 2>&1 + grub-install --no-floppy --recheck --root-directory=$rootfsdir /dev/$INSTALL_DRIVE >>$INSTALL_LOG 2>&1 progress_indicator stop # Assume no dma if the disk is smaller than 10G (such as a CF drive) @@ -619,7 +905,23 @@ install_grub () { grub_options="ide=nodma" fi - if /opt/vyatta/sbin/grub-setup "$ROOT_PARTITION" "$grub_options" /mnt/rootfs >>$INSTALL_LOG + # Check if using aufs + if grep -q aufs /proc/filesystems + then + if [ -z "$grub_options" ] + then + grub_options="union=aufs" + else + grub_options="$grub_options union=aufs" + fi + fi + + # if union install tell vyatta-grub-setup + if [ ! -z $UNION ]; then + version=$(egrep -i version /opt/vyatta/etc/version | awk '{ print $3 }') + grub_args="-u $version" + fi + if /opt/vyatta/sbin/vyatta-grub-setup $grub_args "$ROOT_PARTITION" "$grub_options" /mnt/rootfs >>$INSTALL_LOG then echo "OK" else @@ -639,7 +941,7 @@ setup_method_manual() { echo -e "\n\n" # if this is parted, let the user create the partitions - if [ "$method" == "parted" ] || [ "$method" == "p" ]; then + if [ "$INSTALL_METHOD" == "parted" ] || [ "$INSTALL_METHOD" == "p" ]; then while [ -z "$INSTALL_DRIVE" ] do # TODO: right now we only run parted on a single drive @@ -678,10 +980,15 @@ setup_method_manual() { make_filesystem "$ROOT_PARTITION" # We need to set the INSTALL_DRIVE if it wasn't set when the user ran parted - # We assume that we will use the boot sector of the same drive that the partition is on + # We assume that we will use the boot sector of the same drive that the + # partition is on. # TODO: Allow different drives to function as the boot device if [ -z "$INSTALL_DRIVE" ]; then - INSTALL_DRIVE=$(echo $ROOT_PARTITION | sed 's/[0-9]//g') + if [ ${ROOT_PARTITION:0:2} = "md" ]; then + INSTALL_DRIVE=$ROOT_PARTITION + else + INSTALL_DRIVE=$(echo $ROOT_PARTITION | sed 's/[0-9]//g') + fi fi } @@ -709,19 +1016,7 @@ setup_method_auto() { fi done - # Give the user a requisite warning that we are about to nuke their drive - response='' - while [ -z $response ] - do - echo "This will destroy all data on /dev/$INSTALL_DRIVE." - echo -n "Continue? (Yes/No) [No]: " - response=$(get_response "No" "Yes No Y N") - - if [ "$response" == "no" ] || [ "$response" == "n" ]; then - echo "Ok then. Exiting..." - exit 1 - fi - done + warn_of_dire_consequences echo @@ -750,7 +1045,74 @@ setup_method_auto() { echo # now take the data and create the partitions - create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" + create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" 0 "yes" +} + +# walk the user through a union setup +# sets globals INSTALL_DRIVE, ROOT_PARTITION, CONFIG_PARTITION +setup_method_union() { + UNION=1 + + echo "A union install requires an image partition of at least 250mbs." + echo "If you want to accomodate more than one image on the partition," + echo "it should be larger. Each image is roughly 200mbs. This " + echo "partition will be the bootable partition for this machine." + echo + + # Ask for the image partition and make sure it's valid + while [ -z "$ROOT_PARTITION" ] + do + select_partition 250 "Which partition should I install the images on?" + # Note that PARTITION is defined in select partition + ROOT_PARTITION=$PARTITION + unmount "$ROOT_PARTITION" + vd=$(grep $ROOT_PARTITION /proc/partitions | awk '{ print $4 }') + + if [ -z "$vd" ]; then + echo + echo "$ROOT_PARTITION is an invalid partition. Please try again." + ROOT_PARTITION="" + fi + done + + echo Creating filesystem on $ROOT_PARTITION + make_filesystem $ROOT_PARTITION + + echo + echo "An optional writable persistent root partition may also" + echo "be created. This partition will allow you to store " + echo "files between reboots and upgrade packages." + echo + echo -n "Would you like to create a persistent root partition? (Yes/No) [Yes]: " + response=$(get_response "Yes" "Yes No Y N") + if [ "$response" == "yes" ] || [ "$response" == "y" ]; then + echo "The persistent root partition should be a minimum of 50mbs" + echo "for log files. If you plan on adding any other software or" + echo "upgrading it, the root partition should be large enough to" + echo "accomodate those packages" + + # Ask for the union partition and make sure it's valid + while [ -z "$UNION_PARTITION" ] + do + select_partition 50 "Which partition should I install the binary images on?" "$ROOT_PARTITION" + # Note that PARTITION is defined in select partition + UNION_PARTITION=$PARTITION + unmount "$UNION_PARTITION" + vd=$(grep $UNION_PARTITION /proc/partitions | awk '{ print $4 }') + + if [ -z "$vd" ]; then + echo + echo "$UNION_PARTITION is an invalid partition. Please try again." + UNION_PARTITION="" + fi + done + + echo Creating filesystems on $ROOT_PARTITION + make_filesystem $UNION_PARTITION + + echo Labeling $UNION_PARTITION + e2label /dev/$UNION_PARTITION live-rw + fi } unmount () { @@ -859,37 +1221,60 @@ probe_drives progress_indicator stop echo "OK" -echo "The Vyatta image will require a minimum ${ROOT_MIN}MB root." -echo "Would you like me to try to partition a drive automatically" -echo "or would you rather partition it manually with parted? If" -echo "you have already setup your partitions, you may skip this step." -echo +INSTALL_METHOD='' +check_for_old_raid +if [ -z "$INSTALL_METHOD" ]; then + check_for_new_raid +fi -method='' -while [ -z $method ] -do - echo -n "Partition (Auto/Parted/Skip) [Auto]: " - method=$(get_response "Auto" "Auto Parted Skip A P S") -done +if [ -z "$INSTALL_METHOD" ]; then + echo "The Vyatta image will require a minimum ${ROOT_MIN}MB root." + echo "Would you like me to try to partition a drive automatically" + echo "or would you rather partition it manually with parted? If" + echo "you have already setup your partitions, you may skip this step." + echo -echo + while [ -z $INSTALL_METHOD ] + do + echo -n "Partition (Auto/Union/Parted/Skip) [Auto]: " + INSTALL_METHOD=$(get_response "Auto" "Auto Parted Skip Union A P S U") + done + + echo +fi # TODO: Note installs assume an LBA BIOS. So no boot partition currently. # also note that we are not creating a swap partition right now. -if [ "$method" == "parted" ] || [ "$method" == "p" ]; then +if [ "$INSTALL_METHOD" == "parted" ] || [ "$INSTALL_METHOD" == "p" ]; then setup_method_manual "parted" -elif [ "$method" == "skip" ] || [ "$method" == "s" ]; then +elif [ "$INSTALL_METHOD" == "skip" ] || [ "$INSTALL_METHOD" == "s" ]; then setup_method_manual "skip" -elif [ "$method" == "auto" ] || [ "$method" == "a" ]; then +elif [ "$INSTALL_METHOD" == "auto" ] || [ "$INSTALL_METHOD" == "a" ]; then + setup_method_auto +elif [ "$INSTALL_METHOD" == "union" ] || [ "$INSTALL_METHOD" == "u" ]; then + echo "A union install requires an image partition of at least 250mbs." + echo "If you want to accomodate more than one image on the partition," + echo "it should be larger. Each image is roughly 200mbs. This " + echo "partition will be the bootable partition for this machine." + echo + + UNION=1 setup_method_auto -elif [ "$method" == "vyatta" ]; then +elif [ "$INSTALL_METHOD" == "vyatta" ]; then echo "Automated install..." echo "unmounting $INSTALL_DRIVE" unmount "$INSTALL_DRIVE" echo "deleting partitions on $INSTALL_DRIVE" delete_partitions "$INSTALL_DRIVE" echo "creating config partition" - create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" + create_partitions "$INSTALL_DRIVE" "$ROOT_PARTITION_SIZE" 0 "yes" +fi + +if [ ! -d /live/image -o -w /live/image ]; then + if [ -z $UNION ]; then + echo "install-system can only be run from livecd" + exit 1 + fi fi # Install the root filesystem @@ -910,9 +1295,18 @@ setup_xen_partition_images # Install grub install_grub -# Fix up PAM configuration for login so that invalid users are prompted -# for password -sed -i 's/requisite[ \t][ \t]*pam_securetty.so/required pam_securetty.so/' $rootfsdir/etc/pam.d/login +if [ -z $UNION ]; then + # Fix up PAM configuration for login so that invalid users are prompted + # for password + sed -i 's/requisite[ \t][ \t]*pam_securetty.so/required pam_securetty.so/' $rootfsdir/etc/pam.d/login +fi + +# postinst hook +if [ -e /opt/vyatta/etc/install-system/postinst ]; then + echo "running post-install script" + /opt/vyatta/etc/install-system/postinst $rootfsdir >>$INSTALL_LOG +fi + cp $INSTALL_LOG $rootfsdir/install.log |