-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
10 changed files
with
264 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,72 @@ | ||
#!/bin/bash | ||
####################################### | ||
# Tencent is pleased to support the open source community by making Blueking Container Service available. | ||
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
# Licensed under the MIT License (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# http://opensource.org/licenses/MIT | ||
# Unless required by applicable law or agreed to in writing, software distributed under | ||
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
# either express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
####################################### | ||
|
||
set -euo pipefail | ||
|
||
# install jq | ||
SELF_DIR=$(dirname "$(readlink -f "$0")") | ||
ROOT_DIR="${SELF_DIR}/.." | ||
readonly SELF_DIR ROOT_DIR | ||
|
||
safe_source() { | ||
local source_file=$1 | ||
if [[ -f ${source_file} ]]; then | ||
#shellcheck source=/dev/null | ||
source "${source_file}" | ||
else | ||
echo "[ERROR]: FAIL to source, missing ${source_file}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
_curl_jq() { | ||
local url save_file version | ||
version=$1 | ||
url="${REPO_URL}/jq-${version}.xz" | ||
save_file="/tmp/jq.xz" | ||
if curl -sSfL "${url}" -o "${save_file}" -m "360"; then | ||
rm -f /tmp/jq | ||
unxz -dc ${save_file} >/tmp/jq | ||
chmod +x /tmp/jq | ||
mv /tmp/jq /usr/local/bin/jq | ||
rm -f ${save_file} | ||
else | ||
utils::log "ERROR" "fail to download jq" | ||
fi | ||
} | ||
|
||
_offline_jq() { | ||
# ToDo | ||
true | ||
} | ||
|
||
main() { | ||
local source_files | ||
source_files=("${ROOT_DIR}/functions/utils.sh" "${ROOT_DIR}/env/bcs.env") | ||
for file in "${source_files[@]}"; do | ||
safe_source "$file" | ||
done | ||
jq_ver=$(awk '/jq/{gsub("\"","",$2);print $2;exit}' \ | ||
"${ROOT_DIR}"/env/offline-manifest.yaml) | ||
|
||
if ! command -v jq >/dev/null; then | ||
if [[ -n ${BCS_OFFLINE:-} ]]; then | ||
_offline_jq | ||
else | ||
_curl_jq "$jq_ver" | ||
fi | ||
fi | ||
utils::log "OK" "installed $(jq -V)" | ||
} | ||
|
||
main |
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,91 @@ | ||
#!/bin/bash | ||
|
||
####################################### | ||
# Tencent is pleased to support the open source community by making Blueking Container Service available. | ||
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
# Licensed under the MIT License (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# http://opensource.org/licenses/MIT | ||
# Unless required by applicable law or agreed to in writing, software distributed under | ||
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
# either express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
####################################### | ||
|
||
set -euo pipefail | ||
|
||
# Process encapsulation of tool installation | ||
VERSION="1.0.0" | ||
PROGRAM="$(basename "$0")" | ||
SELF_DIR=$(dirname "$(readlink -f "$0")") | ||
ROOT_DIR="${SELF_DIR}/.." | ||
|
||
PROJECTS=(yq jq) | ||
|
||
readonly SELF_DIR ROOT_DIR PROJECTS | ||
|
||
usage_and_exit() { | ||
cat <<EOF | ||
Usage: | ||
$PROGRAM | ||
[ -h --help -? show usage ] | ||
[ -v -V --version show script version] | ||
[ ${PROJECTS[*]} ] | ||
EOF | ||
exit "$1" | ||
} | ||
|
||
version() { | ||
echo "$PROGRAM version $VERSION" | ||
} | ||
|
||
safe_source() { | ||
local source_file=$1 | ||
if [[ -f ${source_file} ]]; then | ||
#shellcheck source=/dev/null | ||
source "${source_file}" | ||
else | ||
echo "[ERROR]: FAIL to source, missing ${source_file}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main() { | ||
local source_files | ||
source_files=("${ROOT_DIR}/functions/utils.sh") | ||
for file in "${source_files[@]}"; do | ||
safe_source "$file" | ||
done | ||
|
||
local project | ||
|
||
(($# == 0)) && usage_and_exit 1 | ||
while (($# > 0)); do | ||
case "$1" in | ||
--help | -h | '-?') | ||
usage_and_exit 0 | ||
;; | ||
--version | -v | -V) | ||
version | ||
exit 0 | ||
;; | ||
-*) | ||
# ToDo: Unified standard error code | ||
export ERR_CODE=1 | ||
utils::log "ERROR" "unkown para: $1" | ||
;; | ||
*) | ||
project="${ROOT_DIR}/tools/install_$1" | ||
if [[ -x "${project}" ]]; then | ||
"${project}" | ||
else | ||
utils::log "ERROR" "can't exec ${project}" | ||
fi | ||
;; | ||
esac | ||
shift | ||
done | ||
return 0 | ||
} | ||
|
||
main "$@" |
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,73 @@ | ||
#!/bin/bash | ||
####################################### | ||
# Tencent is pleased to support the open source community by making Blueking Container Service available. | ||
# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
# Licensed under the MIT License (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# http://opensource.org/licenses/MIT | ||
# Unless required by applicable law or agreed to in writing, software distributed under | ||
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
# either express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
####################################### | ||
|
||
set -euo pipefail | ||
|
||
# install yq | ||
SELF_DIR=$(dirname "$(readlink -f "$0")") | ||
ROOT_DIR="${SELF_DIR}/.." | ||
readonly SELF_DIR ROOT_DIR | ||
|
||
safe_source() { | ||
local source_file=$1 | ||
if [[ -f ${source_file} ]]; then | ||
#shellcheck source=/dev/null | ||
source "${source_file}" | ||
else | ||
echo "[ERROR]: FAIL to source, missing ${source_file}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
_curl_yq() { | ||
local url save_file version | ||
version=$1 | ||
url="${REPO_URL}/yq-${version}.xz" | ||
save_file="/tmp/yq.xz" | ||
if curl -sSfL "${url}" -o "${save_file}" -m "360"; then | ||
# rm -f /tmp/yq | ||
unxz -dc ${save_file} >/tmp/yq | ||
chmod +x /tmp/yq | ||
mv /tmp/yq /usr/local/bin/yq | ||
rm -f ${save_file} | ||
else | ||
utils::log "ERROR" "fail to download yq: $url" | ||
fi | ||
} | ||
|
||
_offline_yq() { | ||
# ToDo | ||
true | ||
} | ||
|
||
main() { | ||
local source_files | ||
source_files=("${ROOT_DIR}/functions/utils.sh" "${ROOT_DIR}/env/bcs.env") | ||
for file in "${source_files[@]}"; do | ||
safe_source "$file" | ||
done | ||
yq_ver=$(awk '/yq/{gsub("\"","",$2);print $2;exit}' \ | ||
"${ROOT_DIR}"/env/offline-manifest.yaml) | ||
|
||
if ! command -v yq >/dev/null; then | ||
if [[ -n ${BCS_OFFLINE:-} ]]; then | ||
_offline_yq | ||
else | ||
_curl_yq "$yq_ver" | ||
fi | ||
fi | ||
utils::log "OK" "installed $(yq -V)" | ||
"$ROOT_DIR"/k8s/operate_completion yq | ||
} | ||
|
||
main |