diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install-system | 35 | ||||
-rwxr-xr-x | scripts/standalone_root_pw_reset | 41 |
2 files changed, 50 insertions, 26 deletions
diff --git a/scripts/install-system b/scripts/install-system index 71233ccb..d6ea9b74 100755 --- a/scripts/install-system +++ b/scripts/install-system @@ -229,7 +229,7 @@ select_drive () { # Assume no dma if the disk is smaller than 10G (such as a CF drive) size=$(get_drive_size $INSTALL_DRIVE) - if [ $size -lt 11000 ] + if [[ $size -lt 11000 && ! $GRUB_OPTIONS =~ 'ide=nodma' ]] then GRUB_OPTIONS="$GRUB_OPTIONS ide=nodma" fi @@ -309,6 +309,9 @@ rename_old_config() { check_config_partition() { lpart=$1 + # Cleanup from possible partial last run + rm -fr /mnt/config + # Look to see if this is a config partition mkdir -p /mnt/tmp output=$(mount /dev/$lpart /mnt/tmp 2>&1) @@ -476,7 +479,15 @@ install_root_filesystem () { output=$(umount /mnt/squashfs) # create the fstab - echo -e "/dev/$ROOT_PARTITION\t/\text3\tdefaults\t0 1" >> $rootfsdir/etc/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/ @@ -517,16 +528,19 @@ copy_config () { if [ -z "$config" ]; then config="$fdconfdir/config.boot" else - config="$config\n$fdconfdir/config.boot" + config="$config $fdconfdir/config.boot" fi fi if [ -n "$config" ]; then echo "I found the following configuration files" - echo -e "$config" - default=$(echo -e $config| head -1) + for file in $config + do + echo $file + done + + default=$(echo -e $config | awk '{ print $1 }') - resp='' while [ -z "$configfile" ] do echo -n "Which one should I copy to $INSTALL_DRIVE? [$default]: " @@ -553,7 +567,7 @@ change_password() { local user=$1 local pwd read pwd - local epwd=$(mkpasswd -H md5 $pwd | sed 's:/:\\/':) + local epwd=$(mkpasswd -H md5 $pwd | sed 's:/:\\/:g') sed -i \ -e "/ user $user {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$epwd\"/" \ @@ -629,9 +643,10 @@ install_grub () { # 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 ] + if [ -z "$uuid" ] then - GRUB_ROOT="root=$rootdev ro" + echo "Unable to read filesystem UUID. Exiting." + exit 1 else GRUB_ROOT="root=UUID=$uuid ro" fi @@ -716,7 +731,7 @@ install_grub () { echo echo -e "menuentry \"Root password reset to factory (Serial console)\" {" - echo -e "\tkernel /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE init=$PWRESET" + echo -e "\tlinux /boot/vmlinuz $GRUB_ROOT $GRUB_OPTIONS $SERIAL_CONSOLE init=$PWRESET" echo -e "\tinitrd /boot/initrd.img" echo -e "}" ) >"$rootfsdir/boot/grub/grub.cfg" diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset index 0dc65fd2..b173f22d 100755 --- a/scripts/standalone_root_pw_reset +++ b/scripts/standalone_root_pw_reset @@ -24,7 +24,7 @@ CF=/opt/vyatta/etc/config/config.boot echo "Standalone root password recovery tool." - +echo # # Check to see if we are running in standalone mode. We'll # know that we are if our pid is 1. @@ -38,12 +38,8 @@ fi # OK, now we know we are running in standalone mode. Talk to the # user. # -echo "Do you wish to reset the reset the root password to its" -echo -n "factory setting value of \"vyatta\"? (Yes/No) [No]: " - -# -# Parse the user's response -# +echo "Do you wish to reset the root password" +echo -n "to the original default value (vyatta)? (Yes/No) [No]: " read response response=${response:0:1} @@ -55,26 +51,39 @@ if [ "$response" != "y" -a "$response" != "Y" ]; then /sbin/reboot -f fi + echo "Starting process to reset the root password..." echo "Re-mounting root filesystem read/write..." mount -o remount,rw / -echo "Mounting the config filesystem..." -mount /opt/vyatta/etc/config/ +# Leftover from V3.0 +if grep -q /opt/vyatta/etc/config /etc/fstab +then + echo "Mounting the config filesystem..." + mount /opt/vyatta/etc/config/ +fi echo "Saving backup copy of config.boot..." cp $CF ${CF}.before_pwrecovery echo "Reseting the root password..." -sed -i -e "/^.* user root {/,/^.* }/s/encrypted-password: .*$/encrypted-password: \"\$1\$\$Ht7gBYnxI1xCdO\/JOnodh.\"/" $CF -echo "Root password has been reset." -echo "Logging the activity..." -echo "`date`: Root password reset to factory value" >> /var/log/messages +# change system first +newpwd=$(mkpasswd -H md5 vyatta) +usermod --password "$newpwd" root + +# escape / in encrypted passwd +pw=$(echo $newpwd | sed 's:/:\\/:g') +sed -i \ + -e "/^.* user root {/,/}/s/encrypted-password:.*\$/encrypted-password: \"$pw\"/" \ + $CF + +echo $(date "+%b%e %T") $(hostname) "Root password reset to factory value" \ + | tee -a /var/log/auth.log >>/var/log/messages -echo -n "Machine will reboot in 5 seconds..." sync -sleep 5 -echo + +echo "System will reboot in 10 seconds..." +sleep 10 /sbin/reboot -f |