Skip to content

Commit

Permalink
update docker-cli plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
moukoublen committed Mar 17, 2024
1 parent 6ba8469 commit 6162b0d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
27 changes: 19 additions & 8 deletions scripts/install-docker-buildx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

set -e

# global path: /usr/local/lib/docker/cli-plugins
PLUGINS_DIR="${HOME}/.docker/cli-plugins/"
mkdir -p "${PLUGINS_DIR}"
# $HOME/.docker/cli-plugins

# /usr/local/lib/docker/cli-plugins
# /usr/local/libexec/docker/cli-plugins

# /usr/lib/docker/cli-plugins
# /usr/libexec/docker/cli-plugins

# PLUGINS_DIR="${HOME}/.docker/cli-plugins/"
# mkdir -p "${PLUGINS_DIR}"
PLUGINS_DIR="/usr/local/lib/docker/cli-plugins"
sudo mkdir -p "${PLUGINS_DIR}"

__remote_version() {
local JS_BODY="${1}"
Expand All @@ -22,15 +31,18 @@ __get_dl_url() {
local ENDSWITH
ENDSWITH=$(echo "$(uname -s)-$(uname -m)" | tr '[:upper:]' '[:lower:]')
case "${ENDSWITH}" in
linux-x86_64)
"linux-x86_64")
ENDSWITH="linux-amd64"
;;
linux-aarch64)
"linux-aarch64")
ENDSWITH="linux-arm64"
;;
darwin-x86_64)
"darwin-x86_64")
ENDSWITH="darwin-amd64"
;;
"darwin-arm64")
ENDSWITH="darwin-arm64"
;;
esac
echo "${JS_BODY}" | jq -r ".assets[] | select(.name | endswith(\"${ENDSWITH}\")) | .browser_download_url"
}
Expand All @@ -41,8 +53,7 @@ __install_exec() {
local DOWNLOADED_FULL_PATH="${2}"
#local TMP_DIR
#TMP_DIR="$(dirname "${DOWNLOADED_FULL_PATH}")"
cp "${DOWNLOADED_FULL_PATH}" "${BIN_DIR}"/docker-buildx
chmod +x "${BIN_DIR}"/docker-buildx
sudo install -D --owner=root --group=root --mode=0755 "${DOWNLOADED_FULL_PATH}" "${BIN_DIR}/docker-buildx"
}
export -f __install_exec

Expand Down
41 changes: 33 additions & 8 deletions scripts/install-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

set -e

# global path: /usr/local/lib/docker/cli-plugins
PLUGINS_DIR="${HOME}/.docker/cli-plugins/"
mkdir -p "${PLUGINS_DIR}"
# $HOME/.docker/cli-plugins

# /usr/local/lib/docker/cli-plugins
# /usr/local/libexec/docker/cli-plugins

# /usr/lib/docker/cli-plugins
# /usr/libexec/docker/cli-plugins

# PLUGINS_DIR="${HOME}/.docker/cli-plugins/"
# mkdir -p "${PLUGINS_DIR}"
PLUGINS_DIR="/usr/local/lib/docker/cli-plugins"
sudo mkdir -p "${PLUGINS_DIR}"

__remote_version() {
local JS_BODY="${1}"
Expand All @@ -20,18 +29,34 @@ export -f __local_version

__get_dl_url() {
local JS_BODY="${1}"
local BINARY
BINARY=$(echo "docker-compose-$(uname -s)-$(uname -m)" | tr '[:upper:]' '[:lower:]')
echo "${JS_BODY}" | jq -r ".assets[] | select(.name | test(\"^${BINARY}$\")) | .browser_download_url"
local ENDSWITH
ENDSWITH=$(echo "$(uname -s)-$(uname -m)" | tr '[:upper:]' '[:lower:]')
case "${ENDSWITH}" in
"linux-x86_64")
ENDSWITH="linux-x86_64"
;;
"linux-aarch64")
ENDSWITH="linux-aarch64"
;;
"darwin-x86_64")
ENDSWITH="darwin-x86_64"
;;
"darwin-arm64")
ENDSWITH="darwin-aarch64"
;;
esac
echo "${JS_BODY}" | jq -r ".assets[] | select(.name | endswith(\"${ENDSWITH}\")) | .browser_download_url"
}
export -f __get_dl_url

__install_exec() {
local BIN_DIR="${1}"
local DOWNLOADED_FULL_PATH="${2}"

cp "${DOWNLOADED_FULL_PATH}" "${BIN_DIR}"/docker-compose
chmod +x "${BIN_DIR}"/docker-compose
# cp "${DOWNLOADED_FULL_PATH}" "${BIN_DIR}"/docker-compose
# chmod +x "${BIN_DIR}"/docker-compose

sudo install -D --owner=root --group=root --mode=0755 "${DOWNLOADED_FULL_PATH}" "${BIN_DIR}/docker-compose"
}
export -f __install_exec

Expand Down

0 comments on commit 6162b0d

Please sign in to comment.