Posts Tagged programming

Wordpress Automation


OK so I had a few minutes to spare today and I  decided to finalize this mini-automation script for WordPress installs.  Keep in mind that  the assumption is made that you have used Virtualmin to create the preliminary aspects, vhost, mysql, doc root, etc… If not… this ain’t gonna work as it is.  I guess I could work up a more in-depth script to include these aspects, in fact that is how I started this idea in the first place, but the aspects of virtualmin really are pretty extensive and since I am using that to manage the vhosts anyway I just skipped that part, I mean why try to improve on a great integration aspect, besides it is unlikely I could do it better anyway.  I would however like to translate this piece into a Perl mod to be added to the virtualmin GUI, that would be a cool improvement.

#/bin/bash

#

echo “Make sure you have created this VHost using virtualmin FIRST…”

sleep 5

echo “OK… moving on then”

sleep 2

echo “Enter the name of your new site, then press [ENTER}”

read newblog

# You need these if you are NOT using virtualmin FIRST !!

# mkdir /var/www/html/$newblog

# useradd -c ‘$newblog user’ -p ‘$newblog’ $newblog

# chown -R $newblog:$newblog $newblog

cd /home/$newblog/public_html

wget http://www.wordpress.org/latest.tar.gz

tar xzf latest.tar.gz

rm -Rf latest.tar.gz

mv wordpress/* .

rm -Rf wordpress

chmod 777 .

# Link the themes & plugins from the default repo

# This makes the assumption that you actually HAVE a repo for themes and plugins…

# If you don’t this ain’t gonna do what we need it to !!

cd /home/$newblog/public_html/wp-content

mv themes bak.themes # <– Just in case we hose everything 😦

# Make the link directorie(s), if necessary and link ’em up

mkdir -p /var/www/repo/themes

ln -s /var/www/repo/themes /home/$newblog/public_html/wp-content/themes

mv plugins bak.plugins

mkdir -p /var/www/repo/plugins

ln -s /var/www/repo/plugins /home/$newblog/public_html/wp-content/plugins

cd ../

cp wp-config-sample.php wp-config.php

#

#

# Final directions

# Open the editor if needed but SED will do what you need

# vi wp-config.php

sed -i ‘s/putyourdbnamehere/’$newblog’/’ wp-config.php

sed -i ‘s/usernamehere/’$newblog’/’ wp-config.php

sed -i ‘s/yourpasswordhere/’$newblog’/’ wp-config.php

chown -R $newblog:$newblog *

# EOF

If you need webmin/virtualmin/cloudmin (I HIGHLY recommend them) you can spin this off:

# Virtualmin/Webmin/Cloudmin Installation

# cd /usr/src

# wget http://software.virtualmin.com/gpl/scripts/install.sh

# sh install.sh

# wegt http://cloudmin.virtualmin.com/gpl/scripts/cloudmin-gpl-redhat-install.sh

# sh cloudmin-gpl-redhat-install.sh

And that’s it! Just navigate to your new URL (assuming that you made the proper DNS entries…) and configure WordPress from its admin console.  I also thought this tutorial on SED was pretty useful although what I used here is very basic, just in case you need something more.

http://www.grymoire.com/Unix/Sed.html

Happy Blogging 🙂

Advertisements

, , , , , , , , , ,

3 Comments

AIX ‘stats-grabber’


I thought this was a pretty cool little ditty, if you administer AIX that is…

#!/usr/bin/ksh
# Bruce Spencer, IBM
# 2/4/99
# Modified 1/20/2000 to add serial number and “uname -M”
# This program identifies the Model, serial number (PCI only), memory, CPU’
# and disk on a RS/6000

# Hardware Codes for MCA based systems
CODE=`uname -m | cut -c9,10 `
case $CODE in
02) MODEL=”7015-930″;;
10) MODEL=”7016-730, 7013-530, 7016-730″;;
14) MODEL=”7013-540″;;
18) MODEL=”7013-53H”;;
1C) MODEL=”7013-550″;;
20) MODEL=”7015-930″;;
2E) MODEL=”7015-950″;;
30) MODEL=”7013-520, 7018-740/741″;;
31) MODEL=”7012-320″;;
34) MODEL=”7013-52H”;;
35) MODEL=”7012-32H”;;
37) MODEL=”7012-340″;;
38) MODEL=”7012-350″;;
41) MODEL=”7011-220″;;
42) MODEL=”7006-41T/41W”;;
43) MODEL=”7008-M20″;;
46) MODEL=”7011-250″;;
47) MODEL=”7011-230″;;
48) MODEL=”7009-C10″;;
57) MODEL=”7012-390, 7030-3BT”;;
58) MODEL=”7012-380, 7030-3AT”;;
59) MODEL=”7012-39H, 7030-3CT”;;
5C) MODEL=”7013-560″;;
63) MODEL=”7015-970/97B”;;
64) MODEL=”7015-980/98B”;;
66) MODEL=”7013-580/58F”;;
67) MODEL=”7013-570/770/771/R10″;;
70) MODEL=”7013-590″;;
71) MODEL=”7013-58H”;;
72) MODEL=”7013-59H/R12″;;
75) MODEL=”7012-370/375/37T”;;
76) MODEL=”7012-360/365/36T”;;
77) MODEL=”7012-355/55H/55L”;;
79) MODEL=”7013-590″;;
80) MODEL=”7015-990″;;
82) MODEL=”7015-R24″;;
89) MODEL=”7013-595″;;
90) MODEL=”7009-C20″;;
91) MODEL=”7006-42x”;;
94) MODEL=”7012-397″;;
A0) MODEL=”7013-J30″;;
A1) MODEL=”7013-J40″;;
A3) MODEL=”7015-R30″;;
A4) MODEL=”7015-R40″;;
A6) MODEL=”7012-G30″;;
A7) MODEL=”7012-G40″;;
C0) MODEL=”7024-E20″;;
C4) MODEL=”7025-F40″;;
4C) MODEL=`uname -M`;;  # PCI systems
*) MODEL=”Unknown”;;
esac
# echo “Hostname         = ” $(hostname)
echo “Host/IP Address  = ” $(host $(hostname) )
echo “RS/6000 Model    = ” $MODEL

SN=$(lsattr -El sys0 -a systemid 2>/dev/null)
if [ $? -eq 0 ]
then
echo “Serial Number    = ” `echo $SN | awk ‘ { print $2 }’`
fi

echo “Number of CPU’s  = ” $(lscfg |grep -c “^+ proc”)
echo “Memory (KB)      = ” $(lsattr -El sys0 | awk ‘/realmem/ {print $2 }’)
echo “AIX Level        = ” $(oslevel)
echo “Number of hdisks = ” $(lspv |wc -l)
echo “Volume Groups”
# list volume groups disk avail/used

for i in $(lsvg)
do
lsvg $i
done | awk ‘
BEGIN      { printf(“%10s\t%10s\t%10s\t%10s\t%10s\n”,”VG”,”Total(MB)”,”Free”,”USED”,”Disks”) }
/VOLUME GROUP:/ { printf(“%10s\t”, $3)  }
/TOTAL PP/ {     B=index($0,”(“) + 1
E=index($0,” megaby”)
D=E-B
printf(“%10s\t”, substr($0,B,D) )
}
/FREE PP/  {     B=index($0,”(“) + 1
E=index($0,” megaby”)
D=E-B
printf(“%10s\t”, substr($0,B,D) )
}
/USED PP/  {     B=index($0,”(“)  + 1
E=index($0,” megaby”)
D=E-B
printf(“%10s\t”, substr($0,B,D) )
}
/ACTIVE PV/ { printf(“%10s\t\n”, $3)  } ‘

, , , , , , , , ,

Leave a comment