LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > Spock's Brain
User Name
Password

Notices


Rate this Entry

Scripting a Wordpress rollout - Method II

Posted 11-30-2015 at 12:50 PM by Habitual
Updated 11-30-2015 at 03:21 PM by Habitual

Now even shinier!
It's a rude and crude script, but it works for experienced admins who knows what they are doing,
and where they are doing it.

Code:
#!/bin/bash
### 11/30/2015 
### jj/Habitual

clear

do_work ()
{ 
    BASEDIR=/var/www/html
    mkdir -pv "$BASEDIR"/"$DOMAIN"/
    cp -pr /var/www/wordpress/* "$BASEDIR"/"$DOMAIN"/
    cp "$BASEDIR"/"$DOMAIN"/wp-config-sample.php  "$BASEDIR"/"$DOMAIN"/wp-config.php
    ### MySQL Database Routine ###
    ### MySQL hates .tld in db names, so change .tld to _tld
    MYSQLDOMAIN=$(echo $DOMAIN | sed 's/\./_/g')
    mysql -e "create database IF NOT EXISTS $MYSQLDOMAIN;"
    CONNECT_PASSWORD=$(date +%s | sha256sum | base64 | head -c 12 ; echo)
    mysql -e "grant select, insert, update, delete on $MYSQLDOMAIN.* to wp_installer@'localhost' identified by '$CONNECT_PASSWORD';flush privileges;"
    sed -i -e 's@database_name_here@'"$MYSQLDOMAIN"'@' $BASEDIR/$DOMAIN/wp-config.php
    sed -i -e 's@username_here@wp_installer@' $BASEDIR/$DOMAIN/wp-config.php
    sed -i -e 's@password_here@'"$CONNECT_PASSWORD"'@' $BASEDIR/$DOMAIN/wp-config.php
    chown apache:apache "$BASEDIR"/"$DOMAIN"/ -R
}

for DOMAIN in "$@"
do
    do_work
done
Usage:
Code:
<script.sh> example1.net example2.net example3.net ... ...
etc....
Takes all of 3 seconds to roll out.

Enjoy the goodness.
Posted in Uncategorized
Views 3422 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 08:56 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration