get latest changes
[mediawiki-setup] / mw-setup-script
index acc327fb5e8ecc925900d508bb5f4c7efeef437b..9c1fd86fae7db844aa7ae4fd7d36495639fba3e1 100755 (executable)
@@ -126,18 +126,26 @@ else
 fi
 
 
-# slightly different depending on if we already set the root pass
-if echo exit|mysql -u root -p"$dbpass"; then
-    # answer interactive prompts:
-    # mysql root pass, change pass? no, remove anon users? (default, yes)
-    # disallow remote root (default, yes), reload? (default, yes)
-    echo -e "$dbpass\nn\n\n\n\n" | mysql_secure_installation
-else
-    # I had 1 less newline at the start when doing ubuntu 14.04,
+# skip if we already set the root pass
+if ! echo exit|mysql -uroot "-p$dbpass"; then
+    # Note: we set a root password here, but in debian 9+, it is ignored;
+    # only the local user root can login, and a password is silently ignored.
+    # We answer these interactive prompts:
+    # Enter current password for root (enter for none):
+    # Set root password? [Y/n]
+    # New password:
+    # Re-enter new password:
+    # Remove anonymous users? [Y/n]
+    # Disallow root login remotely? [Y/n]
+    # Remove test database and access to it? [Y/n]
+    # Reload privilege tables now? [Y/n]
+    # Note, I had 1 less newline at the start when doing ubuntu 14.04,
     # compared to debian 8, so can't say this is especially portable.
-    # It won't hurt if it fails.
     echo -e "\n\n$dbpass\n$dbpass\n\n\n\n\n" | mysql_secure_installation
 fi
+mysql -uroot "-p$dbpass" <<EOF
+GRANT ALL PRIVILEGES ON my_wiki.* TO 'wikiuser'@'localhost' IDENTIFIED BY '$dbpass';
+EOF
 # </source>
 # <source lang="bash">
 mkdir -p $mw
@@ -165,12 +173,12 @@ cd ..
 # Drop any previous database which may have been installed while testing.
 # If upgrading, we should have a db backup which will get restored.
 # https://www.mediawiki.org/wiki/Manual:Upgrading
-mysql -u root -p$dbpass <<'EOF' ||:
+mysql -uroot "-p$dbpass" <<'EOF' ||:
 drop database my_wiki;
 exit
 EOF
 php $mw/maintenance/install.php --pass $wikipass --scriptpath /w \
-    --dbuser root --dbpass $dbpass "$mwdescription" "$wikiuser"
+    --dbuser wikiuser --dbpass $dbpass "$mwdescription" "$wikiuser"
 teeu $mwc <<'EOF'
 # lock down the wiki to only the initial owner until anti-spam measures are put in place
 # limit edits to registered users