Skip to content

Instantly share code, notes, and snippets.

@haet
Forked from vishd/wp-shell-install.sh
Last active December 28, 2015 13:49
Show Gist options
  • Save haet/7510055 to your computer and use it in GitHub Desktop.
Save haet/7510055 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost
echo "MySQL DB Name:"
read mysqldb
export mysqldb
echo "MySQL DB User:"
read mysqluser
export mysqluser
echo "MySQL Password:"
read mysqlpass
export mysqlpass
# WP Variables
echo "Site Title:"
read wptitle
export wptitle
echo "Admin Username:"
read wpuser
export wpuser
echo "Admin Password:"
read wppass
export wppass
echo "Admin Email"
read wpemail
export wpemail
# Site Variables
echo "Site URL (ie, www.youraddress.com):"
read siteurl
export siteurl
#Ftp data
echo "FTP Server:"
read ftpserver
export ftpserver
echo "FTP User:"
read ftpuser
export ftpuser
echo "FTP Password:"
read ftppassword
export ftppassword
echo "FTP directory:"
read ftpdir
export ftpdir
# Download latest WordPress and uncompress
wget http://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz
#mv wordpress/* ./
rm readme.html license.txt
#get language
#http://www.naden.de/blog/wordpress-shellscript-install
WORDPRESS_LANGUAGE=de_DE
# get extra language file
#
if [ ! -z "${WORDPRESS_LANGUAGE}" ]; then
mkdir worpress/wp-content/languages
wget http://svn.automattic.com/wordpress-i18n/${WORDPRESS_LANGUAGE}/trunk/messages/${WORDPRESS_LANGUAGE}.mo -O wordpress/wp-content/languages/${WORDPRESS_LANGUAGE}.mo
wget http://svn.automattic.com/wordpress-i18n/${WORDPRESS_LANGUAGE}/trunk/messages/${WORDPRESS_LANGUAGE}.po -O wordpress/wp-content/languages/${WORDPRESS_LANGUAGE}.po
wget http://svn.automattic.com/wordpress-i18n/${WORDPRESS_LANGUAGE}/trunk/messages/admin-${WORDPRESS_LANGUAGE}.mo -O wordpress/wp-content/languages/admin-${WORDPRESS_LANGUAGE}.mo
wget http://svn.automattic.com/wordpress-i18n/${WORDPRESS_LANGUAGE}/trunk/messages/admin-${WORDPRESS_LANGUAGE}.po -O wordpress/wp-content/languages/admin-${WORDPRESS_LANGUAGE}.po
sed "s/WPLANG', /WPLANG', '${WORDPRESS_LANGUAGE}'/g" wordpress/wp-config-sample.php > wordpress/wp-config-sample.php.$$
fi
#get my standard plugins
cd wordpress/wp-content/plugins/
cd ../../
# Grab our Salt Keys
wget -O /tmp/wp.keys https://api.wordpress.org/secret-key/1.1/salt/
# Butcher our wp-config.php file
sed -e "s/localhost/"$mysqlhost"/" -e "s/database_name_here/"$mysqldb"/" -e "s/username_here/"$mysqluser"/" -e "s/password_here/"$mysqlpass"/" wordpress/wp-config-sample.php > wordpress/wp-config.php
sed -i '/#@-/r /tmp/wp.keys' wordpress/wp-config.php
sed -i "/#@+/,/#@-/d" wordpress/wp-config.php
#FTP upload
ftp -n -v $ftpserver << EOT
ascii
user $ftpuser $ftppassword
mkdir $ftpdir
cd $ftpdir
prompt
mput wordpress/*
bye
EOT
# Run our install ...
curl -d "weblog_title=$wptitle&user_name=$wpuser&admin_password=$wppass&admin_password2=$wppass&admin_email=$wpemail" http://$siteurl/wp-admin/install.php?step=2
# Tidy up
rmdir wordpress
rm latest.tar.gz
rm /tmp/wp.keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment