diff options
Diffstat (limited to 'scripts/install-system')
-rwxr-xr-x | scripts/install-system | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/scripts/install-system b/scripts/install-system index d11aca78..1259af3b 100755 --- a/scripts/install-system +++ b/scripts/install-system @@ -69,6 +69,13 @@ SPID=$$ # Path to standalone root password reset script PWRESET=/opt/vyatta/sbin/standalone_root_pw_reset +# Grub options +GRUB_OPTIONS="quiet" + +# Output to both console (last device is /dev/console) +VTY_CONSOLE="console=ttyS0,9600 console=tty0" +SERIAL_CONSOLE="console=tty0 console=ttyS0,9600" + # trap signals so we can kill runaway progress indicators trap 'progress_indicator stop; exit 1' 1 trap 'progress_indicator stop; exit 1' 2 @@ -95,7 +102,7 @@ get_response () { # get the response from the user read myresponse - myresponse=$(echo "$myresponse" | awk '{ printf (tolower($0)) }') + myresponse=$(echo "$myresponse" | tr [:upper:] [:lower:]) # Check to see if the user accepts the default if [ -z "$myresponse" ]; then @@ -157,6 +164,7 @@ get_drive_size () { echo $lsize } + # Probe hardrives not shown in /proc/partitions by default probe_drives () { # find IDE drives. Not all drives show up in /proc/partitions for @@ -209,7 +217,7 @@ select_drive () { size=$(get_drive_size $INSTALL_DRIVE) if [ $size -lt 11000 ] then - ISCF="ide=nodma" + GRUB_OPTIONS="$GRUB_OPTIONS ide=nodma" fi } @@ -527,6 +535,30 @@ copy_config () { fi } +change_password() { + local user=$1 + local pwd + read pwd + local epwd=$(mkpasswd -H md5 $pwd) + + sed -i \ + -e "/ user $user {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$epwd\"/" \ + $rootfsdir$ofrconfdir/config.boot +} + +system_setup () { + echo -n "Would you like to set the passwords for system users (Yes/No) [Yes]: " + local response=$(get_response "Yes" "Yes No Y N") + + if [ "$response" == "yes" ] || [ "$response" == "y" ]; then + echo -n 'System adminstrator (root) password: ' + change_password root + echo -n 'Router adminstrator (vyatta) password: ' + change_password vyatta + fi +} + + # setup grub on the boot sector of a user queried drive install_grub () { orig_install_drive="$INSTALL_DRIVE" @@ -579,6 +611,17 @@ install_grub () { DEFAULT_CONSOLE="0" fi + # Read UUID off of filesystem and use it to tell GRUB where to mount drive + # This allows device to move around and grub will still find it + local rootdev="/dev/$ROOT_PARTITION"; + uuid=$(dumpe2fs -h $rootdev 2>/dev/null | awk '/^Filesystem UUID/ {print $3}') + if [ -z $uuid ] + then + GRUB_ROOT="root=$rootdev ro" + else + GRUB_ROOT="root=UUID=$uuid ro" + fi + ( # create the grub.cfg file for grub # The "default=" line selects which boot option will be used by default. @@ -606,7 +649,7 @@ install_grub () { if [ -f "/boot/vmlinuz" ]; then # Set first system boot option. Make KVM the default console in this one. echo -e "menuentry \"Vyatta OFR (KVM console)\" {" - echo -en "\tlinux /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 \n" + echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE" echo -e "\tinitrd /boot/initrd.img" echo -e "}" @@ -614,7 +657,7 @@ install_grub () { # console in this one. echo echo -e "menuentry \"Vyatta OFR (Serial console)\" {" - echo -en "\tlinux /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=tty0 console=ttyS0,9600 \n" + echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE" echo -e "\tinitrd /boot/initrd.img" echo -e "}" fi @@ -626,7 +669,7 @@ install_grub () { echo echo -e "menuentry \"Vyatta Xen linux$xversion dom0\" {" echo -e "\tmultiboot /boot/$xen_version " - echo -en "\tmodule /boot/vmlinuz$xversion root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 \n" + echo -e "\tmodule /boot/vmlinuz$xversion $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE" echo -e "\tmodule /boot/initrd.img$xversion" echo -e "}" done @@ -637,12 +680,12 @@ install_grub () { for kversion in $kernel_versions; do echo echo -e "menuentry \"Vyatta OFR linux$kversion (KVM console)\" {" - echo -en "\tlinux /boot/vmlinuz$kversion root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 \n" + echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE" echo -e "\tinitrd /boot/initrd.img$kversion" echo -e "}" echo echo -e "menuentry \"Vyatta OFR linux$kversion (Serial console)\" {" - echo -en "\tlinux /boot/vmlinuz$kversion root=/dev/$ROOT_PARTITION $ISCF console=tty0 console=ttyS0,9600 \n" + echo -e "\tlinux /boot/vmlinuz$kversion $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE" echo -e "\tinitrd /boot/initrd.img$kversion" echo -e "}" done @@ -653,13 +696,13 @@ install_grub () { echo echo -e "menuentry \"Root password reset to factory (KVM console)\" {" - echo -e "\tlinux /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=ttyS0,9600 console=tty0 init=$PWRESET" + echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $VTY_CONSOLE init=$PWRESET" echo -e "\tinitrd /boot/initrd.img" echo -e "}" echo echo -e "menuentry \"Root password reset to factory (Serial console)\" {" - echo -e "\tkernel /boot/vmlinuz root=/dev/$ROOT_PARTITION $ISCF console=tty0 console=ttyS0,9600 init=$PWRESET" + echo -e "\tkernel /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE init=$PWRESET" echo -e "\tinitrd /boot/initrd.img" echo -e "}" ) >"$rootfsdir/boot/grub/grub.cfg" @@ -937,6 +980,12 @@ install_root_filesystem "$ROOT_PARTITION" # Copy the config files copy_config "$CONFIG_PARTITION" +# Modify config to match system +# Assume user wants to keep password from old config +if [ ! -d /mnt/config ]; then + system_setup +fi + # check for xen part images in /var/xen setup_xen_partition_images |