diff --git a/files/scripts/get_file.sh b/files/scripts/get_file.sh index 6173362..f0871ad 100644 --- a/files/scripts/get_file.sh +++ b/files/scripts/get_file.sh @@ -18,6 +18,7 @@ showhelp () { echo "-s - The URL of the file to get" echo "-t - The type of file that is retrieved: list|tarball|maven-metadata|dir" echo "-d - An alternative destination directory (default is automatically chosen)" + echo "-f - An alternative destination file name (default is automatically chosen)" echo "-a - If 'no' return a special error code (99) if the download checksum is the same of the one previously downloaded" echo "-u - in case of type http, specify a http_user for curl" echo "-p - in case of type http, specifiy http_user for curl" @@ -77,6 +78,9 @@ while [ $# -gt 0 ]; do # Enforces and overrides and alternative downloaddir downloaddir=$2 shift 2 ;; + -f) + destfilename=$2 + shift 2 ;; -a) alwaysdeploy=$2 shift 2 ;; @@ -115,11 +119,19 @@ case $type in save_runtime_config "downloadedfile=$downloaddir/$downloadfilename" ;; http|https) - if [ -z "$http_password" ] ; then - curl $ssl_arg -s -f -L "$url" -O + if [ ! -z "$destfilename" ] ; then + destfilename_arg="-o $destfilename" else - curl $ssl_arg -s -f -L --anyauth --user $http_user:$http_password "$url" -O - fi + destfilename_arg="-O" + fi + + if [ ! -z "$http_password" ] ; then + httpauth_arg="--anyauth --user $http_user:$http_password" + else + httpauth_arg="" + fi + + curl $ssl_arg -s -f -L $httpauth_arg "$url" $destfilename_arg check_retcode save_runtime_config "downloadedfile=$downloaddir/$downloadfilename" ;; diff --git a/manifests/project/war.pp b/manifests/project/war.pp index 60f3f99..1a92fed 100644 --- a/manifests/project/war.pp +++ b/manifests/project/war.pp @@ -16,6 +16,11 @@ # [*deploy_root*] # The destination directory where the retrieved file(s) are deployed. # +# [*war_file*] +# (Optional) - The destination war file name where the retrieved file +# is deployed. In the case of a single war file that already has a version +# specifies the name and needs to be renamed. +# # [*init_source*] # (Optional) - The full URL to be used to retrieve, for the first time, # the project files. They are copied directly to the $deploy_root @@ -117,6 +122,7 @@ define puppi::project::war ( $source, $deploy_root, + $war_file = undef, $init_source = '', $user = 'root', $predeploy_customcommand = '', @@ -173,8 +179,9 @@ $bool_check_deploy = any2bool($check_deploy) $bool_auto_deploy = any2bool($auto_deploy) - $war_file = url_parse($source,'filename') - + if ($war_file == undef) { + $war_file = url_parse($source,'filename') + } ### CREATE PROJECT puppi::project { $name: @@ -187,7 +194,7 @@ puppi::initialize { "${name}-Deploy_Files": priority => '40' , command => 'get_file.sh' , - arguments => "-s ${init_source} -d ${deploy_root}" , + arguments => "-s '${init_source}' -d '${deploy_root}'" , user => $user , project => $name , enable => $enable , @@ -211,7 +218,7 @@ puppi::deploy { "${name}-Retrieve_WAR": priority => '20' , command => 'get_file.sh' , - arguments => "-s ${source} -a ${real_always_deploy}" , + arguments => "-s '${source}' -a '${real_always_deploy}' -f '${war_file}'" , user => 'root' , project => $name , enable => $enable , @@ -232,7 +239,7 @@ puppi::deploy { "${name}-Backup_existing_WAR": priority => '30' , command => 'archive.sh' , - arguments => "-b ${deploy_root} -t war -s move -m diff -o '${backup_rsync_options}' -n ${backup_retention}" , + arguments => "-b '${deploy_root}' -t war -s copy -m diff -o '${backup_rsync_options}' -n '${backup_retention}'" , user => 'root' , project => $name , enable => $enable , @@ -243,7 +250,7 @@ puppi::deploy { "${name}-Check_undeploy": priority => '32' , command => 'checkwardir.sh' , - arguments => "-a ${deploy_root}/${war_file}" , + arguments => "-a '${deploy_root}/${war_file}'" , user => $user , project => $name , enable => $enable , @@ -287,7 +294,7 @@ puppi::deploy { "${name}-Deploy_WAR": priority => '40' , command => 'deploy_files.sh' , - arguments => "-d ${deploy_root} -c ${bool_clean_deploy}", + arguments => "-d '${deploy_root}' -c '${bool_clean_deploy}'", user => $user , project => $name , enable => $enable , @@ -330,7 +337,7 @@ puppi::deploy { "${name}-Check_deploy": priority => '45' , command => 'checkwardir.sh' , - arguments => "-p ${deploy_root}/${war_file}" , + arguments => "-p '${deploy_root}/${war_file}'" , user => $user , project => $name , enable => $enable , @@ -378,7 +385,7 @@ puppi::rollback { "${name}-Remove_existing_WAR": priority => '30' , command => 'delete.sh' , - arguments => "${deploy_root}/${war_file}" , + arguments => "'${deploy_root}/${war_file}'" , user => 'root' , project => $name , enable => $enable , @@ -388,7 +395,7 @@ puppi::rollback { "${name}-Check_undeploy": priority => '36' , command => 'checkwardir.sh' , - arguments => "-a ${deploy_root}/${war_file}" , + arguments => "-a '${deploy_root}/${war_file}'" , user => $user , project => $name , enable => $enable , @@ -431,7 +438,7 @@ puppi::rollback { "${name}-Recover_Files_To_Deploy": priority => '40' , command => 'archive.sh' , - arguments => "-r ${deploy_root} -t war -o '${backup_rsync_options}'" , + arguments => "-r '${deploy_root}' -t war -o '${backup_rsync_options}'" , user => $user , project => $name , enable => $enable , @@ -474,7 +481,7 @@ puppi::rollback { "${name}-Check_deploy": priority => '45' , command => 'checkwardir.sh' , - arguments => "-p ${deploy_root}/${war_file}" , + arguments => "-p '${deploy_root}/${war_file}'" , user => $user , project => $name , enable => $enable ,