Chad Don Cooper Projects and ponderings…

23Jan/180

Install PHP Unit on Windows

  • Download the latest phpunit.phar
  • Place it in a directory which is listed under PATH
  • Remove the .phar file extension.

Doing this rather than making a batch file gets it working in Git Bash.

Filed under: Uncategorized No Comments
17Nov/170

Automated install of MySQL on CentOS 7

Run the scirpt below using the first argument for the root user password.

#!/bin/bash

NEW_MYSQL_ROOT_PASSWORD=$1

rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum install mysql-server expect -y
systemctl enable mysqld
systemctl start mysqld

TMP_MYSQL_ROOT_PASSWORD=$(grep -oP 'root@localhost: (.+)$' /var/log/mysqld.log)
TMP_MYSQL_ROOT_PASSWORD="${TMP_MYSQL_ROOT_PASSWORD/root@localhost: /}"

SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root:\"
send \"$TMP_MYSQL_ROOT_PASSWORD\r\"
expect \"New password:\"
send \"$NEW_MYSQL_ROOT_PASSWORD\r\"
expect \"Re-enter new password:\"
send \"$NEW_MYSQL_ROOT_PASSWORD\r\"
expect \"Change the password for root\"
send \"y\r\"
expect \"New password:\"
send \"$NEW_MYSQL_ROOT_PASSWORD\r\"
expect \"Re-enter new password:\"
send \"$NEW_MYSQL_ROOT_PASSWORD\r\"
expect \"Remove anonymous users?\"
send \"y\r\"
expect \"Disallow root login remotely?\"
send \"y\r\"
expect \"Remove test database and access to it?\"
send \"y\r\"
expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
")

echo "$SECURE_MYSQL"

yum remove expect -y

Filed under: Uncategorized No Comments