Skip to content

Instantly share code, notes, and snippets.

@yadex205 yadex205/init.sh
Created May 1, 2016

Embed
What would you like to do?
お手軽WordPress環境構築スクリプト
#!/bin/bash
# プロジェクトルート/bin/init.sh のように配置してください。
# ルート/vendor にwp-cli.pharを、ルート/htdocsにWordPressを配置します。
WPCLI_BIN="vendor/wp-cli.phar"
WPCLI="$WPCLI_BIN --path=htdocs"
WP_INSTALL_DIR="htdocs"
TITLE='a wordpress site'
URL='localhost:8080'
NAME='wp'
PASSWORD='wp'
EMAIL='wp@example.com'
while getopts t:u:n:p:e: OPT
do
case $OPT in
t) TITLE=$OPTARG
;;
u) URL=$OPTARG
;;
n) NAME=$OPTARG
;;
p) PASSWORD=$OPTARG
;;
e) EMAIL=$OPTARG
esac
done
install_wpcli () {
echo "Begin installing WP-CLI."
if [ ! -d vendor ]; then
mkdir vendor
fi
curl -s -S https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o $WPCLI_BIN && \
chmod +x $WPCLI_BIN && \
echo "Finished installing WP-CLI."
}
download_wp () {
echo "Begin downloading WordPress"
if [ ! -d $WP_INSTALL_DIR ]; then
mkdir $WP_INSTALL_DIR
fi
$WPCLI core download --locale=ja && \
echo "Finished downloading WordPress."
}
install_sqlite_integration () {
echo "Begin installing sqlite-integration plugin."
curl -s -S https://downloads.wordpress.org/plugin/sqlite-integration.zip -o tmp/sqlite-integration.zip && \
unzip -q tmp/sqlite-integration.zip -d htdocs/wp-content/plugins && \
cp htdocs/wp-content/plugins/sqlite-integration/db.php htdocs/wp-content/db.php &&
echo "Finished installing sqlite-integration plugin."
}
install_wp () {
echo "Begin installing WordPress."
config_file="$WP_INSTALL_DIR/wp-config.php"
echo '<?php' > $config_file && \
curl -s -S https://api.wordpress.org/secret-key/1.1/salt/ >> $config_file && \
cat << EOF >> $config_file && echo "Finished installing WordPress.";
\$table_prefix = 'wp_';
define('WP_DEBUG', true);
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
?>
EOF
}
configure_wp () {
echo "Begin configuring WordPress."
$WPCLI core install --url="$URL" --title="$TITLE" --admin_name="$NAME" --admin_password="$PASSWORD" --admin_email="$EMAIL" && \
echo "Finished configuring WordPress."
}
pushd `dirname $0`/../
if [ ! -d tmp ]; then
mkdir tmp
fi
install_wpcli
download_wp
install_sqlite_integration
install_wp
configure_wp
rm -rf tmp
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.