Permalink
Browse files

Starting to add service update code.

  • Loading branch information...
1 parent 34c7e41 commit d079b4a57727df1b1e8dcd6ed21fe040e9bc06e5 @wayneeseguin wayneeseguin committed Jan 6, 2010
Showing with 67 additions and 42 deletions.
  1. +1 −0 .gitignore
  2. +11 −15 bin/bdsm
  3. +3 −0 config/bdsm
  4. +47 −0 services/bdsm/service
  5. +0 −24 services/bdsm/services
  6. +4 −2 services/bdsm/update
  7. +1 −1 services/unicorn/start
View
@@ -1,2 +1,3 @@
releases/
release
+site/
View
@@ -14,33 +14,31 @@ function version {
function usage {
version
- $services_path/bdsm/help | ${PAGER:-less}
+ "$services_path"/bdsm/help | ${PAGER:-less}
}
#
# Setup
#
prefix="${prefix:-/usr/local}"
-if [[ -f "$HOME/.bdsmrc" ]] ; then source "$HOME/.bdsmrc" ; fi
-source $prefix/bdsm/scripts/initialize
-source $prefix/bdsm/scripts/functions
+if [[ -s "$HOME/.bdsmrc" ]] ; then source "$HOME/.bdsmrc" ; fi
+source "$prefix"/bdsm/scripts/initialize
+source "$prefix"/bdsm/scripts/functions
+result=0
#
# parse args
#
while [ $# -gt 0 ] ; do
token="$1" ; shift
case "$token" in
-
- # TODO: deploy activates framework deploy after doing common deploy tasks (repo update, hooks).
- deploy|backup_database) service="bdsm" ; action="$token" ;;
-
# TODO: service detection "did you mean"
--project) export project="$1" ;;
--environment) export environment="$1" ;;
--repo|repository) export repository="$1" ;;
--database) export database="$1" ;;
--server) export server="$1" ;; # better name for this?
+ --head) export head_flag=1 ;;
--trace) export trace_flag=1 ; export debug_flag=1 ; set -x ;;
--debug) export debug_flag=1 ;;
-v|--version) action="version" ;;
@@ -50,8 +48,11 @@ while [ $# -gt 0 ] ; do
if [[ -z "$service" ]] ; then
if [[ -d "$services_path/$token" ]] ; then
export service="$token"
+ else
+ export service="${service:-bdsm}"
fi
- elif [[ -z "$action" ]] ; then
+ fi
+ if [[ -z "$action" ]] ; then
if [[ -x "$services_path/$service/$token" ]] ; then
export action="$token"
bdsm_args="$@"
@@ -79,18 +80,14 @@ if [[ ! -z "$error_message" ]] ; then exit 1 ; fi
#
# Main Logic
#
-result=0
-
if [[ "$trace_flag" = 1 ]] ; then set -x ; else set +x ; fi
if [[ "version" = "$action" ]] ; then
version
elif [[ ! -z "$service" ]] && [[ ! -z "$action" ]] ; then
if [[ -z "$project" ]] ; then
- echo -e "\$project is unspecified."
- exit 1
+ echo -e "\$project is unspecified." ; exit 1
fi
-
if [[ -s "$services_path/$service/$action" ]] ; then
$services_path/$service/$action $*
fi
@@ -99,7 +96,6 @@ elif [[ ! -z "$service" ]] ; then
else
usage
fi
-
result=$?
exit $result
View
@@ -1,2 +1,5 @@
releases_url=http://bdsm.beginrescueend.com/releases/
services_url=http://bdsm.beginrescueend.com/services/
+releases_url=http://bdsm.beginrescueend.com/releases/latest.tar.gz
+bdsm_repo_url=git://github.com/wayneeseguin/bdsm.git
+service_repo_url=git://github.com/wayneeseguin/bdsm-services.git
View
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+if [[ "$trace_flag" -eq 1 ]] ; then set -x ; fi
+
+result=0 ; action="$1" ; shift
+
+# TODO: set releases_url
+# TODO: set service_url
+# TODO: must be root.
+
+# TODO: Allow ',' separated service list.
+if [[ "install" = "$action" ]] || [[ "upgrade" = "$action" ]] ; then
+ mkdir -p "$src_path"
+ if [[ ! -z "$head_flag" ]] ; then
+ if [[ ! -d "$src_path/$service/.git" ]] ; then
+ "$scripts_path"/log "info" "Updating $service repository."
+ cd "$src_path/$service"/.git
+ # TODO: Branch update logic.
+ git pull origin "${branch:-master}"
+ else
+ "$scripts_path"/log "info" "Cloning $service repository from $service_repo_url."
+ cd "$src_path/$service/"
+ # TODO: git/hg/svn detection, git for now
+ git clone "$service_repo_url"
+ fi
+ else
+ rm -rf "$src_path/latest"
+ mkdir -p "$src_path/latest"
+ curl -O "$releases_url" | tar xf - -C "$src_path/latest"
+ # TODO: error check and exit on error.
+ cd "$src_path/latest"/bdsm-*
+ ./install
+ fi
+elif [[ "uninstall" = "$action" ]] ; then
+ for service in $* ; do
+ if [[ -d "$services_path/$service/" ]] ; then
+ rm -rf "$services_path/$service/"
+ "$scripts_path"/log "info" "$service removed."
+ else
+ "$scripts_path"/log "info" "$service is already non-existant."
+ fi
+ done
+else
+ "$scripts_path"/log "error" "One action {install,uninstall,upgrade} must be specified with 'service'." ; result=1
+fi
+
+exit $result
View
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-result=0
-if [[ ! -z "$install_flag" ]] ; then
- if [[ ! -z "$head_flag" ]] ; then
- for service in $* ; do
- done
- else
- for service in $* ; do
- curl -O
- done
- fi
-elif [[ ! -z "$uninstall_flag" ]] ; then
- for service in $* ; do
- if [[ -d "$services_path/$service/" ]] ; then
- rm -rf "$services_path/$service/"
- $scripts_path/log "info" "$service removed."
- fi
- done
-else
- $scripts_path/log "error" "One action {install,uninstall} must be specified for listed services."
- exit 1
-fi
-exit $result
View
@@ -2,6 +2,8 @@
result=0
+#TODO: set bdsm_repo_url
+
mkdir -p "$src_path"
__pushpop "$src_path"
@@ -19,9 +21,9 @@ fi
if [[ "head" = "$ruby_revision" ]] || [[ -z "$system_ruby" ]] ; then
if [[ -d "$src_path/rvm/.git" ]] ; then
- builtin cd $src_path/rvm/ && git pull origin master && ./scripts/install
+ builtin cd $src_path/rvm/ && git pull origin && ./scripts/install
else
- builtin cd $src_path && git clone git://github.com/wayneeseguin/rvm.git && builtin cd rvm/ && ./install
+ builtin cd $src_path && git clone "$bdsm_repo_url" && builtin cd rvm/ && ./install
fi
else
if [[ "true" = "$($ruby -S gem list rvm --installed)" ]]; then
View
@@ -7,7 +7,7 @@ if [[ "$trace_flag" -eq 1 ]] ; then set -x ; fi
master_pid="$(ps auxww | grep '[u]nicorn' | grep 'master' | awk '/'${project}'/{print $2}')"
cd $current_path
-if [[ ! -z ".rvmrc" ]] ; then source ".rvmrc" ; fi
+if [[ -s ".rvmrc" ]] ; then source ".rvmrc" ; fi
if [[ "$master_pid" -gt 0 ]] ; then
$scripts_path/log "info" "Unicorn herd is already running for $project."

0 comments on commit d079b4a

Please sign in to comment.