diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 21:03:27 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 21:03:27 +0100 |
commit | 179b0d5750cd5a6263563858ade46815d434c4d9 (patch) | |
tree | 016fad94ab2c04d669e9b1c43be0ad38b6f7d019 /deploy-ruby-tasks | |
parent | 2bb34218520b9b95177e4f8421d2cdfe583a1420 (diff) | |
download | bin-179b0d5750cd5a6263563858ade46815d434c4d9.zip bin-179b0d5750cd5a6263563858ade46815d434c4d9.tar.gz |
add deploy-ruby-tasks
Diffstat (limited to 'deploy-ruby-tasks')
-rwxr-xr-x | deploy-ruby-tasks | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/deploy-ruby-tasks b/deploy-ruby-tasks new file mode 100755 index 0000000..e1d3321 --- /dev/null +++ b/deploy-ruby-tasks @@ -0,0 +1,61 @@ +#! /bin/sh + +for arg in $@; do + option=`echo "'$arg'" | cut -d'=' -f1 | tr -d "'"` + value=`echo "'$arg'" | cut -d'=' -f2- | tr -d "'"` + if [ "$value" == "$option" ]; then value=""; fi + case "$option" in + -d|--git-dir) GIT_DIR=$value;; + -t|--tasks-dir) TASKS_DIR=$value;; + *) GIT_REMOTE=$arg;; + esac +done + +GIT_DIR=${GIT_DIR:-$HOME/usr/git} +TASKS_DIR=${TASKS_DIR:-$GIT_DIR/templates/ruby-gem/tasks} +DIFF_OPTS=${DIFF_OPTS:--y --suppress-common-lines} + +RESET="\033[0m" +RED="\033[0;31m" +GREEN="\033[0;32m" +BROWN="\033[0;33m" +PURPLE="\033[0;35m" +CYAN="\033[0;36m" +YELLOW="\033[1;33m" + +function update() { + echo -e "\n${BROWN}${1}${RESET} : ${YELLOW}${2} ${PURPLE}${3}${RESET} differs ..." + diff ${DIFF_OPTS} ${3} ${2} + read -p " update it? [yN]" RET + if [ "${RET}" = "Y" -o "${RET}" = "y" ]; then + cp ${2} ${3} + fi +} + +function copy() { + echo -e "\n${BROWN}${1}${RESET} : ${PURPLE}${3}${RESET} does not exists" + read -p " create it? [yN]" RET + if [ "${RET}" = "Y" -o "${RET}" = "y" ]; then + cp ${2} ${3} + fi +} + +echo -e "task dir:${YELLOW}${TASKS_DIR}${RESET}" +for gitdir in ${GIT_DIR}; do + echo -e "enter ${BROWN}${gitdir}${RESET}" && cd ${gitdir} || return 1 + for dir in $(ls -1); do + [ -d ${dir} ] && [ -e ${dir}/tasks/gem.rake ] || continue + # SEARCH REMOTE + echo -e " enter ${BROWN}${dir}${RESET}" && cd $dir || exit 1 + for task_file in ${TASKS_DIR}/*; do + dest="./tasks/${task_file##*/}" + if [ -e $dest ]; then + cmp -s ${task_file} ${dest} || update ${dir} ${task_file} ${dest} + else + copy ${dir} ${task_file} ${dest} + fi + done + echo -e " leave ${BROWN}${dir}${RESET}\n" && cd .. || exit 1 + done + echo -e "leave ${BROWN}${gitdir}${RESET}" +done |