diff --git a/wp/new-user.sh b/wp/new-user.sh new file mode 100644 index 0000000..3774891 --- /dev/null +++ b/wp/new-user.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Rename user with login "web" to your perfectly user name +# And setup mysql password and also rename mysql user +# Web-root is /home/yourlogin/public_html (that path also changed in apache config) +NEW_USER=$1 +DB_PASS=$2 +if [[ -z "${NEW_USER}" ]]; then + echo "NEW_USER is empty. That is not good." + exit 1 +fi +if [[ -z "${DB_PASS}" ]]; then + echo "DB_PASS is empty. That is not good." + exit 1 +fi +systemctl stop httpd +usermod --login ${NEW_USER} --move-home --home /home/${NEW_USER} web +sed -i "s/User web/User ${NEW_USER}/" /etc/httpd/conf/httpd.conf +sed -i "s/\/home\/web/\/home\/${NEW_USER}/g" /etc/httpd/conf/httpd.conf +systemctl start httpd +mysql -u root -e "set password for 'wp-user'@'%' = password('${DB_PASS}')" +mysql -u root -e "update mysql.user set User='${NEW_USER}' where User='wp-user'" +mysql -u root -e "flush privileges" +mysql -u root -e "create database ${NEW_USER}" +mysql -u root -e "drop database wordpress" +mysql -u root -e "grant all privileges on ${NEW_USER}.* to '${NEW_USER}'@'%' with grant option" +mysql -u root -e "flush privileges" \ No newline at end of file