Created
October 21, 2010 18:53
-
-
Save Servana/639071 to your computer and use it in GitHub Desktop.
Installs Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# == Synopsis | |
# This is a SkyScript launched by Skystack, it was adapted from the StackScript used at Linode. | |
# | |
# == Website | |
# http://skystack.com | |
# == Author | |
# Tass Skoudros | |
# | |
# == Parameters | |
# The only parameters required are | |
# DB_NAME - Database name | |
# DB_USER - Database user | |
# VPATH - virtualhost path | |
# | |
# == Copyright | |
# Copyright (c) 2010 Skystack Limited. Licensed under the MIT License: | |
# http://www.opensource.org/licenses/mit-license.php | |
SKYSTACK_PATH=/opt/skystack | |
PROVIDER=`cat /etc/skystack.d/provider` | |
wordpress_install(){ | |
if [ $PROVIDER = 'ec2' ]; | |
then | |
INTERNAL_HOST=`curl http://169.254.169.254/latest/meta-data/local-hostname` | |
fi | |
if [ $PROVIDER = 'linode' ]; | |
then | |
INTERNAL_HOST=`awk '/SS_HOST/ {print $2}' FS=\= $SKYSTACK_PATH/bootstrapper/etc/userdata.conf` > /dev/null 2>&1 | |
fi | |
DB_NAME=wordpress | |
DB_USER=wordpress | |
VPATH=/var/www/example.com | |
DB_PWD=`cat /opt/skystack/bootstrapper/etc/.mysql.wordpress.shadow` | |
# installs the latest wordpress tarball from wordpress.org | |
if [ ! -e /usr/bin/wget ]; then | |
aptitude -y install wget | |
fi | |
if [ ! -n "$VPATH" ]; then | |
echo "Could not determine DocumentRoot for $VPATH" | |
return 1; | |
fi | |
# download, extract, chown, and get our config file started | |
if [ -e "/opt/skystack/src/latest.tar.gz" ]; | |
then | |
sudo gunzip < /opt/skystack/src/latest.tar.gz | tar -xf - -C $VPATH/ | |
else | |
cd "/opt/skystack/src"; | |
sudo wget http://wordpress.org/latest.tar.gz | |
sudo gunzip < /opt/skystack/src/latest.tar.gz | tar -xf - -C $VPATH/ | |
fi | |
if [ -e $VPATH/index.php ]; then | |
sudo mv $VPATH/index.php $VPATH/info.php | |
fi | |
if [ -e $VPATH/wordpress ]; then | |
sudo cp -R $VPATH/wordpress/* $VPATH/ | |
sudo rm -rf $VPATH/wordpress | |
fi | |
sudo cp $VPATH/wp-config-sample.php $VPATH/wp-config.php | |
sudo chmod 640 $VPATH/wp-config.php | |
sudo chown -R www-data:www-data $VPATH/ | |
# database configuration | |
# WPPASS=$(randomString 20) | |
# configuration file updates | |
for i in {1..4} | |
do sudo sed -i "0,/put your unique phrase here/s/put your unique phrase here/$(randomString 50)/" $VPATH/wp-config.php | |
done | |
sudo sed -i "s/database_name_here/$DB_NAME/" $VPATH/wp-config.php | |
sudo sed -i "s/username_here/$DB_USER/" $VPATH/wp-config.php | |
sudo sed -i "s/password_here/$DB_PWD/" $VPATH/wp-config.php | |
exit 0 | |
} | |
randomString(){ | |
if [ ! -n "$1" ]; | |
then LEN=20 | |
else LEN="$1" | |
fi | |
echo `</dev/urandom tr -dc A-Za-z0-9 | head -c $LEN` | |
} | |
wordpress_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment