Created
January 13, 2012 18:49
-
-
Save DQNEO/1608027 to your computer and use it in GitHub Desktop.
簡易デプロイツール
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 | |
# | |
# deploy.sh : subversion用のデプロイツール | |
# | |
# | |
# Usage: | |
# deploy.sh | |
# 引数はありません。 | |
# | |
# Output: | |
# 標準出力:処理の進捗メッセージ | |
# ステータスコード:成功0, 失敗1 | |
# | |
# Description: | |
# | |
# - svn属性について | |
# svn属性をつけます。 | |
# svn ps svn:executable * | |
# svn ps svn:eol-style LF | |
# | |
# | |
# - ファイル名・ディレクトリ名について | |
# 必ずreadonlyで定数として宣言する | |
# basenameのみの場合は、HOGE_FILENAME, BAR_DIRNAME | |
# fullpathの場合は、 HOGE_FILE, BAR_DIR | |
# | |
# (コーディング規約 http://shellscript.sunone.me/tips.html より) | |
# | |
################################################# | |
## 定数の宣言 | |
# | |
# プロジェクト名(通常はドメイン名) | |
readonly PROJECT_NAME="www.example.com" | |
## パスの設定 | |
# ディレクトリ末尾の/はなし | |
readonly PROJECT_DIR="$HOME/$PROJECT_NAME" | |
readonly TRUNK_DIR="$PROJECT_DIR/trunk" | |
readonly HONBAN_DIR="$PROJECT_DIR/honban" | |
readonly BASE_DIRNAME="now" | |
## 処理実行 | |
# | |
# svn stで結果がある場合は処理中断 | |
RET=$(svn st $TRUNK_DIR ) | |
if [ -n "$RET" ] ; then | |
echo "error:svn st has results" | |
echo $RET | |
exit 1 | |
fi | |
# svn up | |
svn up $TRUNK_DIR || { echo "error:svn up"; exit 1; } | |
echo "svn up trunk $TRUNK_DIR ok" | |
# リビジョン番号を取得 | |
REVNO=$(svnversion -n $TRUNK_DIR) | |
echo "revision:$REVNO" | |
# svn export | |
svn export $TRUNK_DIR $HONBAN_DIR/$REVNO || { echo "error:svn export"; exit 1; } | |
echo "svn export ok" | |
# シムリンク張り替え | |
rm $HONBAN_DIR/$BASE_DIRNAME || { echo "error:rm symlink"; exit 1; } | |
ln -s $REVNO $HONBAN_DIR/$BASE_DIRNAME || { echo "error:ln -s "; exit 1; } | |
echo " " | |
echo "everything ok! \(^^)/" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment