Permalink
Browse files

Added flags for sudo and overriding user. Also adding a nice little w…

…hoami test script.
  • Loading branch information...
1 parent edd117d commit 9e8aae3af82457e87aeec34111b65ae0ef135848 @mm53bar mm53bar committed Mar 1, 2013
Showing with 15 additions and 7 deletions.
  1. +3 −3 .env.sample
  2. +11 −4 bin/plow
  3. +1 −0 bin/whoami
View
6 .env.sample
@@ -1,9 +1,9 @@
# deploy to:
SERVER=server.com
-APP=app_name
-DEPLOY=/srv/$APP
+USER=app_name
+DEPLOY=/srv/$USER
ENVIRONMENT=production
# clone source from:
REPO=ssh://git@github.com/username/repo.git
-BRANCH=master
+BRANCH=master
View
15 bin/plow
@@ -13,6 +13,7 @@ recipe https://raw.github.com/mm53bar/plow/recipes/bin/migrate
recipe https://raw.github.com/mm53bar/plow/recipes/bin/start
recipe https://raw.github.com/mm53bar/plow/recipes/bin/stop
recipe https://raw.github.com/mm53bar/plow/recipes/bin/status
+recipe https://raw.github.com/mm53bar/plow/recipes/bin/whoami
bail() {
echo -e "\033[31m failed: $1\033[0m"
@@ -23,21 +24,28 @@ info() {
echo -e "\033[1;33m== $1\033[0m"
}
-ENVIRONMENT=production
-
while test $# != 0; do
case "$1" in
--staging|staging)
[[ -f .env.staging ]] || bail "no .env.staging found"
ENVIRONMENT=staging
+ source .env.$ENVIRONMENT
;;
--production|production)
[[ -f .env.production ]] || bail "no .env.production found"
ENVIRONMENT=production
+ source .env.$ENVIRONMENT
+ ;;
+ --sudo|sudo)
+ SUDO=sudo
;;
--rev=*)
REF="${1#--rev=}"
;;
+ --*)
+ tmp=${1:2}
+ eval ${tmp%=*}=${tmp#*=}
+ ;;
*)
[[ -f .plow/$(basename $1) ]] && recipes+=(".plow/$(basename $1)")
;;
@@ -50,5 +58,4 @@ for recipe in ${recipes[@]} ; do
recipe_content+=`echo;echo "echo '== Processing recipe: $(basename $recipe)'"`
recipe_content+=`echo;cat $recipe`
done
-source .env.$ENVIRONMENT
-ssh $APP@$SERVER "echo '$recipe_content' > plow.sh && $sudo bash plow.sh"
+ssh $USER@$SERVER "echo '$recipe_content' > plow.sh && $SUDO bash plow.sh"
View
1 bin/whoami
@@ -0,0 +1 @@
+whoami

0 comments on commit 9e8aae3

Please sign in to comment.