forked from dennyzhang/devops_public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3530558
commit b7ed12f
Showing
2 changed files
with
42 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |