File: /home/httpd/html/fagottube.com/wpscript.sh
#!/bin/bash
echo "Enter a database/username: "
read name
#echo "Downloading the latest version of wordpress..."
#wget --quiet -O - wordpress.org/latest.tar.gz | tar -v -z -x --strip-components=1 >& /dev/null
echo "Updating config file..."
password=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
cat wp-config-sample.php |sed -e "s/putyourdbnamehere/$name/g;s/usernamehere/$name/g;s/yourpasswordhere/$password/g" > wp-config.php
echo "Creating database..."
echo "create database $name" | mysql
echo "grant all on $name.* to $name@'localhost' identified by '$password'" | mysql $name
user=`pwd|awk -F\/ '{print $4}'`
echo chown $user.www-data `pwd` -R \* [y/n]:
read answer
if [ $answer == "y" ]
then
chown $user.www-data `pwd` -R *
fi
echo chmod g+w `pwd`/wp-content [y/n]:
read answer
if [ $answer == "y" ]
then
chmod g+w `pwd`/wp-content
fi
echo "done."
echo "db name: $name"
echo "db user: $name"
echo "db pass: $password"
echo ""