diff options
-rwxr-xr-x | scripts/standalone_root_pw_reset | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/scripts/standalone_root_pw_reset b/scripts/standalone_root_pw_reset index e50312bc..c13746a0 100755 --- a/scripts/standalone_root_pw_reset +++ b/scripts/standalone_root_pw_reset @@ -84,8 +84,7 @@ fi # OK, now we know we are running in standalone mode. Talk to the # user. # -echo "Do you wish to reset the admin password?" - +echo -n "Do you wish to reset the admin password? (y or n) " read -t $TIME_TO_WAIT response if [ "$?" != "0" ]; then echo @@ -111,12 +110,12 @@ echo "Starting process to reset the admin password..." echo "Re-mounting root filesystem read/write..." mount -o remount,rw / -if ! -f /opt/vyatta/etc/config -then dead "Missing Vyatta config directory..." +if [ ! -f /etc/passwd ] +then dead "Missing password file" fi -if ! -f /etc/passwd -then dead "Missing password file..." +if [ ! -d /opt/vyatta/etc/config ] +then dead "Missing Vyatta config directory /opt/vyatta/etc/config" fi # Leftover from V3.0 @@ -126,31 +125,31 @@ then mount /opt/vyatta/etc/config/ fi -if ! -f $CF -then dead "$CF file not found..." +if [ ! -f $CF ] +then dead "$CF file not found" fi -if ! grep -q '^system {' $CF -then die "$CF file does not contain system settings..." +if ! grep -q ' system {' $CF +then dead "$CF file does not contain system settings" fi if ! grep -q ' login {' $CF then # Recreate login section of system - sed -i -e '/^system {/a\ - login { \ + sed -i -e '/ system {/a\ + login {\ }' $CF fi if ! grep -q " user $ADMIN " $CF then echo "Recreating administrator $ADMIN in $CF..." - sed -i -e "/ login {/a\ - user $ADMIN { \ - authentication { \ - encrypted-password "$1$4XHPj9eT$G3ww9B/pYDLSXC8YVvazP0" \ - } \ - level admin \ + sed -i -e "/ login {/a\\ + user $ADMIN {\\ + authentication {\\ + encrypted-password \"$1$4XHPj9eT$G3ww9B/pYDLSXC8YVvazP0\"\\ + }\\ + level admin\\ }" $CF fi |