Skip to content

Instantly share code, notes, and snippets.

@shoyan shoyan/wordpress.sh
Created Aug 18, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.