From 73e08222f2c5d51e133e44497d84d25e594fe0ba Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 2 Feb 2022 14:51:33 +0400 Subject: [PATCH] jq replaced by yq --- install.sh | 4 +--- tools/debian_bash_upgrade | 8 ++++---- tools/semver_git_tag | 9 +++------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 784ac66..51a51ff 100755 --- a/install.sh +++ b/install.sh @@ -1,8 +1,6 @@ #!/bin/bash CURDIR=$PWD -# shellcheck disable=SC1091 -# REQUIRED_PKGS=(jq rsync file git) REQUIRED_PKGS=(file git) function usage() { @@ -72,7 +70,7 @@ function install_containers() { # install inside active LXC containers if [[ -f '/snap/bin/lxc' ]]; then - for container in $(/snap/bin/lxc list --format=json | /bin/jq -r '.[] | select(.state.status == "Running") | .name'); do + for container in $(/snap/bin/lxc list --format=json | yq '.[] | select(.state.status == "Running") | .name' -); do install_one_container $container echo done diff --git a/tools/debian_bash_upgrade b/tools/debian_bash_upgrade index 0e139a7..faac223 100755 --- a/tools/debian_bash_upgrade +++ b/tools/debian_bash_upgrade @@ -5,7 +5,7 @@ if [[ -d /opt/debian-bash ]]; then fi remote_release=$(wget_semver artcode pvincent/debian-bash) -if [[ $local_release != $remote_release ]];then +if [[ $local_release != $remote_release ]]; then echo "upgrading from <$local_release> to <$remote_release> ..." curl https://git.artcode.re/pvincent/debian-bash/raw/master/install.sh | sudo bash -s -- --full else @@ -14,9 +14,9 @@ else # install inside active LXC containers if [[ -f '/snap/bin/lxc' ]]; then echo "refreshing containers ..." - for container in `lxc list --format=json | jq -r '.[] | select(.state.status == "Running") | .name'`; do + for container in $(lxc list --format=json | yq '.[] | select(.state.status == "Running") | .name' -); do container_release=$(lxc exec $container -- cat /opt/debian-bash/.semver_git_tag) - if [[ $container_release != $remote_release ]];then + if [[ $container_release != $remote_release ]]; then echo "upgrade container <$container> from <$container_release> to <$remote_release>" /snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r else @@ -25,4 +25,4 @@ else done fi -fi \ No newline at end of file +fi diff --git a/tools/semver_git_tag b/tools/semver_git_tag index a78319e..77b371f 100755 --- a/tools/semver_git_tag +++ b/tools/semver_git_tag @@ -1,6 +1,5 @@ #!/bin/bash - function usage() { echo 'usage: --major | -M | --minor | -m | --patch | -p' exit 1 @@ -34,8 +33,6 @@ function setCommand() { ############# main - - # check git covered REPOSITORY=$(git config --get remote.origin.url) if [[ "$?" -ne 0 ]]; then @@ -131,13 +128,13 @@ GIT_ROOT_FOLDER=$(dirname $(git rev-parse --git-dir)) if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then echo "package.json detected, version replaced with new tag <${TAG}>" - if ! command -v jq &>/dev/null; then - echo 'command not found, hint: `sudo apt install jq`' + if ! command -v yq &>/dev/null; then + echo 'command not found, hint: go and fetch latest release from https://github.com/mikefarah/yq' exit 5 fi tmp=$(mktemp) - jq '.version = $TAG' --arg TAG $TAG "${GIT_ROOT_FOLDER}/package.json" >"$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json" + yq ".version = $TAG" "${GIT_ROOT_FOLDER}/package.json" >"$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json" fi