equal
deleted
inserted
replaced
|
1 #!/bin/bash |
|
2 # deploy.sh - Made for Puppi |
|
3 |
|
4 # Sources common header for Puppi scripts |
|
5 . $(dirname $0)/header || exit 10 |
|
6 |
|
7 # Show help |
|
8 showhelp () { |
|
9 echo "This script deploys the files present in the \$predeploydir to the deploy destination dir" |
|
10 echo "It has the following options:" |
|
11 echo "\$1 (Required) - Destination directory where to deploy files" |
|
12 echo "\$2 (Optional) - Name of the variable that identifies a specific predeploydir" |
|
13 echo |
|
14 echo "Examples:" |
|
15 echo "deploy.sh /var/www/html/my_app" |
|
16 echo "deploy.sh /var/www/html/my_app/conf config" |
|
17 } |
|
18 |
|
19 # Check arguments |
|
20 if [ $1 ] ; then |
|
21 deploy_destdir=$1 |
|
22 # This breaks on projects::maven when using more than one deploy destinations |
|
23 # [ $deploy_root ] && deploy_destdir=$deploy_root |
|
24 else |
|
25 showhelp |
|
26 exit 2 |
|
27 fi |
|
28 |
|
29 # Obtain the value of the variable with name passed as second argument |
|
30 # If no one is given, we take all the files in $predeploydir |
|
31 if [ $2 ] ; then |
|
32 deployfilevar=$2 |
|
33 deploy_sourcedir="$(eval "echo \${$(echo ${deployfilevar})}")" |
|
34 if [ "$deploy_sourcedir" = "" ] ; then |
|
35 exit 0 |
|
36 fi |
|
37 else |
|
38 deploy_sourcedir="$predeploydir" |
|
39 fi |
|
40 |
|
41 # Copy files |
|
42 deploy () { |
|
43 case "$debug" in |
|
44 yes) |
|
45 rsync -rlptDv $deploy_sourcedir/ $deploy_destdir/ |
|
46 check_retcode |
|
47 ;; |
|
48 full) |
|
49 rsync -rlptDv $deploy_sourcedir/ $deploy_destdir/ |
|
50 check_retcode |
|
51 ;; |
|
52 *) |
|
53 rsync -rlptD $deploy_sourcedir/ $deploy_destdir/ |
|
54 check_retcode |
|
55 ;; |
|
56 esac |
|
57 } |
|
58 |
|
59 deploy |