diff options
author | kent@mysql.com/kent-amd64.(none) <> | 2007-01-01 05:30:31 +0100 |
---|---|---|
committer | kent@mysql.com/kent-amd64.(none) <> | 2007-01-01 05:30:31 +0100 |
commit | 0255a1c9c2155d7beeb76517d1a9770789960369 (patch) | |
tree | 824586efcaa6b47b985f617eabe644977c0bd58e /scripts | |
parent | 9b8c7ffc1947208f3b9334b7d8216bb1a62f751b (diff) | |
download | mariadb-git-0255a1c9c2155d7beeb76517d1a9770789960369.tar.gz |
mysql_secure_installation.sh:
Portable handling of "echo" without newline (bug#24605)
check-cpu:
In developer script safe to use "printf", not "echo -n"
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mysql_secure_installation.sh | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index 1c7ca34ad59..e42e83233c3 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -22,6 +22,16 @@ command=".mysql.$$" trap "interrupt" 2 rootpass="" +echo_n= +echo_c= + +set_echo_compat() { + case `echo "testing\c"`,`echo -n testing` in + *c*,-n*) echo_n= echo_c= ;; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c' ;; + esac +} prepare() { touch $config $command @@ -45,7 +55,7 @@ get_root_password() { status=1 while [ $status -eq 1 ]; do stty -echo - echo -n "Enter current password for root (enter for none): " + echo $echo_n "Enter current password for root (enter for none): $echo_c" read password echo stty echo @@ -65,10 +75,10 @@ get_root_password() { set_root_password() { stty -echo - echo -n "New password: " + echo $echo_n "New password: $echo_c" read password1 echo - echo -n "Re-enter new password: " + echo $echo_n "Re-enter new password: $echo_c" read password2 echo stty echo @@ -173,6 +183,7 @@ cleanup() { # The actual script starts here prepare +set_echo_compat echo echo @@ -201,11 +212,11 @@ echo "root user without the proper authorisation." echo if [ $hadpass -eq 0 ]; then - echo -n "Set root password? [Y/n] " + echo $echo_n "Set root password? [Y/n] $echo_c" else echo "You already have a root password set, so you can safely answer 'n'." echo - echo -n "Change the root password? [Y/n] " + echo $echo_n "Change the root password? [Y/n] $echo_c" fi read reply @@ -232,7 +243,7 @@ echo "go a bit smoother. You should remove them before moving into a" echo "production environment." echo -echo -n "Remove anonymous users? [Y/n] " +echo $echo_n "Remove anonymous users? [Y/n] $echo_c" read reply if [ "$reply" = "n" ]; then @@ -251,7 +262,7 @@ echo "Normally, root should only be allowed to connect from 'localhost'. This" echo "ensures that someone cannot guess at the root password from the network." echo -echo -n "Disallow root login remotely? [Y/n] " +echo $echo_n "Disallow root login remotely? [Y/n] $echo_c" read reply if [ "$reply" = "n" ]; then echo " ... skipping." @@ -270,7 +281,7 @@ echo "access. This is also intended only for testing, and should be removed" echo "before moving into a production environment." echo -echo -n "Remove test database and access to it? [Y/n] " +echo $echo_n "Remove test database and access to it? [Y/n] $echo_c" read reply if [ "$reply" = "n" ]; then echo " ... skipping." @@ -288,7 +299,7 @@ echo "Reloading the privilege tables will ensure that all changes made so far" echo "will take effect immediately." echo -echo -n "Reload privilege tables now? [Y/n] " +echo $echo_n "Reload privilege tables now? [Y/n] $echo_c" read reply if [ "$reply" = "n" ]; then echo " ... skipping." |