Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyzhang committed Apr 10, 2016
1 parent 3530558 commit b7ed12f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 49 deletions.
49 changes: 0 additions & 49 deletions common_library/enable_common_library.sh

This file was deleted.

42 changes: 42 additions & 0 deletions common_library/refresh_common_library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash -e
##-------------------------------------------------------------------
## @copyright 2016 DennyZhang.com
## File : refresh_common_library.sh
## Author : Denny <[email protected]>
## Description : Use this file to update common library.
## By default, this file keeps stable and untouched
## --
## Created : <2016-04-07>
## Updated: Time-stamp: <2016-04-10 14:47:15>
##-------------------------------------------------------------------
function refresh_common_library() {
local library_file=${1?}
local library_url=${2?}
local library_file_checksum=${3?}

if [ "x${AVOID_REFRESH_LIBRARY}" != "true" ]; then
if [ "x${library_file_checksum}" = "x" ]; then
wget -O $library_file $library_url
else
if [ ! -f $library_file ]; then
echo "download bash common library"
wget -O $library_file $library_url
else
checksum=$(cksum $library_file | awk -F' ' '{print $1}')
if [ "$library_file_checksum" != "$checksum" ]; then
echo "refresh bash common library"
wget -O $library_file $library_url
fi
fi
fi
fi
}

# When checksum is not given, we will force re-download
file_checksum=${1:-"checksum for common bash library"}
library_download_path=${2:-"/var/lib/devops/devops_common_library.sh"}
library_url=${3:-"https://raw.githubusercontent.com/DennyZhang/devops_public/master/common_library/devops_common_library.sh"}
dir_name=$(dirname $library_download_path)

refresh_common_library $library_download_path $library_url $file_checksum
## File : refresh_common_library.sh ends

0 comments on commit b7ed12f

Please sign in to comment.