From 7077083aca421c2e1c199c1607733a6c6fa34f32 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Thu, 22 Feb 2024 15:54:18 +0800 Subject: [PATCH] fix: del the error world --- install.sh | 2 +- scripts/advertise.sh | 2 +- scripts/build-all-service.sh | 4 ++-- scripts/check-all.sh | 4 ++-- scripts/cherry-pick.sh | 4 ++-- scripts/common.sh | 6 +++--- scripts/docker-start-all.sh | 4 ++-- scripts/gen-swagger-docs.sh | 4 ++-- scripts/init-config.sh | 4 ++-- scripts/init-env.sh | 2 +- scripts/install-im-server.sh | 4 ++-- scripts/install/common.sh | 6 +++--- scripts/install/dependency.sh | 6 +++--- scripts/install/install.sh | 2 +- scripts/install/openim-api.sh | 8 ++++---- scripts/install/openim-crontask.sh | 2 +- scripts/install/openim-man.sh | 2 +- scripts/install/openim-msggateway.sh | 8 ++++---- scripts/install/openim-msgtransfer.sh | 8 ++++---- scripts/install/openim-push.sh | 8 ++++---- scripts/install/openim-rpc.sh | 8 ++++---- scripts/install/openim-tools.sh | 6 +++--- scripts/lib/init.sh | 6 +++--- scripts/lib/logging.sh | 2 +- scripts/lib/util.sh | 4 ++-- scripts/list-feature-tests.sh | 4 ++-- scripts/release.sh | 4 ++-- scripts/run-in-gopath.sh | 4 ++-- scripts/start-all.sh | 4 ++-- scripts/stop-all.sh | 4 ++-- scripts/update-generated-docs.sh | 4 ++-- scripts/update-yamlfmt.sh | 4 ++-- scripts/verify-pkg-names.sh | 4 ++-- scripts/verify-shellcheck.sh | 4 ++-- scripts/verify-spelling.sh | 4 ++-- scripts/verify-typecheck.sh | 4 ++-- scripts/verify-yamlfmt.sh | 4 ++-- 37 files changed, 82 insertions(+), 82 deletions(-) diff --git a/install.sh b/install.sh index 7ff0f8739..4b8e74c55 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ # set -e -set -o pipefail + ############################## OpenIM Github ############################## # ... rest of the script ... diff --git a/scripts/advertise.sh b/scripts/advertise.sh index 3effc4f2b..958b4e3ae 100755 --- a/scripts/advertise.sh +++ b/scripts/advertise.sh @@ -14,7 +14,7 @@ # limitations under the License. set -e -set -o pipefail + . $(dirname ${BASH_SOURCE})/lib/init.sh diff --git a/scripts/build-all-service.sh b/scripts/build-all-service.sh index b5578fca6..f5bd49126 100755 --- a/scripts/build-all-service.sh +++ b/scripts/build-all-service.sh @@ -22,9 +22,9 @@ # Usage: `scripts/build-all-service.sh`. # Example: `scripts/build-go.sh WHAT=cmd/kubelet`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 062605ae1..c37b3446d 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -19,9 +19,9 @@ # Encapsulated as: `make check`. # READ: https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" diff --git a/scripts/cherry-pick.sh b/scripts/cherry-pick.sh index 8a1f8dd79..a072f1ecf 100755 --- a/scripts/cherry-pick.sh +++ b/scripts/cherry-pick.sh @@ -21,9 +21,9 @@ # checks them out to a branch named: # automated-cherry-pick-of--- -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/common.sh b/scripts/common.sh index d67389d56..702f55588 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -18,9 +18,9 @@ # shellcheck disable=SC2034 # Variables sourced in other scripts. # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + # Unset CDPATH, having it set messes up with script import paths unset CDPATH diff --git a/scripts/docker-start-all.sh b/scripts/docker-start-all.sh index 162655553..e3babbeb4 100755 --- a/scripts/docker-start-all.sh +++ b/scripts/docker-start-all.sh @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit + set -o nounset -set -o pipefail + #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 diff --git a/scripts/gen-swagger-docs.sh b/scripts/gen-swagger-docs.sh index 68410e79c..311ae8e15 100755 --- a/scripts/gen-swagger-docs.sh +++ b/scripts/gen-swagger-docs.sh @@ -15,9 +15,9 @@ # Script to generate docs from the latest swagger spec. -set -o errexit + set -o nounset -set -o pipefail + # The root of the build/dist directory OPENIM_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 82eefbb54..34b403923 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -15,9 +15,9 @@ # This script automatically initializes various configuration files and can generate example files. -set -o errexit + set -o nounset -set -o pipefail + # Root directory of the OpenIM project OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/init-env.sh b/scripts/init-env.sh index 75b871b08..495a8fcf4 100755 --- a/scripts/init-env.sh +++ b/scripts/init-env.sh @@ -17,7 +17,7 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. set -o nounset -set -o pipefail + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd -P) source "${OPENIM_ROOT}/scripts/install/common.sh" diff --git a/scripts/install-im-server.sh b/scripts/install-im-server.sh index c1224e30c..426779be0 100755 --- a/scripts/install-im-server.sh +++ b/scripts/install-im-server.sh @@ -27,9 +27,9 @@ # Usage: # SERVER_IMAGE_VERSION=latest IMAGE_REGISTRY=myregistry ./this_script.sh -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/install/common.sh b/scripts/install/common.sh index f6ee5d3ad..add1eebf8 100755 --- a/scripts/install/common.sh +++ b/scripts/install/common.sh @@ -15,9 +15,9 @@ # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + # Sourced flag COMMON_SOURCED=true diff --git a/scripts/install/dependency.sh b/scripts/install/dependency.sh index e7c7eb426..bad1cb6f9 100755 --- a/scripts/install/dependency.sh +++ b/scripts/install/dependency.sh @@ -15,9 +15,9 @@ # This script will install the dependencies required for openim -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh diff --git a/scripts/install/install.sh b/scripts/install/install.sh index d5ec5b7f7..bb09675bf 100755 --- a/scripts/install/install.sh +++ b/scripts/install/install.sh @@ -109,7 +109,7 @@ function openim::uninstall::uninstall_openim() { openim::common::sudo "systemctl stop openim.target" openim::common::sudo "systemctl disable openim.target" openim::common::sudo "rm -f /etc/systemd/system/openim.target" - set -o errexit + openim::log::success "openim uninstall success" } diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index be2a2d33b..6977b519d 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -138,7 +138,7 @@ function openim::api::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index 395b27cd1..97bdf8630 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -107,7 +107,7 @@ function openim::crontask::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-man.sh b/scripts/install/openim-man.sh index fac5cebea..642588a28 100755 --- a/scripts/install/openim-man.sh +++ b/scripts/install/openim-man.sh @@ -76,7 +76,7 @@ function openim::man::uninstall() { # Turn off exit-on-error temporarily to handle non-existing files gracefully set +o errexit openim::common::sudo "rm -f /usr/share/man/man1/openim-*" - set -o errexit + openim::log::info "Uninstalled openim man pages successfully" } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index a2316c784..903f2d32e 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -14,9 +14,9 @@ # limitations under the License. # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -117,7 +117,7 @@ function openim::msggateway::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 783e06729..bd3e51b0e 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -16,9 +16,9 @@ # ./scripts/install/openim-msgtransfer.sh openim::msgtransfer::start # Common utilities, variables and checks for all build scripts. -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -138,7 +138,7 @@ function openim::msgtransfer::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 95da16c8a..6df1d7b09 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -40,9 +40,9 @@ # # Note: Ensure that the appropriate permissions and environmental variables are set prior to script execution. # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -125,7 +125,7 @@ function openim::push::uninstall() { openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" - set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index f8feaaa57..e569cf114 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -38,9 +38,9 @@ # Note: Before executing this script, ensure that the necessary permissions are granted and relevant environmental variables are set. # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh @@ -220,7 +220,7 @@ function openim::rpc::uninstall() { openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${service}.yaml" openim::common::sudo "rm -f ${SYSTEM_FILE_PATHS[$service]}" done - set -o errexit + openim::log::info "uninstall openim-rpc successfully" } diff --git a/scripts/install/openim-tools.sh b/scripts/install/openim-tools.sh index ac60a5f45..f41ed01b9 100755 --- a/scripts/install/openim-tools.sh +++ b/scripts/install/openim-tools.sh @@ -38,9 +38,9 @@ # Example: ./openim-tools.sh openim::tools::install # -set -o errexit -set +o nounset -set -o pipefail + + + OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh diff --git a/scripts/lib/init.sh b/scripts/lib/init.sh index be8e9f8aa..4cd6d9fb8 100755 --- a/scripts/lib/init.sh +++ b/scripts/lib/init.sh @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -o errexit -set +o nounset -set -o pipefail + + + # Short-circuit if init.sh has already been sourced [[ $(type -t openim::init::loaded) == function ]] && return 0 diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 8f2bb33cf..0c34be831 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -75,7 +75,7 @@ openim::log::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 + # is a more verbose version of trap 'openim::log::errexit' ERR # setting errtrace allows our ERR trap handler to be propagated to functions, diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 1bdb7f640..51fc8af67 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -373,7 +373,7 @@ openim::util::check_ports() { # set +o errexit # Sample call for testing: # openim::util::check_ports 10002 1004 12345 13306 -# set -o errexit +# # The `openim::util::check_process_names` function analyzes the state of processes based on given names. # It accepts multiple process names as arguments and prints: @@ -1607,7 +1607,7 @@ openim::util::check_ports() { # set +o errexit # Sample call for testing: # openim::util::check_ports 10002 1004 12345 13306 -# set -o errexit +# # The `openim::util::check_process_names` function analyzes the state of processes based on given names. # It accepts multiple process names as arguments and prints: diff --git a/scripts/list-feature-tests.sh b/scripts/list-feature-tests.sh index 438474bae..7ed19e25d 100755 --- a/scripts/list-feature-tests.sh +++ b/scripts/list-feature-tests.sh @@ -18,9 +18,9 @@ # # Usage: `scripts/list-feature-tests.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. grep "\[Feature:\w+\]" "${OPENIM_ROOT}"/test/e2e/**/*.go -Eoh | LC_ALL=C sort -u \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index a34d5ee22..ed981a0ed 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -47,9 +47,9 @@ # images and other build artifacts. # Build a OpenIM release. This script supports various flags for flexible execution control. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/common.sh" source "${OPENIM_ROOT}/scripts/lib/release.sh" diff --git a/scripts/run-in-gopath.sh b/scripts/run-in-gopath.sh index 9bb8ec882..cbad11d39 100755 --- a/scripts/run-in-gopath.sh +++ b/scripts/run-in-gopath.sh @@ -20,9 +20,9 @@ # the project. # Usage: `scripts/run-in-gopath.sh `. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/start-all.sh b/scripts/start-all.sh index ca03f0c3c..2c6581208 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -17,7 +17,7 @@ #FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array. set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" @@ -30,7 +30,7 @@ if [[ $? -ne 0 ]]; then openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries." "${OPENIM_ROOT}"/scripts/build-all-service.sh fi -set -o errexit + "${OPENIM_ROOT}"/scripts/init-config.sh --skip diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 2acb9cdc5..075418509 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -18,9 +18,9 @@ # Usage: `scripts/stop.sh`. # Encapsulated as: `make stop`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh index c37c4a1f9..84b5c0f8d 100755 --- a/scripts/update-generated-docs.sh +++ b/scripts/update-generated-docs.sh @@ -18,9 +18,9 @@ # immediately before exporting docs. We do not want to check these documents in # by default. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/update-yamlfmt.sh b/scripts/update-yamlfmt.sh index 90ec8aa62..e9cfd63e2 100755 --- a/scripts/update-yamlfmt.sh +++ b/scripts/update-yamlfmt.sh @@ -14,9 +14,9 @@ # limitations under the License. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-pkg-names.sh b/scripts/verify-pkg-names.sh index 1459992e9..1357c6cb7 100755 --- a/scripts/verify-pkg-names.sh +++ b/scripts/verify-pkg-names.sh @@ -17,9 +17,9 @@ # This script verifies whether codes follow golang convention. # Usage: `scripts/verify-pkg-names.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-shellcheck.sh b/scripts/verify-shellcheck.sh index 8a5ad7321..0b8687edb 100755 --- a/scripts/verify-shellcheck.sh +++ b/scripts/verify-shellcheck.sh @@ -17,9 +17,9 @@ # This script lints each shell script by `shellcheck`. # Usage: `scripts/verify-shellcheck.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-spelling.sh b/scripts/verify-spelling.sh index 2c02dccf7..d2830f591 100755 --- a/scripts/verify-spelling.sh +++ b/scripts/verify-spelling.sh @@ -17,9 +17,9 @@ # working directory by client9/misspell package. # Usage: `scripts/verify-spelling.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. export OPENIM_ROOT diff --git a/scripts/verify-typecheck.sh b/scripts/verify-typecheck.sh index 62fca4049..529c35397 100755 --- a/scripts/verify-typecheck.sh +++ b/scripts/verify-typecheck.sh @@ -16,9 +16,9 @@ # This script does a fast type check of script srnetes code for all platforms. # Usage: `scripts/verify-typecheck.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh" diff --git a/scripts/verify-yamlfmt.sh b/scripts/verify-yamlfmt.sh index 3d0a0180d..636a9c8e4 100755 --- a/scripts/verify-yamlfmt.sh +++ b/scripts/verify-yamlfmt.sh @@ -19,9 +19,9 @@ # # Usage: `scripts/verify-yamlfmt.sh`. -set -o errexit + set -o nounset -set -o pipefail + OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/lib/init.sh"