Skip to content

Instantly share code, notes, and snippets.

@shoyan
Created August 18, 2016 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoyan/5a8de2822f49713ae040e8db1924ac63 to your computer and use it in GitHub Desktop.
Save shoyan/5a8de2822f49713ae040e8db1924ac63 to your computer and use it in GitHub Desktop.
WordPressのアーカイブを作成するスクリプト
#!/bin/bash
#
# WordPressのアーカイブを作成するスクリプトです。
# 指定されたWordPressのバージョンにSiteGuardプラグインをいれて、アーカイブを作成します。
#
# Usage:
# ./wordpress.sh version
#
# Example:
# ./wordpress.sh 4.1.1
#
set -e
wp_version=$1
siteguard_version=1.3.0
red=31
yellow=33
cyan=36
function clean() {
cecho $yellow "Running clean task."
rm -rf wordpress
rm -rf wordpress-${wp_version}-ja.zip
rm -rf siteguard.${siteguard_version}.zip
cecho $yellow "Finished clean task."
}
function cecho() {
color=$1
shift
echo -e "\033[${color}m$@\033[m"
}
function run() {
trap 'clean; cecho $red "An error has occurred, script fails."' ERR
cecho $yellow "Running $@"
`$@`
cecho $yellow "Finished $@"
}
if [ $# -ne 1 ]; then
echo "versionを指定してください。 \"./wordpress.sh version\""
exit 1
fi
run "curl -O -s -S -f https://ja.wordpress.org/wordpress-${wp_version}-ja.zip"
run "unzip -q wordpress-${wp_version}-ja.zip"
run "curl -O -s -S -f https://downloads.wordpress.org/plugin/siteguard.${siteguard_version}.zip"
run "unzip -q siteguard.${siteguard_version}.zip"
run "mv siteguard wordpress/wp-content/plugins/"
run "zip -rq wordpress-${wp_version}.zip wordpress"
clean
cecho $cyan "Completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment