#!/bin/bash TEMPLATE=ichimisushiandgrill.com OUTPUT=${1:-ichimisushi-thai.com} SANITIZED=${OUTPUT//[-.]/_} DB_USER=$SANITIZED TABLE_NAME=wordpress_$SANITIZED PATH=$PWD:$PATH set -ex [ "$OUTPUT" != "$TEMPLATE" ] # Create new apache virtual host if [ ! -e /etc/apache2/sites-enabled/$OUTPUT.conf ] then [ -e /etc/apache2/sites-available/$TEMPLATE.conf ] mkdir /srv/$OUTPUT /srv/$OUTPUT/public_html /srv/$OUTPUT/logs cd /etc/apache2/sites-available/ sed -e "s/$TEMPLATE/$OUTPUT/g" < "$TEMPLATE".conf > "$OUTPUT".conf a2ensite $OUTPUT systemctl reload apache2 fi # Install wordpress content to apache htdocs directory if [ ! -e /srv/"$OUTPUT"/public_html/wordpress/wp-config.php ] then cd /srv/"$OUTPUT"/public_html curl https://wordpress.org/latest.tar.gz | tar -zx cd wordpress wp-conf.sh "$TABLE_NAME" "$DB_USER" > wp-config.php chown www-data.www-data -R . chown nobody.nogroup wp-config.php fi # Set up database if true then pwline=$(grep DB_PASSWORD /srv/$OUTPUT/public_html/wordpress/wp-config.php) DB_PASSWORD=$(php -r "$pwline echo DB_PASSWORD;") mysqladmin create "$TABLE_NAME" mysql "$TABLE_NAME" <