diff --git a/.github/workflows/build_helper.sh b/.github/workflows/build_helper.sh index 3f2ca07..26b2583 100755 --- a/.github/workflows/build_helper.sh +++ b/.github/workflows/build_helper.sh @@ -1350,7 +1350,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Fedora # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi @@ -1377,7 +1377,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Ubuntu or Debian # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi @@ -1386,7 +1386,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Alpine # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fadf78..26af3d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,16 +57,15 @@ jobs: container: - ubuntu:24.04 - ubuntu:22.04 - - ubuntu:20.04 - debian:bookworm - debian:bullseye - rockylinux:9 - rockylinux:8 - fedora:41 - fedora:40 + - alpine:3.21 - alpine:3.20 - alpine:3.19 - - alpine:3.18 container: image: ${{ matrix.container }} diff --git a/.github/workflows/ostypevars.sh b/.github/workflows/ostypevars.sh index 5ead54a..b04fce3 100644 --- a/.github/workflows/ostypevars.sh +++ b/.github/workflows/ostypevars.sh @@ -115,20 +115,6 @@ elif echo "${CI_OSTYPE}" | grep -q -i -e "ubuntu:22.04" -e "ubuntu:jammy"; then PKG_EXT="deb" IS_OS_UBUNTU=1 -elif echo "${CI_OSTYPE}" | grep -q -i -e "ubuntu:20.04" -e "ubuntu:focal"; then - DIST_TAG="ubuntu/focal" - INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps dh-systemd" - INSTALLER_BIN="apt-get" - UPDATE_CMD="update" - UPDATE_CMD_ARG="" - INSTALL_CMD="install" - INSTALL_CMD_ARG="" - INSTALL_AUTO_ARG="-y" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="debian_build" - PKG_EXT="deb" - IS_OS_UBUNTU=1 - elif echo "${CI_OSTYPE}" | grep -q -i -e "debian:12" -e "debian:bookworm"; then DIST_TAG="debian/bookworm" INSTALL_PKG_LIST="git autoconf autotools-dev make dh-make fakeroot dpkg-dev devscripts pkg-config ruby-dev rubygems rubygems-integration procps" @@ -213,8 +199,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "fedora:40"; then PKG_EXT="rpm" IS_OS_FEDORA=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then - DIST_TAG="alpine/v3.20" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.21"; then + DIST_TAG="alpine/v3.21" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf musl-locales ruby-dev procps" INSTALLER_BIN="apk" UPDATE_CMD="update" @@ -227,8 +213,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then PKG_EXT="apk" IS_OS_ALPINE=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then - DIST_TAG="alpine/v3.19" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then + DIST_TAG="alpine/v3.20" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf musl-locales ruby-dev procps" INSTALLER_BIN="apk" UPDATE_CMD="update" @@ -241,8 +227,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then PKG_EXT="apk" IS_OS_ALPINE=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.18"; then - DIST_TAG="alpine/v3.18" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then + DIST_TAG="alpine/v3.19" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf musl-locales ruby-dev procps" INSTALLER_BIN="apk" UPDATE_CMD="update" diff --git a/AUTHORS b/AUTHORS index bdbc350..f7732ba 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,6 @@ Wrote from scratch the initial version of k2hr3-get-resource. -3. Hirotaka Wakabayashi +2. Hirotaka Wakabayashi Technical engineer of k2hr3-get-resource product. diff --git a/README.md b/README.md index 4bea5fd..dbd4f42 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ K2HR3 Get Resource(K2HR3 Utilities) [![GitHub forks](https://img.shields.io/github/forks/yahoojapan/k2hr3_get_resource.svg)](https://github.com/yahoojapan/k2hr3_get_resource/network) [![GitHub stars](https://img.shields.io/github/stars/yahoojapan/k2hr3_get_resource.svg)](https://github.com/yahoojapan/k2hr3_get_resource/stargazers) [![GitHub issues](https://img.shields.io/github/issues/yahoojapan/k2hr3_get_resource.svg)](https://github.com/yahoojapan/k2hr3_get_resource/issues) -[![debian packages](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) [![RPM packages](https://img.shields.io/badge/rpm-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) +[![debian packages](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) +[![ALPINE packages](https://img.shields.io/badge/apk-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) ### **K2HR3** - **K2H**dkc based **R**esource and **R**oles and policy **R**ules @@ -35,40 +36,42 @@ K2HR3 Get Resource is a Systemd Timer Service for retrieving RESOURCE data from - Use the common directory /etc/antpickax. ### Documents -[K2HR3 Document](https://k2hr3.antpick.ax/index.html) -[K2HR3 Web Application Usage](https://k2hr3.antpick.ax/usage_app.html) -[K2HR3 Command Line Interface Usage](https://k2hr3.antpick.ax/cli.html) -[K2HR3 REST API Usage](https://k2hr3.antpick.ax/api.html) -[K2HR3 OpenStack Notification Listener Usage](https://k2hr3.antpick.ax/detail_osnl.html) -[K2HR3 Watcher Usage](https://k2hr3.antpick.ax/tools.html) -[K2HR3 Get Resource Usage](https://k2hr3.antpick.ax/tools.html) -[K2HR3 Utilities for Setup](https://k2hr3.antpick.ax/setup.html) -[K2HR3 Demonstration](https://demo.k2hr3.antpick.ax/) - -[About k2hdkc](https://k2hdkc.antpick.ax/) -[About k2hash](https://k2hash.antpick.ax/) -[About chmpx](https://chmpx.antpick.ax/) -[About k2hash transaction plugin](https://k2htpdtor.antpick.ax/) - -[About AntPickax](https://antpick.ax/) +- [K2HR3 Document](https://k2hr3.antpick.ax/index.html) +- [K2HR3 Web Application Usage](https://k2hr3.antpick.ax/usage_app.html) +- [K2HR3 Command Line Interface Usage](https://k2hr3.antpick.ax/cli.html) +- [K2HR3 REST API Usage](https://k2hr3.antpick.ax/api.html) +- [K2HR3 OpenStack Notification Listener Usage](https://k2hr3.antpick.ax/detail_osnl.html) +- [K2HR3 Watcher Usage](https://k2hr3.antpick.ax/tools.html) +- [K2HR3 Get Resource Usage](https://k2hr3.antpick.ax/tools.html) +- [K2HR3 Utilities for Setup](https://k2hr3.antpick.ax/setup.html) +- [K2HR3 Demonstration](https://demo.k2hr3.antpick.ax/) + +- [About k2hdkc](https://k2hdkc.antpick.ax/) +- [About k2hash](https://k2hash.antpick.ax/) +- [About chmpx](https://chmpx.antpick.ax/) +- [About k2hash transaction plugin](https://k2htpdtor.antpick.ax/) + +- [About AntPickax](https://antpick.ax/) ### Repositories -[K2HR3 main repository](https://github.com/yahoojapan/k2hr3) -[K2HR3 Web Application repository](https://github.com/yahoojapan/k2hr3_app) -[K2HR3 Command Line Interface repository](https://github.com/yahoojapan/k2hr3_cli) -[K2HR3 REST API repository](https://github.com/yahoojapan/k2hr3_api) -[K2HR3 OpenStack Notification Listener](https://github.com/yahoojapan/k2hr3_osnl) -[K2HR3 Utilities](https://github.com/yahoojapan/k2hr3_utils) -[K2HR3 Container Registration Sidecar](https://github.com/yahoojapan/k2hr3_sidecar) -[K2HR3 Get Resource](https://github.com/yahoojapan/k2hr3_get_resource) - -[k2hdkc](https://github.com/yahoojapan/k2hdkc) -[k2hash](https://github.com/yahoojapan/k2hash) -[chmpx](https://github.com/yahoojapan/chmpx) -[k2hash transaction plugin](https://github.com/yahoojapan/k2htp_dtor) +- [K2HR3 main repository](https://github.com/yahoojapan/k2hr3) +- [K2HR3 Web Application repository](https://github.com/yahoojapan/k2hr3_app) +- [K2HR3 Command Line Interface repository](https://github.com/yahoojapan/k2hr3_cli) +- [K2HR3 REST API repository](https://github.com/yahoojapan/k2hr3_api) +- [K2HR3 OpenStack Notification Listener](https://github.com/yahoojapan/k2hr3_osnl) +- [K2HR3 Get Resource](https://github.com/yahoojapan/k2hr3_get_resource) +- [K2HR3 Utilities](https://github.com/yahoojapan/k2hr3_utils) +- [K2HR3 Container Registration Sidecar](https://github.com/yahoojapan/k2hr3_sidecar) + +- [k2hdkc](https://github.com/yahoojapan/k2hdkc) +- [k2hash](https://github.com/yahoojapan/k2hash) +- [chmpx](https://github.com/yahoojapan/chmpx) +- [k2hash transaction plugin](https://github.com/yahoojapan/k2htp_dtor) ### Packages -[k2hr3-get-resource(packages)](https://packagecloud.io/app/antpickax/stable/search?q=k2hr3-get-resource) +- [RPM packages(packagecloud.io)](https://packagecloud.io/app/antpickax/stable/search?q=k2hr3-get-resource&filter=rpm&dist=&arch=) +- [Debian packages(packagecloud.io)](https://packagecloud.io/app/antpickax/stable/search?q=k2hr3-get-resource&filter=deb&dist=&arch=) +- [ALPINE packages(packagecloud.io)](https://packagecloud.io/app/antpickax/stable/search?q=k2hr3-get-resource&filter=all&dist=alpine&arch=) ### License This software is released under the MIT License, see the license file. diff --git a/autogen.sh b/autogen.sh index 3d4170f..a4ac58a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -54,18 +54,18 @@ while [ $# -ne 0 ]; do echo "[ERROR] Parameters are something wrong." exit 1 - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then echo "Usage: ${AUTOGEN_NAME} [--help(-h)] [--no_update_version_file(-nu)] [--no_aclocal_force(-na)] [--no_check_ver_diff(-nc)]" exit 0 - elif [ "$1" = "-nu" ] || [ "$1" = "-NU" ] || [ "$1" = "--no_update_version_file" ] || [ "$1" = "--NO_UPDATE_VERSION_FILE" ]; then + elif echo "$1" | grep -q -i -e "^-nu$" -e "^--no_update_version_file$"; then UPDATE_VERSION_FILE=0 FORCEPARAM="" # do not need force - elif [ "$1" = "-na" ] || [ "$1" = "-NA" ] || [ "$1" = "--no_aclocal_force" ] || [ "$1" = "--NO_ACLOCAL_FORCE" ]; then + elif echo "$1" | grep -q -i -e "^-na$" -e "^--no_aclocal_force$"; then FORCEPARAM="" - elif [ "$1" = "-nc" ] || [ "$1" = "-NC" ] || [ "$1" = "--no_check_ver_diff" ] || [ "$1" = "--NO_CHECK_VER_DIFF" ]; then + elif echo "$1" | grep -q -i -e "^-nc$" -e "^--no_check_ver_diff$"; then PARAMETERS="$1" else diff --git a/buildutils/alpine_build.sh b/buildutils/alpine_build.sh index 013a111..d0a5680 100755 --- a/buildutils/alpine_build.sh +++ b/buildutils/alpine_build.sh @@ -99,11 +99,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ -n "${BUILD_NUMBER}" ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -119,7 +119,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -131,7 +131,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 diff --git a/buildutils/debian_build.sh b/buildutils/debian_build.sh index f407dc3..727456a 100755 --- a/buildutils/debian_build.sh +++ b/buildutils/debian_build.sh @@ -104,11 +104,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ "${BUILD_NUMBER}" -ne 0 ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -128,7 +128,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -140,7 +140,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-c" ] || [ "$1" = "-C" ] || [ "$1" = "--class" ] || [ "$1" = "--CLASS" ]; then + elif echo "$1" | grep -q -i -e "^-c$" -e "^--class$"; then if [ -n "${PKG_CLASS_NAME}" ]; then echo "[ERROR] Already --class(-c) option is specified(${PKG_CLASS_NAME})." 1>&2 exit 1 @@ -152,7 +152,7 @@ while [ $# -ne 0 ]; do fi PKG_CLASS_NAME="$1" - elif [ "$1" = "-dt" ] || [ "$1" = "-DT" ] || [ "$1" = "--disttype" ] || [ "$1" = "--DISTTYPE" ]; then + elif echo "$1" | grep -q -i -e "^-dt$" -e "^--disttype$"; then if [ -n "${OS_VERSION_NAME}" ]; then echo "[ERROR] Already --disttype(-dt) option is specified(${OS_VERSION_NAME})." 1>&2 exit 1 @@ -164,14 +164,14 @@ while [ $# -ne 0 ]; do fi OS_VERSION_NAME="$1" - elif [ "$1" = "-r" ] || [ "$1" = "-R" ] || [ "$1" = "--rootdir" ] || [ "$1" = "--ROOTDIR" ]; then + elif echo "$1" | grep -q -i -e "^-r$" -e "^--rootdir$"; then if [ "${IS_ROOTDIR}" -ne 0 ]; then echo "[ERROR] Already --rootdir(-r) option is specified." 1>&2 exit 1 fi IS_ROOTDIR=1 - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 @@ -255,9 +255,9 @@ if [ "${NO_INTERACTIVE}" -eq 0 ]; then printf '[INPUT] Confirm (y/n) : ' read -r CONFIRM - if [ "${CONFIRM}" = "y" ] || [ "${CONFIRM}" = "Y" ] || [ "${CONFIRM}" = "yes" ] || [ "${CONFIRM}" = "YES" ]; then + if echo "${CONFIRM}" | grep -q -i -e "^y$" -e "^yes$"; then IS_CONFIRMED=1 - elif [ "${CONFIRM}" = "n" ] || [ "${CONFIRM}" = "N" ] || [ "${CONFIRM}" = "no" ] || [ "${CONFIRM}" = "NO" ]; then + elif echo "${CONFIRM}" | grep -q -i -e "^n$" -e "^no$"; then echo "Interrupt this processing, bye..." exit 0 fi diff --git a/buildutils/make_release_version_file.sh b/buildutils/make_release_version_file.sh index 8a2331f..1416080 100755 --- a/buildutils/make_release_version_file.sh +++ b/buildutils/make_release_version_file.sh @@ -68,31 +68,31 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-ng" ] || [ "$1" = "-NG" ] || [ "$1" = "--not_use_git" ] || [ "$1" = "--NOT_USE_GIT" ]; then + elif echo "$1" | grep -q -i -e "^-ng$" -e "^--not_use_git$"; then if [ "${NOT_USE_GIT}" -ne 0 ]; then echo "[ERROR] already --not_use_git(-ng) option is specified." 1>&2 exit 1 fi NOT_USE_GIT=1 - elif [ "$1" = "-nd" ] || [ "$1" = "-ND" ] || [ "$1" = "--no_check_ver_diff" ] || [ "$1" = "--NO_CHECK_VER_DIFF" ]; then + elif echo "$1" | grep -q -i -e "^-nd$" -e "^--no_check_ver_diff$"; then if [ "${NO_CHECK_VER_DIFF}" -ne 0 ]; then echo "[ERROR] already --no_check_ver_diff(-nd) option is specified." 1>&2 exit 1 fi NO_CHECK_VER_DIFF=1 - elif [ "$1" = "-f" ] || [ "$1" = "-F" ] || [ "$1" = "--file" ] || [ "$1" = "--FILE" ]; then + elif echo "$1" | grep -q -i -e "^-f$" -e "^--file$"; then if [ -n "${CHANGELOG_FILE}" ]; then echo "[ERROR] already --file(-f) option is specified(${CHANGELOG_FILE})." 1>&2 exit 1 fi shift - if [ $# -eq 0 ] || [ -z "$1" ]; then + if [ $# -eq 0 ]; then echo "[ERROR] Must set changelog file path after -file(-f) option." 1>&2 exit 1 fi diff --git a/buildutils/make_rpm_changelog.sh b/buildutils/make_rpm_changelog.sh index 37c5e9e..5a1875a 100755 --- a/buildutils/make_rpm_changelog.sh +++ b/buildutils/make_rpm_changelog.sh @@ -61,7 +61,7 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 diff --git a/buildutils/make_variables.sh b/buildutils/make_variables.sh index 7eb1cbb..d230f62 100755 --- a/buildutils/make_variables.sh +++ b/buildutils/make_variables.sh @@ -65,11 +65,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-pv" ] || [ "$1" = "-PV" ] || [ "$1" = "--pkg_version" ] || [ "$1" = "--PKG_VERSION" ]; then + elif echo "$1" | grep -q -i -e "^-pv$" -e "^--pkg_version$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -78,7 +78,7 @@ while [ $# -ne 0 ]; do PRGMODE="PKG" EXCLUSIVE_OPT=1 - elif [ "$1" = "-lvi" ] || [ "$1" = "-LVI" ] || [ "$1" = "--lib_version_info" ] || [ "$1" = "--LIB_VERSION_INFO" ]; then + elif echo "$1" | grep -q -i -e "^-lvi$" -e "^--lib_version_info$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -87,7 +87,7 @@ while [ $# -ne 0 ]; do PRGMODE="LIB" EXCLUSIVE_OPT=1 - elif [ "$1" = "-lvl" ] || [ "$1" = "-LVL" ] || [ "$1" = "--lib_version_for_link" ] || [ "$1" = "--LIB_VERSION_FOR_LINK" ]; then + elif echo "$1" | grep -q -i -e "^-lvl$" -e "^--lib_version_for_link$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -96,7 +96,7 @@ while [ $# -ne 0 ]; do PRGMODE="LINK" EXCLUSIVE_OPT=1 - elif [ "$1" = "-mn" ] || [ "$1" = "-MN" ] || [ "$1" = "--major_number" ] || [ "$1" = "--MAJOR_NUMBER" ]; then + elif echo "$1" | grep -q -i -e "^-mn$" -e "^--major_number$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -105,7 +105,7 @@ while [ $# -ne 0 ]; do PRGMODE="MAJOR" EXCLUSIVE_OPT=1 - elif [ "$1" = "-dd" ] || [ "$1" = "-DD" ] || [ "$1" = "--debhelper_dep" ] || [ "$1" = "--DEBHELPER_DEP" ]; then + elif echo "$1" | grep -q -i -e "^-dd$" -e "^--debhelper_dep$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -115,7 +115,7 @@ while [ $# -ne 0 ]; do DEB_WITH_SYSTEMD=0 EXCLUSIVE_OPT=1 - elif [ "$1" = "-dds" ] || [ "$1" = "-DDS" ] || [ "$1" = "--debhelper_dep_with_systemd" ] || [ "$1" = "--DEBHELPER_DEP_WITH_SYSTEMD" ]; then + elif echo "$1" | grep -q -i -e "^-dds$" -e "^--debhelper_dep_with_systemd$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -125,7 +125,7 @@ while [ $# -ne 0 ]; do DEB_WITH_SYSTEMD=1 EXCLUSIVE_OPT=1 - elif [ "$1" = "-rg" ] || [ "$1" = "-RG" ] || [ "$1" = "--rpmpkg_group" ] || [ "$1" = "--RPMPKG_GROUP" ]; then + elif echo "$1" | grep -q -i -e "^-rg$" -e "^--rpmpkg_group$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' diff --git a/buildutils/rpm_build.sh b/buildutils/rpm_build.sh index 8ba71af..ffe69c2 100755 --- a/buildutils/rpm_build.sh +++ b/buildutils/rpm_build.sh @@ -86,11 +86,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ "${BUILD_NUMBER}" -ne 0 ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -110,7 +110,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -122,7 +122,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 @@ -172,9 +172,9 @@ if [ "${NO_INTERACTIVE}" -eq 0 ]; then printf '[INPUT] Confirm (y/n) : ' read -r CONFIRM - if [ "${CONFIRM}" = "y" ] || [ "${CONFIRM}" = "Y" ] || [ "${CONFIRM}" = "yes" ] || [ "${CONFIRM}" = "YES" ]; then + if echo "${CONFIRM}" | grep -q -i -e "^y$" -e "^yes$"; then IS_CONFIRMED=1 - elif [ "${CONFIRM}" = "n" ] || [ "${CONFIRM}" = "N" ] || [ "${CONFIRM}" = "no" ] || [ "${CONFIRM}" = "NO" ]; then + elif echo "${CONFIRM}" | grep -q -i -e "^n$" -e "^no$"; then echo "Interrupt this processing, bye..." exit 0 fi diff --git a/src/k2hr3-get-resource-helper b/src/k2hr3-get-resource-helper index 5d5ed7b..ec7f94d 100755 --- a/src/k2hr3-get-resource-helper +++ b/src/k2hr3-get-resource-helper @@ -602,7 +602,7 @@ if [ "${SCRIPT_MODE}" != "daemon" ]; then if [ $$ -ne "${OLD_PROCESS_PID}" ]; then # shellcheck disable=SC2009 - if ps -p "${OLD_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_PROCESS_PID}$" || exit 1 && exit 0 ); then log_err "Already process PID(${OLD_PROCESS_PID}) running, thus this script exits." exit 1 fi @@ -681,7 +681,7 @@ if [ "${SCRIPT_MODE}" != "daemon" ]; then OLD_DAEMON_PROCESS_PID=$(cat "${PIDDIR}/${SCRIPT_DAEMON_PIDFILE}") # shellcheck disable=SC2009 - if ! ps -p "${OLD_DAEMON_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_DAEMON_PROCESS_PID}$" || exit 1 && exit 0 ); then rm -f "${PIDDIR}/${SCRIPT_DAEMON_PIDFILE}" IS_NEED_DAEMON_RUN=1 fi @@ -726,7 +726,7 @@ else OLD_DAEMON_PROCESS_PID=$(cat "${PIDDIR}/${SCRIPT_DAEMON_PIDFILE}") # shellcheck disable=SC2009 - if ps -p "${OLD_DAEMON_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_DAEMON_PROCESS_PID}$" || exit 1 && exit 0 ); then log_err "Already process PID(${OLD_DAEMON_PROCESS_PID}) running, thus this daemon exits." exit 1 fi