jq replaced by yq
This commit is contained in:
+1
-3
@@ -1,8 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
CURDIR=$PWD
|
CURDIR=$PWD
|
||||||
# shellcheck disable=SC1091
|
|
||||||
# REQUIRED_PKGS=(jq rsync file git)
|
|
||||||
REQUIRED_PKGS=(file git)
|
REQUIRED_PKGS=(file git)
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
@@ -72,7 +70,7 @@ function install_containers() {
|
|||||||
|
|
||||||
# install inside active LXC containers
|
# install inside active LXC containers
|
||||||
if [[ -f '/snap/bin/lxc' ]]; then
|
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
|
install_one_container $container
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ if [[ -d /opt/debian-bash ]]; then
|
|||||||
fi
|
fi
|
||||||
remote_release=$(wget_semver artcode pvincent/debian-bash)
|
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> ..."
|
echo "upgrading from <$local_release> to <$remote_release> ..."
|
||||||
curl https://git.artcode.re/pvincent/debian-bash/raw/master/install.sh | sudo bash -s -- --full
|
curl https://git.artcode.re/pvincent/debian-bash/raw/master/install.sh | sudo bash -s -- --full
|
||||||
else
|
else
|
||||||
@@ -14,9 +14,9 @@ else
|
|||||||
# install inside active LXC containers
|
# install inside active LXC containers
|
||||||
if [[ -f '/snap/bin/lxc' ]]; then
|
if [[ -f '/snap/bin/lxc' ]]; then
|
||||||
echo "refreshing containers ..."
|
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)
|
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>"
|
echo "upgrade container <$container> from <$container_release> to <$remote_release>"
|
||||||
/snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r
|
/snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo 'usage: --major | -M | --minor | -m | --patch | -p'
|
echo 'usage: --major | -M | --minor | -m | --patch | -p'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -34,8 +33,6 @@ function setCommand() {
|
|||||||
|
|
||||||
############# main
|
############# main
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# check git covered
|
# check git covered
|
||||||
REPOSITORY=$(git config --get remote.origin.url)
|
REPOSITORY=$(git config --get remote.origin.url)
|
||||||
if [[ "$?" -ne 0 ]]; then
|
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
|
if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then
|
||||||
|
|
||||||
echo "package.json detected, version replaced with new tag <${TAG}>"
|
echo "package.json detected, version replaced with new tag <${TAG}>"
|
||||||
if ! command -v jq &>/dev/null; then
|
if ! command -v yq &>/dev/null; then
|
||||||
echo 'command <jq> not found, hint: `sudo apt install jq`'
|
echo 'command <yq> not found, hint: go and fetch latest release from https://github.com/mikefarah/yq'
|
||||||
exit 5
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp)
|
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
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user