diff options
Diffstat (limited to 'scripts/install')
-rwxr-xr-x | scripts/install/install-functions | 20 | ||||
-rwxr-xr-x | scripts/install/install-get-partition | 64 | ||||
-rwxr-xr-x | scripts/install/install-image | 2 | ||||
-rwxr-xr-x | scripts/install/install-image-existing | 23 | ||||
-rwxr-xr-x | scripts/install/install-image-new | 11 | ||||
-rwxr-xr-x | scripts/install/install-postinst-new | 30 |
6 files changed, 58 insertions, 92 deletions
diff --git a/scripts/install/install-functions b/scripts/install/install-functions index 1551fbb0..d241e040 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -43,9 +43,6 @@ CD_SQUASH_ROOT=/mnt/cdsquash VYATTA_CFG_DIR=${vyatta_sysconfdir}/config VYATTA_NEW_CFG_DIR=/config -# the floppy config dir -FD_CFG_DIR=/media/floppy/config - # PROGRESS_PID can be exported by top-level script progress_indicator () { local spid=$PROGRESS_PID @@ -274,7 +271,7 @@ is_live_cd_boot () # Poor check, but whatever. The point is that on installed system # the image file normally is named after the current version, # while on livecd it's just "filesystem.squashfs" - if grep -q -e '^overlayfs.*/filesystem.squashfs' /proc/mounts; then + if grep -q -e '^overlay.*/filesystem.squashfs' /proc/mounts; then return 0 else return 1 @@ -287,8 +284,8 @@ is_union_install () if is_live_cd_boot; then return 1 fi - if grep -q ' /live/image [^ ]\+ rw' /proc/mounts \ - && egrep -q '(union|overlay)fs / (union|overlay)fs ' /proc/mounts; then + if grep -q 'upperdir=/live/persistence/' /proc/mounts \ + && egrep -q 'overlay / overlay ' /proc/mounts; then return 0 else return 1 @@ -298,7 +295,7 @@ is_union_install () # outputs the version string of the current running version. get_cur_version () { - ver=`dpkg-query --showformat='${Version}' --show vyatta-version` + ver=`cat /opt/vyatta/etc/version | awk '{print $2}'` if [ -z "$ver" ]; then echo "UNKNOWN" else @@ -323,7 +320,7 @@ get_new_version () ver_file=${ver_path} if is_live_cd_boot && [ -f "$ver_file" ]; then # we are installing from a live CD boot - ver=`dpkg-query --showformat='${Version}' --show vyatta-version` + ver=`cat /opt/vyatta/etc/version | awk '{print $2}'` echo $ver return fi @@ -337,11 +334,12 @@ gen_mopts () local mnttype=$1 local upper=$2 local lower=$3 - local mntpoint=$4 + local work=$4 + local mntpoint=$5 case "$1" in - overlayfs) - echo "-t $mnttype -o noatime,upperdir=$upper,lowerdir=$lower $mnttype $mntpoint" + overlay) + echo "-t $mnttype -o noatime,upperdir=$upper,lowerdir=$lower,workdir=$work $mnttype $mntpoint" ;; *) echo "-t $mnttype -o noatime,dirs=$upper=rw:$lower=ro $mnttype $mntpoint" diff --git a/scripts/install/install-get-partition b/scripts/install/install-get-partition index eee0dc73..5ea4845e 100755 --- a/scripts/install/install-get-partition +++ b/scripts/install/install-get-partition @@ -195,6 +195,14 @@ check_for_new_raid () { drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \ | egrep -v "[0-9]$" | egrep -v "^$") + for instdrv in $drives + do + if mount | grep iso9660 | grep -q $instdrv + then + drives=${drives//"$instdrv"/} + fi + done + numdrives=`echo $drives | wc -w` # Need at least two drives for RAID-1. We don't yet have the code @@ -251,12 +259,12 @@ check_for_new_raid () { 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 + # 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 + data_dev=1 if [ $drivesize1 -lt $drivesize2 ]; then root_size=$drivesize1 @@ -264,24 +272,6 @@ check_for_new_raid () { root_size=$drivesize2 fi - let min_size_with_diag=${MIN_ROOT}+${part_diag_size} - if [ $root_size -ge $min_size_with_diag ]; then - 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 - fi - let root_size-=$part_start_offset for drive in $drives; do @@ -480,7 +470,7 @@ save_image_config() { rm -fr /mnt/config mkdir /mnt/config - output=$(cp -pR /mnt/tmp/boot/$image_name/live-rw/config/* /mnt/config) + output=$(cp -pR /mnt/tmp/boot/$image_name/rw/config/* /mnt/config) if [ -n "$output" ]; then echo -e "Warning: error in copying the old config partition.\nSee $INSTALL_LOG for more details." @@ -492,7 +482,7 @@ save_image_config() { save_image_keys() { image_name=$1 - if [ ! -d /mnt/tmp/boot/$image_name/live-rw/etc/ssh ]; then + if [ ! -d /mnt/tmp/boot/$image_name/rw/etc/ssh ]; then echo "No SSH keys found on $image_name, so none can be saved." return; fi @@ -506,7 +496,7 @@ save_image_keys() { fi mkdir -p /mnt/ssh - output=$(cp -p /mnt/tmp/boot/$image_name/live-rw/etc/ssh/ssh_host_* /mnt/ssh) + output=$(cp -p /mnt/tmp/boot/$image_name/rw/etc/ssh/ssh_host_* /mnt/ssh) if [ -n "$output" ]; then echo -e "Warning: error in copying the old ssh keys." @@ -552,7 +542,7 @@ save_old_info() { image_dirs=/mnt/tmp/boot/* for dir in $image_dirs; do - if [ -f $dir/live-rw/config/.vyatta_config ]; then + if [ -f $dir/rw/config/.vyatta_config ]; then item=${dir##/mnt/tmp/boot/} images=($item ${images[@]}) @@ -652,7 +642,7 @@ make_filesystem () { lecho "Creating filesystem on /dev/$ldrive..." progress_indicator start - output=$(mkfs -t $ROOT_FSTYPE /dev/$ldrive 2>&1) + output=$(mkfs -L persistence -t $ROOT_FSTYPE /dev/$ldrive 2>&1) status=$? if [ "$status" != 0 ]; then echo -e "Error: couldn't create the root filesystem.\nSee $INSTALL_LOG for further details.\nExiting..." @@ -679,26 +669,28 @@ create_partitions() { exit 1 fi + # Force FAT label creation + lecho "Creating a new disklabel on $ldrive" + parted -s /dev/$ldrive mklabel msdos + # Make sure you can print disk info using parted parted --script /dev/$ldrive p >/dev/null 2>&1 - # If unable to read disk, it's likely it needs a disklabel + # If we still can't, something has gone terribly wrong if [ "$?" != "0" ]; then - lecho "Creating a new disklabel on $ldrive" - lecho "parted /dev/$ldrive mklabel msdos" - output=$(parted -s /dev/$ldrive mklabel msdos) - - parted --script /dev/$ldrive p >/dev/null 2>&1 - if [ "$?" != "0" ]; then - echo "Unable to read disk label. Exiting." - exit 1 - fi + echo "Unable to read disk label. Exiting." + exit 1 fi lecho "Creating root partition on /dev/$ldrive" # Make the root partition - output=$(parted --script --align optimal /dev/$ldrive mkpart primary 0% $root_part_size) + # if optimal_io_size is empty use default of 2048s + if [ $(cat /sys/block/$ldrive/queue/optimal_io_size) -gt 0 ]; then + output=$(parted --script --align optimal /dev/$ldrive mkpart primary 0% $root_part_size) + else + output=$(parted --script --align optimal /dev/$ldrive mkpart primary 2048s $root_part_size) + fi status=$? if [ "$status" != 0 ]; then echo -e "Error creating primary partition on $ldrive.\nPlease see $INSTALL_LOG for more details.\nExiting..." diff --git a/scripts/install/install-image b/scripts/install/install-image index c7323fbf..fd10d0c3 100755 --- a/scripts/install/install-image +++ b/scripts/install/install-image @@ -63,7 +63,7 @@ fetch_iso_by_url () fi # This is for statistics collection - vyos_version=`dpkg-query --showformat='${Version}' --show vyatta-version` + vyos_version=`cat /opt/vyatta/etc/version | awk '{print $2}'` filename="${TEMP_DIR}/${NEW_ISO##*/}" curl -L -H "User-Agent: VyOS/$vyos_version" $auth -f -o $filename $NEW_ISO diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing index 7d58cd96..f38e3701 100755 --- a/scripts/install/install-image-existing +++ b/scripts/install/install-image-existing @@ -77,7 +77,7 @@ if [ -z "$CURVER" ]; then fi # get new version string. this is from the squashfs image. -NEWVER=`cat ${CD_SQUASH_ROOT}/opt/vyatta/etc/version | grep "Version:" | awk '{print $2,$3}' | sed 's/ /-/g'` +NEWVER=`cat ${CD_SQUASH_ROOT}/opt/vyatta/etc/version | grep "Version:" | awk '{print $2,$3}' | sed 's/[[:space:]]*$//' | sed 's/ /-/g'` NEWNAME=$NEWVER echo -n "What would you like to name this image? [$NEWNAME]: " @@ -110,10 +110,12 @@ fi echo "OK. This image will be named: $NEWNAME" # this is the default if current install is union -BOOT_DIR=/live/image/boot + if [ "$CUR_INSTALL" == 'old' ]; then BOOT_DIR=/boot -elif [ "$CUR_INSTALL" != 'union' ]; then +elif [ "$CUR_INSTALL" == 'union' ]; then + BOOT_DIR=`/opt/vyatta/sbin/vyos-persistpath`/boot +else echo 'Invalid current install type. Exiting...' exit 1 fi @@ -155,11 +157,14 @@ echo "Installing \"$NEWNAME\" image." # create the new release directories REL_ROOT=$BOOT_DIR/$NEWNAME -RW_DIR="$REL_ROOT/live-rw" +RW_DIR="$REL_ROOT/rw" if ! mkdir -p "$RW_DIR"; then failure_exit 'Cannot create directory for new release.' fi +WORK_DIR="$REL_ROOT/work" +mkdir -p "$WORK_DIR" + # copy the squashfs image and boot files echo "Copying new release files..." squash_img=${CD_ROOT}/live/filesystem.squashfs @@ -180,20 +185,12 @@ if ! try_mount "-o loop,ro $target_squash $READ_ROOT"; then fi # set up root for postinst -margs=$(gen_mopts "overlayfs" $RW_DIR $READ_ROOT $INST_ROOT) +margs=$(gen_mopts "overlay" $RW_DIR $READ_ROOT $WORK_DIR $INST_ROOT) if ! try_mount "$margs"; then rm -rf $REL_ROOT failure_exit 'Failed to set up root directory for postinst.' fi -# set up /var/run fstab entry -PI_FSTAB=$INST_ROOT/etc/fstab -if ! grep -q 'tmpfs /var/run ' $PI_FSTAB >&/dev/null; then - # replace the fstab. the default one has header that will cause - # it to be wiped out on live boot. - echo 'tmpfs /var/run tmpfs nosuid,nodev 0 0' >$PI_FSTAB -fi - # # Check to make sure we have enough space to copy the config and data dirs... # diff --git a/scripts/install/install-image-new b/scripts/install/install-image-new index 7965b939..d6427500 100755 --- a/scripts/install/install-image-new +++ b/scripts/install/install-image-new @@ -62,8 +62,10 @@ echo "OK. This image will be named: $image_name" # make the dir for the new version mkdir -p $WRITE_ROOT/boot/$image_name # make dir for backing store -rw_dir=$WRITE_ROOT/boot/$image_name/live-rw +rw_dir=$WRITE_ROOT/boot/$image_name/rw mkdir -p $rw_dir +work_dir=$WRITE_ROOT/boot/$image_name/work +mkdir -p $work_dir echo Copying squashfs image... # these are the defaults if installing from a specified ISO image file. @@ -73,7 +75,7 @@ boot_dir=${CD_SQUASH_ROOT}/boot boot_files=$(find $boot_dir -maxdepth 1 -type f -o -type l 2>/dev/null) if [ ! -f "$squash_img" ] || [ -z "$boot_files" ]; then # maybe installing from a live CD boot? - squash_img=/live/image/live/filesystem.squashfs + squash_img=/lib/live/mount/medium/live/filesystem.squashfs boot_dir=/boot boot_files=$(find $boot_dir -maxdepth 1 -type f -o -type l 2>/dev/null) if [ ! -f "$squash_img" ] || [ -z "$boot_files" ]; then @@ -88,13 +90,16 @@ cp -p $squash_img $target_squash echo Copying kernel and initrd images... cp -dp $boot_files $WRITE_ROOT/boot/$image_name/ +# create persistence.conf file +echo "/ union" > $WRITE_ROOT/persistence.conf + # set up union root for postinst mkdir -p $INST_ROOT $READ_ROOT if ! try_mount "-o loop,ro -t squashfs $target_squash $READ_ROOT"; then echo 'Exiting...' exit 1 fi -margs=$(gen_mopts "overlayfs" $rw_dir $READ_ROOT $INST_ROOT) +margs=$(gen_mopts "overlay" $rw_dir $READ_ROOT $work_dir $INST_ROOT) if ! try_mount "$margs"; then echo 'Exiting...' exit 1 diff --git a/scripts/install/install-postinst-new b/scripts/install/install-postinst-new index 11cf788e..2457cdd3 100755 --- a/scripts/install/install-postinst-new +++ b/scripts/install/install-postinst-new @@ -51,15 +51,6 @@ copy_config () { config=${VYATTA_NEW_CFG_DIR}/config.boot fi - # Second candidate: The config file on floppy, if one exists. - if [ -f "${FD_CFG_DIR}/config.boot" ]; then - if [ -z "$config" ]; then - config="${FD_CFG_DIR}/config.boot" - else - config="$config ${FD_CFG_DIR}/config.boot" - fi - fi - # Third candidate: The default config file DEF_CONF=$vyatta_sysconfdir/config.boot.default if [ -f $DEF_CONF ]; then @@ -175,7 +166,7 @@ setup_xen_extras () { echo "" >> $grubfile echo "title vyatta-virt" >> $grubfile echo "root (hd0,0)" >> $grubfile - echo "kernel $xen_grub_boot_path/vmlinuz root=/dev/$rootdev boot=live vyatta-union=$xen_grub_boot_path console=hvc0" >> $grubfile + echo "kernel $xen_grub_boot_path/vmlinuz root=/dev/$rootdev boot=live vyos-union=$xen_grub_boot_path console=hvc0" >> $grubfile echo "initrd $xen_grub_boot_path/initrd.img" >> $grubfile # Add symlink pointing to default image @@ -259,27 +250,10 @@ if [ -f "$MDADM_CONFIG_FILE" ]; then fi fi -if [ "$INSTALL_TYPE" == 'union' ]; then - # make /var/run tmpfs - pi_fstab=$INST_ROOT/etc/fstab - if ! grep -q 'tmpfs /var/run ' $pi_fstab >&/dev/null; then - # replace the fstab. the default one has header that will cause - # it to be wiped out on live boot. - echo 'tmpfs /var/run tmpfs nosuid,nodev 0 0' >$pi_fstab - fi -else - # not passing the write root to postinst (only needed for union) +if [ "$INSTALL_TYPE" != 'union' ]; then WRITE_ROOT='' fi -# postinst hook -if [ -e /opt/vyatta/etc/install-system/postinst ]; then - echo "running post-install script" - output=$(/opt/vyatta/etc/install-system/postinst \ - "$INST_ROOT" "$WRITE_ROOT" 2>&1) - lecho "$output" -fi - becho "Done!" exit 0 |