feat: add copyright

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-07-04 11:15:20 +08:00
parent 91979285eb
commit 21789bd7ac
341 changed files with 5137 additions and 439 deletions
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
image=openim/open_im_server:v1.0.5
rm Open-IM-Server -rf
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
version=errcode
repository=${1}
if [[ -z ${repository} ]]
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# http://stackoverflow.com/a/21142256/2055281
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
echo "docker-compose ps..........................."
cd ..
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
version="${VERSION}"
if [ "${version}" == "" ];then
version=v`gsemver bump`
fi
if [ -z "`git tag -l ${version}`" ];then
git tag -a -m "release version ${version}" ${version}
fi
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
source ./enterprise/path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#input:[10023,2323,3434]
#output:10023 2323 3434
list_to_string(){
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
echo -e "check time synchronize.................................."
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#input:[10023,2323,3434]
#output:10023 2323 3434
list_to_string(){
-1
View File
@@ -28,7 +28,6 @@ LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(main|master|develop)$|(feature|feat|release|hotfix|test|bug|ci|style|)\/[a-z0-9._-]+$|^HEAD$"
YELLOW="\e[93m"
GREEN="\e[32m"
RED="\e[31m"
+14
View File
@@ -1,3 +1,17 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ../.env
+14 -4
View File
@@ -1,8 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
#Define color variables
#Feature
@@ -22,7 +32,7 @@ COLOR_BBLUE='\033[44m';COLOR_BMAGENTA='\033[45m';
COLOR_BCYAN='\033[46m';COLOR_BWHITE='\033[47m';
# Print colors you can use
iam::color::print_color()
openim::color::print_color()
{
echo
echo -e ${bmagenta}--back-color:${normal}
+81 -71
View File
@@ -1,152 +1,162 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
# shellcheck disable=SC2034 # Variables sourced in other scripts.
# The server platform we are building on.
readonly IAM_SUPPORTED_SERVER_PLATFORMS=(
readonly OPENIM_SUPPORTED_SERVER_PLATFORMS=(
linux/amd64
linux/arm64
)
# If we update this we should also update the set of platforms whose standard
# library is precompiled for in build/build-image/cross/Dockerfile
readonly IAM_SUPPORTED_CLIENT_PLATFORMS=(
readonly OPENIM_SUPPORTED_CLIENT_PLATFORMS=(
linux/amd64
linux/arm64
)
# The set of server targets that we are only building for Linux
# If you update this list, please also update build/BUILD.
iam::golang::server_targets() {
openim::golang::server_targets() {
local targets=(
iam-apiserver
iam-authz-server
iam-pump
iam-watcher
openim-apiserver
openim-authz-server
openim-pump
openim-watcher
)
echo "${targets[@]}"
}
IFS=" " read -ra IAM_SERVER_TARGETS <<< "$(iam::golang::server_targets)"
readonly IAM_SERVER_TARGETS
readonly IAM_SERVER_BINARIES=("${IAM_SERVER_TARGETS[@]##*/}")
IFS=" " read -ra OPENIM_SERVER_TARGETS <<< "$(openim::golang::server_targets)"
readonly OPENIM_SERVER_TARGETS
readonly OPENIM_SERVER_BINARIES=("${OPENIM_SERVER_TARGETS[@]##*/}")
# The set of server targets we build docker images for
iam::golang::server_image_targets() {
# NOTE: this contains cmd targets for iam::build::get_docker_wrapped_binaries
openim::golang::server_image_targets() {
# NOTE: this contains cmd targets for openim::build::get_docker_wrapped_binaries
local targets=(
cmd/iam-apiserver
cmd/iam-authz-server
cmd/iam-pump
cmd/iam-watcher
cmd/openim-apiserver
cmd/openim-authz-server
cmd/openim-pump
cmd/openim-watcher
)
echo "${targets[@]}"
}
IFS=" " read -ra IAM_SERVER_IMAGE_TARGETS <<< "$(iam::golang::server_image_targets)"
readonly IAM_SERVER_IMAGE_TARGETS
readonly IAM_SERVER_IMAGE_BINARIES=("${IAM_SERVER_IMAGE_TARGETS[@]##*/}")
IFS=" " read -ra OPENIM_SERVER_IMAGE_TARGETS <<< "$(openim::golang::server_image_targets)"
readonly OPENIM_SERVER_IMAGE_TARGETS
readonly OPENIM_SERVER_IMAGE_BINARIES=("${OPENIM_SERVER_IMAGE_TARGETS[@]##*/}")
# ------------
# NOTE: All functions that return lists should use newlines.
# bash functions can't return arrays, and spaces are tricky, so newline
# separators are the preferred pattern.
# To transform a string of newline-separated items to an array, use iam::util::read-array:
# iam::util::read-array FOO < <(iam::golang::dups a b c a)
# To transform a string of newline-separated items to an array, use openim::util::read-array:
# openim::util::read-array FOO < <(openim::golang::dups a b c a)
#
# ALWAYS remember to quote your subshells. Not doing so will break in
# bash 4.3, and potentially cause other issues.
# ------------
# Returns a sorted newline-separated list containing only duplicated items.
iam::golang::dups() {
openim::golang::dups() {
# We use printf to insert newlines, which are required by sort.
printf "%s\n" "$@" | sort | uniq -d
}
# Returns a sorted newline-separated list with duplicated items removed.
iam::golang::dedup() {
openim::golang::dedup() {
# We use printf to insert newlines, which are required by sort.
printf "%s\n" "$@" | sort -u
}
# Depends on values of user-facing IAM_BUILD_PLATFORMS, IAM_FASTBUILD,
# and IAM_BUILDER_OS.
# Configures IAM_SERVER_PLATFORMS and IAM_CLIENT_PLATFORMS, then sets them
# Depends on values of user-facing OPENIM_BUILD_PLATFORMS, OPENIM_FASTBUILD,
# and OPENIM_BUILDER_OS.
# Configures OPENIM_SERVER_PLATFORMS and OPENIM_CLIENT_PLATFORMS, then sets them
# to readonly.
# The configured vars will only contain platforms allowed by the
# IAM_SUPPORTED* vars at the top of this file.
declare -a IAM_SERVER_PLATFORMS
declare -a IAM_CLIENT_PLATFORMS
iam::golang::setup_platforms() {
if [[ -n "${IAM_BUILD_PLATFORMS:-}" ]]; then
# IAM_BUILD_PLATFORMS needs to be read into an array before the next
# OPENIM_SUPPORTED* vars at the top of this file.
declare -a OPENIM_SERVER_PLATFORMS
declare -a OPENIM_CLIENT_PLATFORMS
openim::golang::setup_platforms() {
if [[ -n "${OPENIM_BUILD_PLATFORMS:-}" ]]; then
# OPENIM_BUILD_PLATFORMS needs to be read into an array before the next
# step, or quoting treats it all as one element.
local -a platforms
IFS=" " read -ra platforms <<< "${IAM_BUILD_PLATFORMS}"
IFS=" " read -ra platforms <<< "${OPENIM_BUILD_PLATFORMS}"
# Deduplicate to ensure the intersection trick with iam::golang::dups
# Deduplicate to ensure the intersection trick with openim::golang::dups
# is not defeated by duplicates in user input.
iam::util::read-array platforms < <(iam::golang::dedup "${platforms[@]}")
openim::util::read-array platforms < <(openim::golang::dedup "${platforms[@]}")
# Use iam::golang::dups to restrict the builds to the platforms in
# IAM_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
# Use openim::golang::dups to restrict the builds to the platforms in
# OPENIM_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
# set, so if they appear twice after the merge they are in the intersection.
iam::util::read-array IAM_SERVER_PLATFORMS < <(iam::golang::dups \
openim::util::read-array OPENIM_SERVER_PLATFORMS < <(openim::golang::dups \
"${platforms[@]}" \
"${IAM_SUPPORTED_SERVER_PLATFORMS[@]}" \
"${OPENIM_SUPPORTED_SERVER_PLATFORMS[@]}" \
)
readonly IAM_SERVER_PLATFORMS
readonly OPENIM_SERVER_PLATFORMS
iam::util::read-array IAM_CLIENT_PLATFORMS < <(iam::golang::dups \
openim::util::read-array OPENIM_CLIENT_PLATFORMS < <(openim::golang::dups \
"${platforms[@]}" \
"${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}" \
"${OPENIM_SUPPORTED_CLIENT_PLATFORMS[@]}" \
)
readonly IAM_CLIENT_PLATFORMS
readonly OPENIM_CLIENT_PLATFORMS
elif [[ "${IAM_FASTBUILD:-}" == "true" ]]; then
IAM_SERVER_PLATFORMS=(linux/amd64)
readonly IAM_SERVER_PLATFORMS
IAM_CLIENT_PLATFORMS=(linux/amd64)
readonly IAM_CLIENT_PLATFORMS
elif [[ "${OPENIM_FASTBUILD:-}" == "true" ]]; then
OPENIM_SERVER_PLATFORMS=(linux/amd64)
readonly OPENIM_SERVER_PLATFORMS
OPENIM_CLIENT_PLATFORMS=(linux/amd64)
readonly OPENIM_CLIENT_PLATFORMS
else
IAM_SERVER_PLATFORMS=("${IAM_SUPPORTED_SERVER_PLATFORMS[@]}")
readonly IAM_SERVER_PLATFORMS
OPENIM_SERVER_PLATFORMS=("${OPENIM_SUPPORTED_SERVER_PLATFORMS[@]}")
readonly OPENIM_SERVER_PLATFORMS
IAM_CLIENT_PLATFORMS=("${IAM_SUPPORTED_CLIENT_PLATFORMS[@]}")
readonly IAM_CLIENT_PLATFORMS
OPENIM_CLIENT_PLATFORMS=("${OPENIM_SUPPORTED_CLIENT_PLATFORMS[@]}")
readonly OPENIM_CLIENT_PLATFORMS
fi
}
iam::golang::setup_platforms
openim::golang::setup_platforms
# The set of client targets that we are building for all platforms
# If you update this list, please also update build/BUILD.
readonly IAM_CLIENT_TARGETS=(
readonly OPENIM_CLIENT_TARGETS=(
iamctl
)
readonly IAM_CLIENT_BINARIES=("${IAM_CLIENT_TARGETS[@]##*/}")
readonly OPENIM_CLIENT_BINARIES=("${OPENIM_CLIENT_TARGETS[@]##*/}")
readonly IAM_ALL_TARGETS=(
"${IAM_SERVER_TARGETS[@]}"
"${IAM_CLIENT_TARGETS[@]}"
readonly OPENIM_ALL_TARGETS=(
"${OPENIM_SERVER_TARGETS[@]}"
"${OPENIM_CLIENT_TARGETS[@]}"
)
readonly IAM_ALL_BINARIES=("${IAM_ALL_TARGETS[@]##*/}")
readonly OPENIM_ALL_BINARIES=("${OPENIM_ALL_TARGETS[@]##*/}")
# Asks golang what it thinks the host platform is. The go tool chain does some
# slightly different things when the target platform matches the host platform.
iam::golang::host_platform() {
openim::golang::host_platform() {
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
}
# Ensure the go tool exists and is a viable version.
iam::golang::verify_go_version() {
openim::golang::verify_go_version() {
if [[ -z "$(command -v go)" ]]; then
iam::log::usage_from_stdin <<EOF
openim::log::usage_from_stdin <<EOF
Can't find 'go' in PATH, please fix and retry.
See http://golang.org/doc/install for installation instructions.
EOF
@@ -158,25 +168,25 @@ EOF
local minimum_go_version
minimum_go_version=go1.13.4
if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
iam::log::usage_from_stdin <<EOF
openim::log::usage_from_stdin <<EOF
Detected go version: ${go_version[*]}.
IAM requires ${minimum_go_version} or greater.
OpenIM requires ${minimum_go_version} or greater.
Please install ${minimum_go_version} or later.
EOF
return 2
fi
}
# iam::golang::setup_env will check that the `go` commands is available in
# openim::golang::setup_env will check that the `go` commands is available in
# ${PATH}. It will also check that the Go version is good enough for the
# IAM build.
# OpenIM build.
#
# Outputs:
# env-var GOBIN is unset (we want binaries in a predictable place)
# env-var GO15VENDOREXPERIMENT=1
# env-var GO111MODULE=on
iam::golang::setup_env() {
iam::golang::verify_go_version
openim::golang::setup_env() {
openim::golang::verify_go_version
# Unset GOBIN in case it already exists in the current session.
unset GOBIN
+20 -10
View File
@@ -1,8 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
set -o errexit
set +o nounset
@@ -16,13 +26,13 @@ unset CDPATH
export GO111MODULE=on
# The root of the build/dist directory
IAM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
source "${IAM_ROOT}/scripts/lib/util.sh"
source "${IAM_ROOT}/scripts/lib/logging.sh"
source "${IAM_ROOT}/scripts/lib/color.sh"
source "${OPENIM_ROOT}/scripts/lib/util.sh"
source "${OPENIM_ROOT}/scripts/lib/logging.sh"
source "${OPENIM_ROOT}/scripts/lib/color.sh"
iam::log::install_errexit
openim::log::install_errexit
source "${IAM_ROOT}/scripts/lib/version.sh"
source "${IAM_ROOT}/scripts/lib/golang.sh"
source "${OPENIM_ROOT}/scripts/lib/version.sh"
source "${OPENIM_ROOT}/scripts/lib/golang.sh"
+36 -26
View File
@@ -1,15 +1,25 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
# Controls verbosity of the script output and logging.
IAM_VERBOSE="${IAM_VERBOSE:-5}"
OPENIM_VERBOSE="${OPENIM_VERBOSE:-5}"
# Handler for when we exit automatically on an error.
# Borrowed from https://gist.github.com/ahendrix/7030300
iam::log::errexit() {
openim::log::errexit() {
local err="${PIPESTATUS[*]}"
# If the shell we are in doesn't have errexit set (common in subshells) then
@@ -21,19 +31,19 @@ iam::log::errexit() {
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
iam::log::error "Call tree:"
openim::log::error "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
do
iam::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)"
openim::log::error " ${i}: ${BASH_SOURCE[${i}+1]}:${BASH_LINENO[${i}]} ${FUNCNAME[${i}]}(...)"
done
fi
iam::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status ${err}" "${1:-1}" 1
openim::log::error_exit "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status ${err}" "${1:-1}" 1
}
iam::log::install_errexit() {
openim::log::install_errexit() {
# trap ERR to provide an error handler whenever a command exits nonzero this
# is a more verbose version of set -o errexit
trap 'iam::log::errexit' ERR
trap 'openim::log::errexit' ERR
# setting errtrace allows our ERR trap handler to be propagated to functions,
# expansions and subshells
@@ -44,7 +54,7 @@ iam::log::install_errexit() {
#
# Args:
# $1 The number of stack frames to skip when printing.
iam::log::stack() {
openim::log::stack() {
local stack_skip=${1:-0}
stack_skip=$((stack_skip + 1))
if [[ ${#FUNCNAME[@]} -gt ${stack_skip} ]]; then
@@ -66,13 +76,13 @@ iam::log::stack() {
# $1 Message to log with the error
# $2 The error code to return
# $3 The number of stack frames to skip when printing.
iam::log::error_exit() {
openim::log::error_exit() {
local message="${1:-}"
local code="${2:-1}"
local stack_skip="${3:-0}"
stack_skip=$((stack_skip + 1))
if [[ ${IAM_VERBOSE} -ge 4 ]]; then
if [[ ${OPENIM_VERBOSE} -ge 4 ]]; then
local source_file=${BASH_SOURCE[${stack_skip}]}
local source_line=${BASH_LINENO[$((stack_skip - 1))]}
echo "!!! Error in ${source_file}:${source_line}" >&2
@@ -80,7 +90,7 @@ iam::log::error_exit() {
echo " ${1}" >&2
}
iam::log::stack ${stack_skip}
openim::log::stack ${stack_skip}
echo "Exiting with status ${code}" >&2
fi
@@ -89,7 +99,7 @@ iam::log::error_exit() {
}
# Log an error but keep going. Don't dump the stack or exit.
iam::log::error() {
openim::log::error() {
timestamp=$(date +"[%m%d %H:%M:%S]")
echo "!!! ${timestamp} ${1-}" >&2
shift
@@ -99,7 +109,7 @@ iam::log::error() {
}
# Print an usage message to stderr. The arguments are printed directly.
iam::log::usage() {
openim::log::usage() {
echo >&2
local message
for message; do
@@ -108,19 +118,19 @@ iam::log::usage() {
echo >&2
}
iam::log::usage_from_stdin() {
openim::log::usage_from_stdin() {
local messages=()
while read -r line; do
messages+=("${line}")
done
iam::log::usage "${messages[@]}"
openim::log::usage "${messages[@]}"
}
# Print out some info that isn't a top level status line
iam::log::info() {
openim::log::info() {
local V="${V:-0}"
if [[ ${IAM_VERBOSE} < ${V} ]]; then
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
return
fi
@@ -129,26 +139,26 @@ iam::log::info() {
done
}
# Just like iam::log::info, but no \n, so you can make a progress bar
iam::log::progress() {
# Just like openim::log::info, but no \n, so you can make a progress bar
openim::log::progress() {
for message; do
echo -e -n "${message}"
done
}
iam::log::info_from_stdin() {
openim::log::info_from_stdin() {
local messages=()
while read -r line; do
messages+=("${line}")
done
iam::log::info "${messages[@]}"
openim::log::info "${messages[@]}"
}
# Print a status line. Formatted to show up in a stream of output.
iam::log::status() {
openim::log::status() {
local V="${V:-0}"
if [[ ${IAM_VERBOSE} < ${V} ]]; then
if [[ ${OPENIM_VERBOSE} < ${V} ]]; then
return
fi
+180 -170
View File
@@ -1,22 +1,33 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
# This file creates release artifacts (tar files, container images) that are
# ready to distribute to install or distribute to end users.
###############################################################################
# Most of the ::release:: namespace functions have been moved to
# github.com/iam/release. Have a look in that repo and specifically in
# github.com/openim/release. Have a look in that repo and specifically in
# lib/releaselib.sh for ::release::-related functionality.
###############################################################################
# example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com
# https://cloud.tencent.com/document/product/436/71763
# Tencent cos configuration
readonly BUCKET="marmotedu-1254073058"
readonly BUCKET="openim-1306374445"
readonly REGION="ap-beijing"
readonly COS_RELEASE_DIR="iam-release"
readonly COS_RELEASE_DIR="openim-release"
# default cos command tool
readonly COSTOOL="coscmd"
# This is where the final release artifacts are created locally
@@ -24,15 +35,15 @@ readonly RELEASE_STAGE="${LOCAL_OUTPUT_ROOT}/release-stage"
readonly RELEASE_TARS="${LOCAL_OUTPUT_ROOT}/release-tars"
readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
# IAM github account info
readonly IAM_GITHUB_ORG=marmotedu
readonly IAM_GITHUB_REPO=iam
# OpenIM github account info
readonly OPENIM_GITHUB_ORG=OpenIMSDK
readonly OPENIM_GITHUB_REPO=openim
readonly ARTIFACT=iam.tar.gz
readonly ARTIFACT=openim.tar.gz
readonly CHECKSUM=${ARTIFACT}.sha1sum
IAM_BUILD_CONFORMANCE=${IAM_BUILD_CONFORMANCE:-y}
IAM_BUILD_PULL_LATEST_IMAGES=${IAM_BUILD_PULL_LATEST_IMAGES:-y}
OPENIM_BUILD_CONFORMANCE=${OPENIM_BUILD_CONFORMANCE:-y}
OPENIM_BUILD_PULL_LATEST_IMAGES=${OPENIM_BUILD_PULL_LATEST_IMAGES:-y}
# Validate a ci version
#
@@ -50,12 +61,12 @@ IAM_BUILD_PULL_LATEST_IMAGES=${IAM_BUILD_PULL_LATEST_IMAGES:-y}
# VERSION_PRERELEASE_REV (e.g. '4')
# VERSION_BUILD_INFO (e.g. '.56+abcdef12345678')
# VERSION_COMMITS (e.g. '56')
function iam::release::parse_and_validate_ci_version() {
function openim::release::parse_and_validate_ci_version() {
# Accept things like "v1.2.3-alpha.4.56+abcdef12345678" or "v1.2.3-beta.4"
local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-([a-zA-Z0-9]+)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*)\\+[0-9a-f]{7,40})?$"
local -r version="${1-}"
[[ "${version}" =~ ${version_regex} ]] || {
iam::log::error "Invalid ci version: '${version}', must match regex ${version_regex}"
openim::log::error "Invalid ci version: '${version}', must match regex ${version_regex}"
return 1
}
@@ -80,73 +91,73 @@ function iam::release::parse_and_validate_ci_version() {
# ---------------------------------------------------------------------------
# Build final release artifacts
function iam::release::clean_cruft() {
function openim::release::clean_cruft() {
# Clean out cruft
find "${RELEASE_STAGE}" -name '*~' -exec rm {} \;
find "${RELEASE_STAGE}" -name '#*#' -exec rm {} \;
find "${RELEASE_STAGE}" -name '.DS*' -exec rm {} \;
}
function iam::release::package_tarballs() {
function openim::release::package_tarballs() {
# Clean out any old releases
rm -rf "${RELEASE_STAGE}" "${RELEASE_TARS}" "${RELEASE_IMAGES}"
mkdir -p "${RELEASE_TARS}"
iam::release::package_src_tarball &
iam::release::package_client_tarballs &
iam::release::package_iam_manifests_tarball &
iam::release::package_server_tarballs &
iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
openim::release::package_src_tarball &
openim::release::package_client_tarballs &
openim::release::package_iam_manifests_tarball &
openim::release::package_server_tarballs &
openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
iam::release::package_final_tarball & # _final depends on some of the previous phases
iam::util::wait-for-jobs || { iam::log::error "previous tarball phase failed"; return 1; }
openim::release::package_final_tarball & # _final depends on some of the previous phases
openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
}
function iam::release::updload_tarballs() {
iam::log::info "upload ${RELEASE_TARS}/* to cos bucket ${BUCKET}."
function openim::release::updload_tarballs() {
openim::log::info "upload ${RELEASE_TARS}/* to cos bucket ${BUCKET}."
for file in $(ls ${RELEASE_TARS}/*)
do
if [ "${COSTOOL}" == "coscli" ];then
coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/${file##*/}"
coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/${OPENIM_GIT_VERSION}/${file##*/}"
coscli cp "${file}" "cos://${BUCKET}/${COS_RELEASE_DIR}/latest/${file##*/}"
else
coscmd upload "${file}" "${COS_RELEASE_DIR}/${IAM_GIT_VERSION}/"
coscmd upload "${file}" "${COS_RELEASE_DIR}/${OPENIM_GIT_VERSION}/"
coscmd upload "${file}" "${COS_RELEASE_DIR}/latest/"
fi
done
}
# Package the source code we built, for compliance/licensing/audit/yadda.
function iam::release::package_src_tarball() {
local -r src_tarball="${RELEASE_TARS}/iam-src.tar.gz"
iam::log::status "Building tarball: src"
if [[ "${IAM_GIT_TREE_STATE-}" = 'clean' ]]; then
function openim::release::package_src_tarball() {
local -r src_tarball="${RELEASE_TARS}/openim-src.tar.gz"
openim::log::status "Building tarball: src"
if [[ "${OPENIM_GIT_TREE_STATE-}" = 'clean' ]]; then
git archive -o "${src_tarball}" HEAD
else
find "${IAM_ROOT}" -mindepth 1 -maxdepth 1 \
find "${OPENIM_ROOT}" -mindepth 1 -maxdepth 1 \
! \( \
\( -path "${IAM_ROOT}"/_\* -o \
-path "${IAM_ROOT}"/.git\* -o \
-path "${IAM_ROOT}"/.gitignore\* -o \
-path "${IAM_ROOT}"/.gsemver.yaml\* -o \
-path "${IAM_ROOT}"/.config\* -o \
-path "${IAM_ROOT}"/.chglog\* -o \
-path "${IAM_ROOT}"/.gitlint -o \
-path "${IAM_ROOT}"/.golangci.yaml -o \
-path "${IAM_ROOT}"/.goreleaser.yml -o \
-path "${IAM_ROOT}"/.note.md -o \
-path "${IAM_ROOT}"/.todo.md \
\( -path "${OPENIM_ROOT}"/_\* -o \
-path "${OPENIM_ROOT}"/.git\* -o \
-path "${OPENIM_ROOT}"/.gitignore\* -o \
-path "${OPENIM_ROOT}"/.gsemver.yaml\* -o \
-path "${OPENIM_ROOT}"/.config\* -o \
-path "${OPENIM_ROOT}"/.chglog\* -o \
-path "${OPENIM_ROOT}"/.gitlint -o \
-path "${OPENIM_ROOT}"/.golangci.yaml -o \
-path "${OPENIM_ROOT}"/.goreleaser.yml -o \
-path "${OPENIM_ROOT}"/.note.md -o \
-path "${OPENIM_ROOT}"/.todo.md \
\) -prune \
\) -print0 \
| "${TAR}" czf "${src_tarball}" --transform "s|${IAM_ROOT#/*}|iam|" --null -T -
| "${TAR}" czf "${src_tarball}" --transform "s|${OPENIM_ROOT#/*}|openim|" --null -T -
fi
}
# Package up all of the server binaries
function iam::release::package_server_tarballs() {
function openim::release::package_server_tarballs() {
# Find all of the built client binaries
local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
if [[ -n ${OPENIM_BUILD_PLATFORMS-} ]]; then
read -ra long_platforms <<< "${OPENIM_BUILD_PLATFORMS}"
fi
for platform_long in "${long_platforms[@]}"; do
@@ -154,14 +165,14 @@ function iam::release::package_server_tarballs() {
local platform_tag
platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
platform_tag=${platform/\//-} # Replace a "/" for a "-"
iam::log::status "Starting tarball: server $platform_tag"
openim::log::status "Starting tarball: server $platform_tag"
(
local release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
local release_stage="${RELEASE_STAGE}/server/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/server/bin"
local server_bins=("${IAM_SERVER_BINARIES[@]}")
local server_bins=("${OPENIM_SERVER_BINARIES[@]}")
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
@@ -169,24 +180,24 @@ function iam::release::package_server_tarballs() {
cp "${server_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
iam::release::clean_cruft
openim::release::clean_cruft
local package_name="${RELEASE_TARS}/iam-server-${platform_tag}.tar.gz"
iam::release::create_tarball "${package_name}" "${release_stage}/.."
local package_name="${RELEASE_TARS}/openim-server-${platform_tag}.tar.gz"
openim::release::create_tarball "${package_name}" "${release_stage}/.."
) &
done
iam::log::status "Waiting on tarballs"
iam::util::wait-for-jobs || { iam::log::error "server tarball creation failed"; exit 1; }
openim::log::status "Waiting on tarballs"
openim::util::wait-for-jobs || { openim::log::error "server tarball creation failed"; exit 1; }
}
# Package up all of the cross compiled clients. Over time this should grow into
# a full SDK
function iam::release::package_client_tarballs() {
function openim::release::package_client_tarballs() {
# Find all of the built client binaries
local long_platforms=("${LOCAL_OUTPUT_BINPATH}"/*/*)
if [[ -n ${IAM_BUILD_PLATFORMS-} ]]; then
read -ra long_platforms <<< "${IAM_BUILD_PLATFORMS}"
if [[ -n ${OPENIM_BUILD_PLATFORMS-} ]]; then
read -ra long_platforms <<< "${OPENIM_BUILD_PLATFORMS}"
fi
for platform_long in "${long_platforms[@]}"; do
@@ -194,14 +205,14 @@ function iam::release::package_client_tarballs() {
local platform_tag
platform=${platform_long##${LOCAL_OUTPUT_BINPATH}/} # Strip LOCAL_OUTPUT_BINPATH
platform_tag=${platform/\//-} # Replace a "/" for a "-"
iam::log::status "Starting tarball: client $platform_tag"
openim::log::status "Starting tarball: client $platform_tag"
(
local release_stage="${RELEASE_STAGE}/client/${platform_tag}/iam"
local release_stage="${RELEASE_STAGE}/client/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/client/bin"
local client_bins=("${IAM_CLIENT_BINARIES[@]}")
local client_bins=("${OPENIM_CLIENT_BINARIES[@]}")
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
@@ -209,45 +220,45 @@ function iam::release::package_client_tarballs() {
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/client/bin/"
iam::release::clean_cruft
openim::release::clean_cruft
local package_name="${RELEASE_TARS}/iam-client-${platform_tag}.tar.gz"
iam::release::create_tarball "${package_name}" "${release_stage}/.."
local package_name="${RELEASE_TARS}/openim-client-${platform_tag}.tar.gz"
openim::release::create_tarball "${package_name}" "${release_stage}/.."
) &
done
iam::log::status "Waiting on tarballs"
iam::util::wait-for-jobs || { iam::log::error "client tarball creation failed"; exit 1; }
openim::log::status "Waiting on tarballs"
openim::util::wait-for-jobs || { openim::log::error "client tarball creation failed"; exit 1; }
}
# Package up all of the server binaries in docker images
function iam::release::build_server_images() {
function openim::release::build_server_images() {
# Clean out any old images
rm -rf "${RELEASE_IMAGES}"
local platform
for platform in "${IAM_SERVER_PLATFORMS[@]}"; do
for platform in "${OPENIM_SERVER_PLATFORMS[@]}"; do
local platform_tag
local arch
platform_tag=${platform/\//-} # Replace a "/" for a "-"
arch=$(basename "${platform}")
iam::log::status "Building images: $platform_tag"
openim::log::status "Building images: $platform_tag"
local release_stage
release_stage="${RELEASE_STAGE}/server/${platform_tag}/iam"
release_stage="${RELEASE_STAGE}/server/${platform_tag}/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/server/bin"
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# IAM_SERVER_IMAGE_BINARIES array.
cp "${IAM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
# OPENIM_SERVER_IMAGE_BINARIES array.
cp "${OPENIM_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
iam::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
openim::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
done
}
function iam::release::md5() {
function openim::release::md5() {
if which md5 >/dev/null 2>&1; then
md5 -q "$1"
else
@@ -255,7 +266,7 @@ function iam::release::md5() {
fi
}
function iam::release::sha1() {
function openim::release::sha1() {
if which sha1sum >/dev/null 2>&1; then
sha1sum "$1" | awk '{ print $1 }'
else
@@ -263,12 +274,12 @@ function iam::release::sha1() {
fi
}
function iam::release::build_conformance_image() {
function openim::release::build_conformance_image() {
local -r arch="$1"
local -r registry="$2"
local -r version="$3"
local -r save_dir="${4-}"
iam::log::status "Building conformance image for arch: ${arch}"
openim::log::status "Building conformance image for arch: ${arch}"
ARCH="${arch}" REGISTRY="${registry}" VERSION="${version}" \
make -C cluster/images/conformance/ build >/dev/null
@@ -277,7 +288,7 @@ function iam::release::build_conformance_image() {
if [[ -n "${save_dir}" ]]; then
"${DOCKER[@]}" save "${conformance_tag}" > "${save_dir}/conformance-${arch}.tar"
fi
iam::log::status "Deleting conformance image ${conformance_tag}"
openim::log::status "Deleting conformance image ${conformance_tag}"
"${DOCKER[@]}" rmi "${conformance_tag}" &>/dev/null || true
}
@@ -285,7 +296,7 @@ function iam::release::build_conformance_image() {
# Args:
# $1 - binary_dir, the directory to save the tared images to.
# $2 - arch, architecture for which we are building docker images.
function iam::release::create_docker_images_for_server() {
function openim::release::create_docker_images_for_server() {
# Create a sub-shell so that we don't pollute the outer environment
(
local binary_dir
@@ -294,27 +305,27 @@ function iam::release::create_docker_images_for_server() {
local images_dir
binary_dir="$1"
arch="$2"
binaries=$(iam::build::get_docker_wrapped_binaries "${arch}")
binaries=$(openim::build::get_docker_wrapped_binaries "${arch}")
images_dir="${RELEASE_IMAGES}/${arch}"
mkdir -p "${images_dir}"
# k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE.
# We can use IAM_DOCKER_REGISTRY to include and extra registry in the docker archive.
# If we use IAM_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below.
# We can use OPENIM_DOCKER_REGISTRY to include and extra registry in the docker archive.
# If we use OPENIM_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below.
local -r docker_registry="k8s.gcr.io"
# Docker tags cannot contain '+'
local docker_tag="${IAM_GIT_VERSION/+/_}"
local docker_tag="${OPENIM_GIT_VERSION/+/_}"
if [[ -z "${docker_tag}" ]]; then
iam::log::error "git version information missing; cannot create Docker tag"
openim::log::error "git version information missing; cannot create Docker tag"
return 1
fi
# provide `--pull` argument to `docker build` if `IAM_BUILD_PULL_LATEST_IMAGES`
# provide `--pull` argument to `docker build` if `OPENIM_BUILD_PULL_LATEST_IMAGES`
# is set to y or Y; otherwise try to build the image without forcefully
# pulling the latest base image.
local docker_build_opts
docker_build_opts=
if [[ "${IAM_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
if [[ "${OPENIM_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
docker_build_opts='--pull'
fi
@@ -327,12 +338,12 @@ function iam::release::create_docker_images_for_server() {
local docker_file_path="${docker_build_path}/Dockerfile"
local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}"
iam::log::status "Starting docker build for image: ${binary_name}-${arch}"
openim::log::status "Starting docker build for image: ${binary_name}-${arch}"
(
rm -rf "${docker_build_path}"
mkdir -p "${docker_build_path}"
ln "${binary_file_path}" "${docker_build_path}/${binary_name}"
ln "${IAM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
ln "${OPENIM_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf"
chmod 0644 "${docker_build_path}/nsswitch.conf"
cat <<EOF > "${docker_file_path}"
FROM ${base_image}
@@ -346,9 +357,9 @@ EOF
"${DOCKER[@]}" build ${docker_build_opts:+"${docker_build_opts}"} -q -t "${docker_image_tag}" "${docker_build_path}" >/dev/null
# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.
local -r release_docker_image_tag="${IAM_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${IAM_DOCKER_IMAGE_TAG-$docker_tag}"
local -r release_docker_image_tag="${OPENIM_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${OPENIM_DOCKER_IMAGE_TAG-$docker_tag}"
if [[ "${release_docker_image_tag}" != "${docker_image_tag}" ]]; then
iam::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
openim::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
fi
@@ -357,121 +368,121 @@ EOF
rm -rf "${docker_build_path}"
ln "${binary_file_path}.tar" "${images_dir}/"
iam::log::status "Deleting docker image ${docker_image_tag}"
openim::log::status "Deleting docker image ${docker_image_tag}"
"${DOCKER[@]}" rmi "${docker_image_tag}" &>/dev/null || true
) &
done
if [[ "${IAM_BUILD_CONFORMANCE}" =~ [yY] ]]; then
iam::release::build_conformance_image "${arch}" "${docker_registry}" \
if [[ "${OPENIM_BUILD_CONFORMANCE}" =~ [yY] ]]; then
openim::release::build_conformance_image "${arch}" "${docker_registry}" \
"${docker_tag}" "${images_dir}" &
fi
iam::util::wait-for-jobs || { iam::log::error "previous Docker build failed"; return 1; }
iam::log::status "Docker builds done"
openim::util::wait-for-jobs || { openim::log::error "previous Docker build failed"; return 1; }
openim::log::status "Docker builds done"
)
}
# This will pack iam-system manifests files for distros such as COS.
function iam::release::package_iam_manifests_tarball() {
iam::log::status "Building tarball: manifests"
# This will pack openim-system manifests files for distros such as COS.
function openim::release::package_iam_manifests_tarball() {
openim::log::status "Building tarball: manifests"
local src_dir="${IAM_ROOT}/deployments"
local src_dir="${OPENIM_ROOT}/deployments"
local release_stage="${RELEASE_STAGE}/manifests/iam"
local release_stage="${RELEASE_STAGE}/manifests/openim"
rm -rf "${release_stage}"
local dst_dir="${release_stage}"
mkdir -p "${dst_dir}"
cp -r ${src_dir}/* "${dst_dir}"
#cp "${src_dir}/iam-apiserver.yaml" "${dst_dir}"
#cp "${src_dir}/iam-authz-server.yaml" "${dst_dir}"
#cp "${src_dir}/iam-pump.yaml" "${dst_dir}"
#cp "${src_dir}/iam-watcher.yaml" "${dst_dir}"
#cp "${IAM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
#cp "${src_dir}/openim-apiserver.yaml" "${dst_dir}"
#cp "${src_dir}/openim-authz-server.yaml" "${dst_dir}"
#cp "${src_dir}/openim-pump.yaml" "${dst_dir}"
#cp "${src_dir}/openim-watcher.yaml" "${dst_dir}"
#cp "${OPENIM_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
iam::release::clean_cruft
openim::release::clean_cruft
local package_name="${RELEASE_TARS}/iam-manifests.tar.gz"
iam::release::create_tarball "${package_name}" "${release_stage}/.."
local package_name="${RELEASE_TARS}/openim-manifests.tar.gz"
openim::release::create_tarball "${package_name}" "${release_stage}/.."
}
# This is all the platform-independent stuff you need to run/install iam.
# This is all the platform-independent stuff you need to run/install openim.
# Arch-specific binaries will need to be downloaded separately (possibly by
# using the bundled cluster/get-iam-binaries.sh script).
# using the bundled cluster/get-openim-binaries.sh script).
# Included in this tarball:
# - Cluster spin up/down scripts and configs for various cloud providers
# - Tarballs for manifest configs that are ready to be uploaded
# - Examples (which may or may not still work)
# - The remnants of the docs/ directory
function iam::release::package_final_tarball() {
iam::log::status "Building tarball: final"
function openim::release::package_final_tarball() {
openim::log::status "Building tarball: final"
# This isn't a "full" tarball anymore, but the release lib still expects
# artifacts under "full/iam/"
local release_stage="${RELEASE_STAGE}/full/iam"
# artifacts under "full/openim/"
local release_stage="${RELEASE_STAGE}/full/openim"
rm -rf "${release_stage}"
mkdir -p "${release_stage}"
mkdir -p "${release_stage}/client"
cat <<EOF > "${release_stage}/client/README"
Client binaries are no longer included in the IAM final tarball.
Client binaries are no longer included in the OpenIM final tarball.
Run release/get-iam-binaries.sh to download client and server binaries.
Run release/get-openim-binaries.sh to download client and server binaries.
EOF
# We want everything in /scripts.
mkdir -p "${release_stage}/release"
cp -R "${IAM_ROOT}/scripts/release" "${release_stage}/"
cat <<EOF > "${release_stage}/release/get-iam-binaries.sh"
cp -R "${OPENIM_ROOT}/scripts/release" "${release_stage}/"
cat <<EOF > "${release_stage}/release/get-openim-binaries.sh"
#!/usr/bin/env bash
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
# This file download iam client and server binaries from tencent cos bucket.
# This file download openim client and server binaries from tencent cos bucket.
os=linux arch=amd64 version=${IAM_GIT_VERSION} && wget https://${BUCKET}.cos.${REGION}.myqcloud.com/${COS_RELEASE_DIR}/\$version/{iam-client-\$os-\$arch.tar.gz,iam-server-\$os-\$arch.tar.gz}
os=linux arch=amd64 version=${OPENIM_GIT_VERSION} && wget https://${BUCKET}.cos.${REGION}.myqcloud.com/${COS_RELEASE_DIR}/\$version/{openim-client-\$os-\$arch.tar.gz,openim-server-\$os-\$arch.tar.gz}
EOF
chmod +x ${release_stage}/release/get-iam-binaries.sh
chmod +x ${release_stage}/release/get-openim-binaries.sh
mkdir -p "${release_stage}/server"
cp "${RELEASE_TARS}/iam-manifests.tar.gz" "${release_stage}/server/"
cp "${RELEASE_TARS}/openim-manifests.tar.gz" "${release_stage}/server/"
cat <<EOF > "${release_stage}/server/README"
Server binary tarballs are no longer included in the IAM final tarball.
Server binary tarballs are no longer included in the OpenIM final tarball.
Run release/get-iam-binaries.sh to download client and server binaries.
Run release/get-openim-binaries.sh to download client and server binaries.
EOF
# Include hack/lib as a dependency for the cluster/ scripts
#mkdir -p "${release_stage}/hack"
#cp -R "${IAM_ROOT}/hack/lib" "${release_stage}/hack/"
#cp -R "${OPENIM_ROOT}/hack/lib" "${release_stage}/hack/"
cp -R ${IAM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
cp -R ${OPENIM_ROOT}/{docs,configs,scripts,deployments,init,README.md,LICENSE} "${release_stage}/"
echo "${IAM_GIT_VERSION}" > "${release_stage}/version"
echo "${OPENIM_GIT_VERSION}" > "${release_stage}/version"
iam::release::clean_cruft
openim::release::clean_cruft
local package_name="${RELEASE_TARS}/${ARTIFACT}"
iam::release::create_tarball "${package_name}" "${release_stage}/.."
openim::release::create_tarball "${package_name}" "${release_stage}/.."
}
# Build a release tarball. $1 is the output tar name. $2 is the base directory
# of the files to be packaged. This assumes that ${2}/iamis what is
# being packaged.
function iam::release::create_tarball() {
iam::build::ensure_tar
function openim::release::create_tarball() {
openim::build::ensure_tar
local tarfile=$1
local stagingdir=$2
"${TAR}" czf "${tarfile}" -C "${stagingdir}" iam --owner=0 --group=0
"${TAR}" czf "${tarfile}" -C "${stagingdir}" openim --owner=0 --group=0
}
function iam::release::install_github_release(){
function openim::release::install_github_release(){
GO111MODULE=on go install github.com/github-release/github-release@latest
}
@@ -480,46 +491,46 @@ function iam::release::install_github_release(){
# - gsemver
# - git-chglog
# - coscmd or coscli
function iam::release::verify_prereqs(){
function openim::release::verify_prereqs(){
if [ -z "$(which github-release 2>/dev/null)" ]; then
iam::log::info "'github-release' tool not installed, try to install it."
openim::log::info "'github-release' tool not installed, try to install it."
if ! iam::release::install_github_release; then
iam::log::error "failed to install 'github-release'"
if ! openim::release::install_github_release; then
openim::log::error "failed to install 'github-release'"
return 1
fi
fi
if [ -z "$(which git-chglog 2>/dev/null)" ]; then
iam::log::info "'git-chglog' tool not installed, try to install it."
openim::log::info "'git-chglog' tool not installed, try to install it."
if ! go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest &>/dev/null; then
iam::log::error "failed to install 'git-chglog'"
openim::log::error "failed to install 'git-chglog'"
return 1
fi
fi
if [ -z "$(which gsemver 2>/dev/null)" ]; then
iam::log::info "'gsemver' tool not installed, try to install it."
openim::log::info "'gsemver' tool not installed, try to install it."
if ! go install github.com/arnaud-deprez/gsemver@latest &>/dev/null; then
iam::log::error "failed to install 'gsemver'"
openim::log::error "failed to install 'gsemver'"
return 1
fi
fi
if [ -z "$(which ${COSTOOL} 2>/dev/null)" ]; then
iam::log::info "${COSTOOL} tool not installed, try to install it."
openim::log::info "${COSTOOL} tool not installed, try to install it."
if ! make -C "${IAM_ROOT}" tools.install.${COSTOOL}; then
iam::log::error "failed to install ${COSTOOL}"
if ! make -C "${OPENIM_ROOT}" tools.install.${COSTOOL}; then
openim::log::error "failed to install ${COSTOOL}"
return 1
fi
fi
if [ -z "${TENCENT_SECRET_ID}" -o -z "${TENCENT_SECRET_KEY}" ];then
iam::log::error "can not find env: TENCENT_SECRET_ID and TENCENT_SECRET_KEY"
openim::log::error "can not find env: TENCENT_SECRET_ID and TENCENT_SECRET_KEY"
return 1
fi
@@ -556,42 +567,41 @@ EOF
# Create a github release with specified tarballs.
# NOTICE: Must export 'GITHUB_TOKEN' env in the shell, details:
# https://github.com/github-release/github-release
function iam::release::github_release() {
function openim::release::github_release() {
# create a github release
iam::log::info "create a new github release with tag ${IAM_GIT_VERSION}"
openim::log::info "create a new github release with tag ${OPENIM_GIT_VERSION}"
github-release release \
--user ${IAM_GITHUB_ORG} \
--repo ${IAM_GITHUB_REPO} \
--tag ${IAM_GIT_VERSION} \
--user ${OPENIM_GITHUB_ORG} \
--repo ${OPENIM_GITHUB_REPO} \
--tag ${OPENIM_GIT_VERSION} \
--description "" \
--pre-release
# update iam tarballs
iam::log::info "upload ${ARTIFACT} to release ${IAM_GIT_VERSION}"
# update openim tarballs
openim::log::info "upload ${ARTIFACT} to release ${OPENIM_GIT_VERSION}"
github-release upload \
--user ${IAM_GITHUB_ORG} \
--repo ${IAM_GITHUB_REPO} \
--tag ${IAM_GIT_VERSION} \
--user ${OPENIM_GITHUB_ORG} \
--repo ${OPENIM_GITHUB_REPO} \
--tag ${OPENIM_GIT_VERSION} \
--name ${ARTIFACT} \
--file ${RELEASE_TARS}/${ARTIFACT}
iam::log::info "upload iam-src.tar.gz to release ${IAM_GIT_VERSION}"
openim::log::info "upload openim-src.tar.gz to release ${OPENIM_GIT_VERSION}"
github-release upload \
--user ${IAM_GITHUB_ORG} \
--repo ${IAM_GITHUB_REPO} \
--tag ${IAM_GIT_VERSION} \
--name "iam-src.tar.gz" \
--file ${RELEASE_TARS}/iam-src.tar.gz
--user ${OPENIM_GITHUB_ORG} \
--repo ${OPENIM_GITHUB_REPO} \
--tag ${OPENIM_GIT_VERSION} \
--name "openim-src.tar.gz" \
--file ${RELEASE_TARS}/openim-src.tar.gz
}
function iam::release::generate_changelog() {
iam::log::info "generate CHANGELOG-${IAM_GIT_VERSION#v}.md and commit it"
function openim::release::generate_changelog() {
openim::log::info "generate CHANGELOG-${OPENIM_GIT_VERSION#v}.md and commit it"
git-chglog ${IAM_GIT_VERSION} > ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
git-chglog ${OPENIM_GIT_VERSION} > ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
set +o errexit
git add ${IAM_ROOT}/CHANGELOG/CHANGELOG-${IAM_GIT_VERSION#v}.md
git commit -a -m "docs(changelog): add CHANGELOG-${IAM_GIT_VERSION#v}.md"
git add ${OPENIM_ROOT}/CHANGELOG/CHANGELOG-${OPENIM_GIT_VERSION#v}.md
git commit -a -m "docs(changelog): add CHANGELOG-${OPENIM_GIT_VERSION#v}.md"
git push -f origin master # 最后将 CHANGELOG 也 push 上去
}
+107 -97
View File
@@ -1,23 +1,33 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
function iam::util::sourced_variable {
function openim::util::sourced_variable {
# Call this function to tell shellcheck that a variable is supposed to
# be used from other calling context. This helps quiet an "unused
# variable" warning from shellcheck and also document your code.
true
}
iam::util::sortable_date() {
openim::util::sortable_date() {
date "+%Y%m%d-%H%M%S"
}
# arguments: target, item1, item2, item3, ...
# returns 0 if target is in the given items, 1 otherwise.
iam::util::array_contains() {
openim::util::array_contains() {
local search="$1"
local element
shift
@@ -29,7 +39,7 @@ iam::util::array_contains() {
return 1
}
iam::util::wait_for_url() {
openim::util::wait_for_url() {
local url=$1
local prefix=${2:-}
local wait=${3:-1}
@@ -37,7 +47,7 @@ iam::util::wait_for_url() {
local maxtime=${5:-1}
command -v curl >/dev/null || {
iam::log::usage "curl must be installed"
openim::log::usage "curl must be installed"
exit 1
}
@@ -45,19 +55,19 @@ iam::util::wait_for_url() {
for i in $(seq 1 "${times}"); do
local out
if out=$(curl --max-time "${maxtime}" -gkfs "${url}" 2>/dev/null); then
iam::log::status "On try ${i}, ${prefix}: ${out}"
openim::log::status "On try ${i}, ${prefix}: ${out}"
return 0
fi
sleep "${wait}"
done
iam::log::error "Timed out waiting for ${prefix} to answer at ${url}; tried ${times} waiting ${wait} between each"
openim::log::error "Timed out waiting for ${prefix} to answer at ${url}; tried ${times} waiting ${wait} between each"
return 1
}
# Example: iam::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
# Example: openim::util::wait_for_success 120 5 "iamctl get nodes|grep localhost"
# arguments: wait time, sleep time, shell command
# returns 0 if the shell command get output, 1 otherwise.
iam::util::wait_for_success(){
openim::util::wait_for_success(){
local wait_time="$1"
local sleep_time="$2"
local cmd="$3"
@@ -72,9 +82,9 @@ iam::util::wait_for_success(){
return 1
}
# Example: iam::util::trap_add 'echo "in trap DEBUG"' DEBUG
# Example: openim::util::trap_add 'echo "in trap DEBUG"' DEBUG
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
iam::util::trap_add() {
openim::util::trap_add() {
local trap_add_cmd
trap_add_cmd=$1
shift
@@ -101,23 +111,23 @@ iam::util::trap_add() {
done
}
# Opposite of iam::util::ensure-temp-dir()
iam::util::cleanup-temp-dir() {
rm -rf "${IAM_TEMP}"
# Opposite of openim::util::ensure-temp-dir()
openim::util::cleanup-temp-dir() {
rm -rf "${OPENIM_TEMP}"
}
# Create a temp dir that'll be deleted at the end of this bash session.
#
# Vars set:
# IAM_TEMP
iam::util::ensure-temp-dir() {
if [[ -z ${IAM_TEMP-} ]]; then
IAM_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t iamrnetes.XXXXXX)
iam::util::trap_add iam::util::cleanup-temp-dir EXIT
# OPENIM_TEMP
openim::util::ensure-temp-dir() {
if [[ -z ${OPENIM_TEMP-} ]]; then
OPENIM_TEMP=$(mktemp -d 2>/dev/null || mktemp -d -t iamrnetes.XXXXXX)
openim::util::trap_add openim::util::cleanup-temp-dir EXIT
fi
}
iam::util::host_os() {
openim::util::host_os() {
local host_os
case "$(uname -s)" in
Darwin)
@@ -127,14 +137,14 @@ iam::util::host_os() {
host_os=linux
;;
*)
iam::log::error "Unsupported host OS. Must be Linux or Mac OS X."
openim::log::error "Unsupported host OS. Must be Linux or Mac OS X."
exit 1
;;
esac
echo "${host_os}"
}
iam::util::host_arch() {
openim::util::host_arch() {
local host_arch
case "$(uname -m)" in
x86_64*)
@@ -165,7 +175,7 @@ iam::util::host_arch() {
host_arch=ppc64le
;;
*)
iam::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
openim::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
exit 1
;;
esac
@@ -175,20 +185,20 @@ iam::util::host_arch() {
# This figures out the host platform without relying on golang. We need this as
# we don't want a golang install to be a prerequisite to building yet we need
# this info to figure out where the final binaries are placed.
iam::util::host_platform() {
echo "$(iam::util::host_os)/$(iam::util::host_arch)"
openim::util::host_platform() {
echo "$(openim::util::host_os)/$(openim::util::host_arch)"
}
# looks for $1 in well-known output locations for the platform ($2)
# $IAM_ROOT must be set
iam::util::find-binary-for-platform() {
# $OPENIM_ROOT must be set
openim::util::find-binary-for-platform() {
local -r lookfor="$1"
local -r platform="$2"
local locations=(
"${IAM_ROOT}/_output/bin/${lookfor}"
"${IAM_ROOT}/_output/${platform}/${lookfor}"
"${IAM_ROOT}/_output/local/bin/${platform}/${lookfor}"
"${IAM_ROOT}/_output/platforms/${platform}/${lookfor}"
"${OPENIM_ROOT}/_output/bin/${lookfor}"
"${OPENIM_ROOT}/_output/${platform}/${lookfor}"
"${OPENIM_ROOT}/_output/local/bin/${platform}/${lookfor}"
"${OPENIM_ROOT}/_output/platforms/${platform}/${lookfor}"
)
# List most recently-updated location.
@@ -197,42 +207,42 @@ iam::util::find-binary-for-platform() {
}
# looks for $1 in well-known output locations for the host platform
# $IAM_ROOT must be set
iam::util::find-binary() {
iam::util::find-binary-for-platform "$1" "$(iam::util::host_platform)"
# $OPENIM_ROOT must be set
openim::util::find-binary() {
openim::util::find-binary-for-platform "$1" "$(openim::util::host_platform)"
}
# Run all known doc generators (today gendocs and genman for iamctl)
# $1 is the directory to put those generated documents
iam::util::gen-docs() {
openim::util::gen-docs() {
local dest="$1"
# Find binary
gendocs=$(iam::util::find-binary "gendocs")
geniamdocs=$(iam::util::find-binary "geniamdocs")
genman=$(iam::util::find-binary "genman")
genyaml=$(iam::util::find-binary "genyaml")
genfeddocs=$(iam::util::find-binary "genfeddocs")
gendocs=$(openim::util::find-binary "gendocs")
geniamdocs=$(openim::util::find-binary "geniamdocs")
genman=$(openim::util::find-binary "genman")
genyaml=$(openim::util::find-binary "genyaml")
genfeddocs=$(openim::util::find-binary "genfeddocs")
# TODO: If ${genfeddocs} is not used from anywhere (it isn't used at
# least from k/k tree), remove it completely.
iam::util::sourced_variable "${genfeddocs}"
openim::util::sourced_variable "${genfeddocs}"
mkdir -p "${dest}/docs/guide/en-US/cmd/iamctl/"
"${gendocs}" "${dest}/docs/guide/en-US/cmd/iamctl/"
mkdir -p "${dest}/docs/guide/en-US/cmd/"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-apiserver"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-authz-server"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-pump"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "iam-watcher"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-apiserver"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-authz-server"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-pump"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/" "openim-watcher"
"${geniamdocs}" "${dest}/docs/guide/en-US/cmd/iamctl" "iamctl"
mkdir -p "${dest}/docs/man/man1/"
"${genman}" "${dest}/docs/man/man1/" "iam-apiserver"
"${genman}" "${dest}/docs/man/man1/" "iam-authz-server"
"${genman}" "${dest}/docs/man/man1/" "iam-pump"
"${genman}" "${dest}/docs/man/man1/" "iam-watcher"
"${genman}" "${dest}/docs/man/man1/" "openim-apiserver"
"${genman}" "${dest}/docs/man/man1/" "openim-authz-server"
"${genman}" "${dest}/docs/man/man1/" "openim-pump"
"${genman}" "${dest}/docs/man/man1/" "openim-watcher"
"${genman}" "${dest}/docs/man/man1/" "iamctl"
mkdir -p "${dest}/docs/guide/en-US/yaml/iamctl/"
@@ -245,14 +255,14 @@ iam::util::gen-docs() {
popd > /dev/null || return 1
}
# Removes previously generated docs-- we don't want to check them in. $IAM_ROOT
# Removes previously generated docs-- we don't want to check them in. $OPENIM_ROOT
# must be set.
iam::util::remove-gen-docs() {
if [ -e "${IAM_ROOT}/docs/.generated_docs" ]; then
openim::util::remove-gen-docs() {
if [ -e "${OPENIM_ROOT}/docs/.generated_docs" ]; then
# remove all of the old docs; we don't want to check them in.
while read -r file; do
rm "${IAM_ROOT}/${file}" 2>/dev/null || true
done <"${IAM_ROOT}/docs/.generated_docs"
rm "${OPENIM_ROOT}/${file}" 2>/dev/null || true
done <"${OPENIM_ROOT}/docs/.generated_docs"
# The docs/.generated_docs file lists itself, so we don't need to explicitly
# delete it.
fi
@@ -260,15 +270,15 @@ iam::util::remove-gen-docs() {
# Returns the name of the upstream remote repository name for the local git
# repo, e.g. "upstream" or "origin".
iam::util::git_upstream_remote_name() {
openim::util::git_upstream_remote_name() {
git remote -v | grep fetch |\
grep -E 'github.com[/:]marmotedu/iam|marmotedu.io/iam' |\
grep -E 'github.com[/:]marmotedu/openim|marmotedu.io/openim' |\
head -n 1 | awk '{print $1}'
}
# Exits script if working directory is dirty. If it's run interactively in the terminal
# the user can commit changes in a second terminal. This script will wait.
iam::util::ensure_clean_working_dir() {
openim::util::ensure_clean_working_dir() {
while ! git diff HEAD --exit-code &>/dev/null; do
echo -e "\nUnexpected dirty working directory:\n"
if tty -s; then
@@ -285,7 +295,7 @@ iam::util::ensure_clean_working_dir() {
# Find the base commit using:
# $PULL_BASE_SHA if set (from Prow)
# current ref from the remote upstream branch
iam::util::base_ref() {
openim::util::base_ref() {
local -r git_branch=$1
if [[ -n ${PULL_BASE_SHA:-} ]]; then
@@ -293,7 +303,7 @@ iam::util::base_ref() {
return
fi
full_branch="$(iam::util::git_upstream_remote_name)/${git_branch}"
full_branch="$(openim::util::git_upstream_remote_name)/${git_branch}"
# make sure the branch is valid, otherwise the check will pass erroneously.
if ! git describe "${full_branch}" >/dev/null; then
@@ -308,13 +318,13 @@ iam::util::base_ref() {
# current branch and upstream branch named by $1.
# Returns 1 (false) if there are no changes
# 0 (true) if there are changes detected.
iam::util::has_changes() {
openim::util::has_changes() {
local -r git_branch=$1
local -r pattern=$2
local -r not_pattern=${3:-totallyimpossiblepattern}
local base_ref
base_ref=$(iam::util::base_ref "${git_branch}")
base_ref=$(openim::util::base_ref "${git_branch}")
echo "Checking for '${pattern}' changes against '${base_ref}'"
# notice this uses ... to find the first shared ancestor
@@ -330,7 +340,7 @@ iam::util::has_changes() {
return 1
}
iam::util::download_file() {
openim::util::download_file() {
local -r url=$1
local -r destination_file=$2
@@ -352,7 +362,7 @@ iam::util::download_file() {
# Test whether openssl is installed.
# Sets:
# OPENSSL_BIN: The path to the openssl binary to use
function iam::util::test_openssl_installed {
function openim::util::test_openssl_installed {
if ! openssl version >& /dev/null; then
echo "Failed to run openssl. Please ensure openssl is installed"
exit 1
@@ -366,7 +376,7 @@ function iam::util::test_openssl_installed {
# '"client auth"'
# '"server auth"'
# '"client auth","server auth"'
function iam::util::create_signing_certkey {
function openim::util::create_signing_certkey {
local sudo=$1
local dest_dir=$2
local id=$3
@@ -380,7 +390,7 @@ EOF
}
# signs a client certificate: args are sudo, dest-dir, CA, filename (roughly), username, groups...
function iam::util::create_client_certkey {
function openim::util::create_client_certkey {
local sudo=$1
local dest_dir=$2
local ca=$3
@@ -404,7 +414,7 @@ EOF
}
# signs a serving certificate: args are sudo, dest-dir, ca, filename (roughly), subject, hosts...
function iam::util::create_serving_certkey {
function openim::util::create_serving_certkey {
local sudo=$1
local dest_dir=$2
local ca=$3
@@ -428,7 +438,7 @@ EOF
}
# creates a self-contained iamconfig: args are sudo, dest-dir, ca file, host, port, client id, token(optional)
function iam::util::write_client_iamconfig {
function openim::util::write_client_iamconfig {
local sudo=$1
local dest_dir=$2
local ca_file=$3
@@ -461,14 +471,14 @@ EOF
# flatten the iamconfig files to make them self contained
username=$(whoami)
${sudo} /usr/bin/env bash -e <<EOF
$(iam::util::find-binary iamctl) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
$(openim::util::find-binary iamctl) --iamconfig="${dest_dir}/${client_id}.iamconfig" config view --minify --flatten > "/tmp/${client_id}.iamconfig"
mv -f "/tmp/${client_id}.iamconfig" "${dest_dir}/${client_id}.iamconfig"
chown ${username} "${dest_dir}/${client_id}.iamconfig"
EOF
}
# Determines if docker can be run, failures may simply require that the user be added to the docker group.
function iam::util::ensure_docker_daemon_connectivity {
function openim::util::ensure_docker_daemon_connectivity {
IFS=" " read -ra DOCKER <<< "${DOCKER_OPTS}"
# Expand ${DOCKER[@]} only if it's not unset. This is to work around
# Bash 3 issue with unbound variable.
@@ -497,7 +507,7 @@ EOF
# Wait for background jobs to finish. Return with
# an error status if any of the jobs failed.
iam::util::wait-for-jobs() {
openim::util::wait-for-jobs() {
local fail=0
local job
for job in $(jobs -p); do
@@ -506,12 +516,12 @@ iam::util::wait-for-jobs() {
return ${fail}
}
# iam::util::join <delim> <list...>
# openim::util::join <delim> <list...>
# Concatenates the list elements with the delimiter passed as first parameter
#
# Ex: iam::util::join , a b c
# Ex: openim::util::join , a b c
# -> a,b,c
function iam::util::join {
function openim::util::join {
local IFS="$1"
shift
echo "$*"
@@ -527,7 +537,7 @@ function iam::util::join {
# CFSSLJSON_BIN: The path of the installed cfssljson binary
# CFSSLCERTINFO_BIN: The path of the installed cfssl-certinfo binary
#
function iam::util::ensure-cfssl {
function openim::util::ensure-cfssl {
if command -v cfssl &>/dev/null && command -v cfssljson &>/dev/null && command -v cfssl-certinfo &>/dev/null; then
CFSSL_BIN=$(command -v cfssl)
CFSSLJSON_BIN=$(command -v cfssljson)
@@ -535,7 +545,7 @@ function iam::util::ensure-cfssl {
return 0
fi
host_arch=$(iam::util::host_arch)
host_arch=$(openim::util::host_arch)
if [[ "${host_arch}" != "amd64" ]]; then
echo "Cannot download cfssl on non-amd64 hosts and cfssl does not appear to be installed."
@@ -588,13 +598,13 @@ function iam::util::ensure-cfssl {
popd > /dev/null || return 1
}
# iam::util::ensure-gnu-sed
# openim::util::ensure-gnu-sed
# Determines which sed binary is gnu-sed on linux/darwin
#
# Sets:
# SED: The name of the gnu-sed binary
#
function iam::util::ensure-gnu-sed {
function openim::util::ensure-gnu-sed {
# NOTE: the echo below is a workaround to ensure sed is executed before the grep.
# see: https://github.com/iamrnetes/iamrnetes/issues/87251
sed_help="$(LANG=C sed --help 2>&1 || true)"
@@ -603,16 +613,16 @@ function iam::util::ensure-gnu-sed {
elif command -v gsed &>/dev/null; then
SED="gsed"
else
iam::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
openim::log::error "Failed to find GNU sed as sed or gsed. If you are on Mac: brew install gnu-sed." >&2
return 1
fi
iam::util::sourced_variable "${SED}"
openim::util::sourced_variable "${SED}"
}
# iam::util::check-file-in-alphabetical-order <file>
# openim::util::check-file-in-alphabetical-order <file>
# Check that the file is in alphabetical order
#
function iam::util::check-file-in-alphabetical-order {
function openim::util::check-file-in-alphabetical-order {
local failure_file="$1"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
{
@@ -626,9 +636,9 @@ function iam::util::check-file-in-alphabetical-order {
fi
}
# iam::util::require-jq
# openim::util::require-jq
# Checks whether jq is installed.
function iam::util::require-jq {
function openim::util::require-jq {
if ! command -v jq &>/dev/null; then
echo "jq not found. Please install." 1>&2
return 1
@@ -636,7 +646,7 @@ function iam::util::require-jq {
}
# outputs md5 hash of $1, works on macOS and Linux
function iam::util::md5() {
function openim::util::md5() {
if which md5 >/dev/null 2>&1; then
md5 -q "$1"
else
@@ -644,7 +654,7 @@ function iam::util::md5() {
fi
}
# iam::util::read-array
# openim::util::read-array
# Reads in stdin and adds it line by line to the array provided. This can be
# used instead of "mapfile -t", and is bash 3 compatible.
#
@@ -652,9 +662,9 @@ function iam::util::md5() {
# $1 (name of array to create/modify)
#
# Example usage:
# iam::util::read-array files < <(ls -1)
# openim::util::read-array files < <(ls -1)
#
function iam::util::read-array {
function openim::util::read-array {
local i=0
unset -v "$1"
while IFS= read -r "$1[i++]"; do :; done
@@ -671,13 +681,13 @@ if [[ -z "${color_start-}" ]]; then
declare -r color_cyan="${color_start}1;36m"
declare -r color_norm="${color_start}0m"
iam::util::sourced_variable "${color_start}"
iam::util::sourced_variable "${color_red}"
iam::util::sourced_variable "${color_yellow}"
iam::util::sourced_variable "${color_green}"
iam::util::sourced_variable "${color_blue}"
iam::util::sourced_variable "${color_cyan}"
iam::util::sourced_variable "${color_norm}"
openim::util::sourced_variable "${color_start}"
openim::util::sourced_variable "${color_red}"
openim::util::sourced_variable "${color_yellow}"
openim::util::sourced_variable "${color_green}"
openim::util::sourced_variable "${color_blue}"
openim::util::sourced_variable "${color_cyan}"
openim::util::sourced_variable "${color_norm}"
fi
# ex: ts=2 sw=2 et filetype=sh
+52 -42
View File
@@ -1,29 +1,39 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Copyright 2020 Lingfei Kong <colin404@foxmail.com>. All rights reserved.
# Use of this source code is governed by a MIT style
# license that can be found in the LICENSE file.
# -----------------------------------------------------------------------------
# Version management helpers. These functions help to set, save and load the
# following variables:
#
# IAM_GIT_COMMIT - The git commit id corresponding to this
# OPENIM_GIT_COMMIT - The git commit id corresponding to this
# source code.
# IAM_GIT_TREE_STATE - "clean" indicates no changes since the git commit id
# OPENIM_GIT_TREE_STATE - "clean" indicates no changes since the git commit id
# "dirty" indicates source code changes after the git commit id
# "archive" indicates the tree was produced by 'git archive'
# IAM_GIT_VERSION - "vX.Y" used to indicate the last release version.
# IAM_GIT_MAJOR - The major part of the version
# IAM_GIT_MINOR - The minor component of the version
# OPENIM_GIT_VERSION - "vX.Y" used to indicate the last release version.
# OPENIM_GIT_MAJOR - The major part of the version
# OPENIM_GIT_MINOR - The minor component of the version
# Grovels through git to set a set of env variables.
#
# If IAM_GIT_VERSION_FILE, this function will load from that file instead of
# If OPENIM_GIT_VERSION_FILE, this function will load from that file instead of
# querying git.
iam::version::get_version_vars() {
if [[ -n ${IAM_GIT_VERSION_FILE-} ]]; then
iam::version::load_version_vars "${IAM_GIT_VERSION_FILE}"
openim::version::get_version_vars() {
if [[ -n ${OPENIM_GIT_VERSION_FILE-} ]]; then
openim::version::load_version_vars "${OPENIM_GIT_VERSION_FILE}"
return
fi
@@ -33,30 +43,30 @@ iam::version::get_version_vars() {
# Disabled as we're not expanding these at runtime, but rather expecting
# that another tool may have expanded these and rewritten the source (!)
if [[ '$Format:%%$' == "%" ]]; then
IAM_GIT_COMMIT='$Format:%H$'
IAM_GIT_TREE_STATE="archive"
OPENIM_GIT_COMMIT='$Format:%H$'
OPENIM_GIT_TREE_STATE="archive"
# When a 'git archive' is exported, the '$Format:%D$' below will look
# something like 'HEAD -> release-1.8, tag: v1.8.3' where then 'tag: '
# can be extracted from it.
if [[ '$Format:%D$' =~ tag:\ (v[^ ,]+) ]]; then
IAM_GIT_VERSION="${BASH_REMATCH[1]}"
OPENIM_GIT_VERSION="${BASH_REMATCH[1]}"
fi
fi
local git=(git --work-tree "${IAM_ROOT}")
local git=(git --work-tree "${OPENIM_ROOT}")
if [[ -n ${IAM_GIT_COMMIT-} ]] || IAM_GIT_COMMIT=$("${git[@]}" rev-parse "HEAD^{commit}" 2>/dev/null); then
if [[ -z ${IAM_GIT_TREE_STATE-} ]]; then
if [[ -n ${OPENIM_GIT_COMMIT-} ]] || OPENIM_GIT_COMMIT=$("${git[@]}" rev-parse "HEAD^{commit}" 2>/dev/null); then
if [[ -z ${OPENIM_GIT_TREE_STATE-} ]]; then
# Check if the tree is dirty. default to dirty
if git_status=$("${git[@]}" status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
IAM_GIT_TREE_STATE="clean"
OPENIM_GIT_TREE_STATE="clean"
else
IAM_GIT_TREE_STATE="dirty"
OPENIM_GIT_TREE_STATE="dirty"
fi
fi
# Use git describe to find the version based on tags.
if [[ -n ${IAM_GIT_VERSION-} ]] || IAM_GIT_VERSION=$("${git[@]}" describe --tags --always --match='v*' 2>/dev/null); then
if [[ -n ${OPENIM_GIT_VERSION-} ]] || OPENIM_GIT_VERSION=$("${git[@]}" describe --tags --always --match='v*' 2>/dev/null); then
# This translates the "git describe" to an actual semver.org
# compatible semantic version that looks something like this:
# v1.1.0-alpha.0.6+84c76d1142ea4d
@@ -67,22 +77,22 @@ iam::version::get_version_vars() {
# These regexes are painful enough in sed...
# We don't want to do them in pure shell, so disable SC2001
# shellcheck disable=SC2001
DASHES_IN_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/[^-]//g")
DASHES_IN_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/[^-]//g")
if [[ "${DASHES_IN_VERSION}" == "---" ]] ; then
# shellcheck disable=SC2001
# We have distance to subversion (v1.1.0-subversion-1-gCommitHash)
IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/")
OPENIM_GIT_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/")
elif [[ "${DASHES_IN_VERSION}" == "--" ]] ; then
# shellcheck disable=SC2001
# We have distance to base tag (v1.1.0-1-gCommitHash)
IAM_GIT_VERSION=$(echo "${IAM_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/")
OPENIM_GIT_VERSION=$(echo "${OPENIM_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/")
fi
if [[ "${IAM_GIT_TREE_STATE}" == "dirty" ]]; then
if [[ "${OPENIM_GIT_TREE_STATE}" == "dirty" ]]; then
# git describe --dirty only considers changes to existing files, but
# that is problematic since new untracked .go files affect the build,
# so use our idea of "dirty" from git status instead.
# TODO?
#IAM_GIT_VERSION+="-dirty"
#OPENIM_GIT_VERSION+="-dirty"
:
fi
@@ -90,17 +100,17 @@ iam::version::get_version_vars() {
# Try to match the "git describe" output to a regex to try to extract
# the "major" and "minor" versions and whether this is the exact tagged
# version or whether the tree is between two tagged versions.
if [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then
IAM_GIT_MAJOR=${BASH_REMATCH[1]}
IAM_GIT_MINOR=${BASH_REMATCH[2]}
if [[ "${OPENIM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-].*)?([+].*)?$ ]]; then
OPENIM_GIT_MAJOR=${BASH_REMATCH[1]}
OPENIM_GIT_MINOR=${BASH_REMATCH[2]}
if [[ -n "${BASH_REMATCH[4]}" ]]; then
IAM_GIT_MINOR+="+"
OPENIM_GIT_MINOR+="+"
fi
fi
# If IAM_GIT_VERSION is not a valid Semantic Version, then refuse to build.
if ! [[ "${IAM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "IAM_GIT_VERSION should be a valid Semantic Version. Current value: ${IAM_GIT_VERSION}"
# If OPENIM_GIT_VERSION is not a valid Semantic Version, then refuse to build.
if ! [[ "${OPENIM_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "OPENIM_GIT_VERSION should be a valid Semantic Version. Current value: ${OPENIM_GIT_VERSION}"
echo "Please see more details here: https://semver.org"
exit 1
fi
@@ -109,27 +119,27 @@ iam::version::get_version_vars() {
}
# Saves the environment flags to $1
iam::version::save_version_vars() {
openim::version::save_version_vars() {
local version_file=${1-}
[[ -n ${version_file} ]] || {
echo "!!! Internal error. No file specified in iam::version::save_version_vars"
echo "!!! Internal error. No file specified in openim::version::save_version_vars"
return 1
}
cat <<EOF >"${version_file}"
IAM_GIT_COMMIT='${IAM_GIT_COMMIT-}'
IAM_GIT_TREE_STATE='${IAM_GIT_TREE_STATE-}'
IAM_GIT_VERSION='${IAM_GIT_VERSION-}'
IAM_GIT_MAJOR='${IAM_GIT_MAJOR-}'
IAM_GIT_MINOR='${IAM_GIT_MINOR-}'
OPENIM_GIT_COMMIT='${OPENIM_GIT_COMMIT-}'
OPENIM_GIT_TREE_STATE='${OPENIM_GIT_TREE_STATE-}'
OPENIM_GIT_VERSION='${OPENIM_GIT_VERSION-}'
OPENIM_GIT_MAJOR='${OPENIM_GIT_MAJOR-}'
OPENIM_GIT_MINOR='${OPENIM_GIT_MINOR-}'
EOF
}
# Loads up the version variables from file $1
iam::version::load_version_vars() {
openim::version::load_version_vars() {
local version_file=${1-}
[[ -n ${version_file} ]] || {
echo "!!! Internal error. No file specified in iam::version::load_version_vars"
echo "!!! Internal error. No file specified in openim::version::load_version_vars"
return 1
}
+2 -2
View File
@@ -31,7 +31,7 @@ gen.errcode: gen.errcode.code gen.errcode.doc
.PHONY: gen.errcode.code
gen.errcode.code: tools.verify.codegen
@echo "===========> Generating iam error code go source files"
@echo "===========> Generating openim error code go source files"
@codegen -type=int ${ROOT_DIR}/internal/pkg/code
.PHONY: gen.errcode.doc
@@ -44,7 +44,7 @@ gen.errcode.doc: tools.verify.codegen
gen.ca.%:
$(eval CA := $(word 1,$(subst ., ,$*)))
@echo "===========> Generating CA files for $(CA)"
@${ROOT_DIR}/scripts/gencerts.sh generate-iam-cert $(OUTPUT_DIR)/cert $(CA)
@${ROOT_DIR}/scripts/gencerts.sh generate-openim-cert $(OUTPUT_DIR)/cert $(CA)
.PHONY: gen.ca
gen.ca: $(addprefix gen.ca., $(CERTIFICATES))
+1 -1
View File
@@ -189,7 +189,7 @@ install.protoc-gen-go:
## install.cfssl: Install cfssl, used to generate certificates
.PHONY: install.cfssl
install.cfssl:
@$(ROOT_DIR)/scripts/install/install.sh iam::install::install_cfssl
@$(ROOT_DIR)/scripts/install/install.sh openim::install::install_cfssl
## install.depth: Install depth, used to check dependency tree
.PHONY: install.depth
+14
View File
@@ -1,3 +1,17 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
db = db.getSiblingDB('admin')
db.auth('$MONGO_INITDB_ROOT_USERNAME', '$MONGO_INITDB_ROOT_PASSWORD')
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
+28 -14
View File
@@ -1,25 +1,39 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Build a IAM release. This will build the binaries, create the Docker
# Build a OpenIM release. This will build the binaries, create the Docker
# images and other build artifacts.
set -o errexit
set -o nounset
set -o pipefail
IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${IAM_ROOT}/scripts/common.sh"
source "${IAM_ROOT}/scripts/lib/release.sh"
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/common.sh"
source "${OPENIM_ROOT}/scripts/lib/release.sh"
IAM_RELEASE_RUN_TESTS=${IAM_RELEASE_RUN_TESTS-y}
OPENIM_RELEASE_RUN_TESTS=${OPENIM_RELEASE_RUN_TESTS-y}
iam::golang::setup_env
iam::build::verify_prereqs
iam::release::verify_prereqs
#iam::build::build_image
iam::build::build_command
iam::release::package_tarballs
iam::release::updload_tarballs
openim::golang::setup_env
openim::build::verify_prereqs
openim::release::verify_prereqs
#openim::build::build_image
openim::build::build_command
openim::release::package_tarballs
openim::release::updload_tarballs
git push origin ${VERSION}
#iam::release::github_release
#iam::release::generate_changelog
#openim::release::github_release
#openim::release::generate_changelog
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#fixme This scripts is the total startup scripts
#fixme The full name of the shell scripts that needs to be started is placed in the need_to_start_server_shell array
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#Include shell font styles and some basic information
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
source ./style_info.cfg
source ./path_info.cfg
+14
View File
@@ -1,4 +1,18 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#fixme This scripts is to stop the service
source ./style_info.cfg