Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/src/vip-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "vip-cli",
"name": "VIP-CLI",
"version": "1.5.0",
"version": "1.5.1",
"description": "Installs VIP-CLI into the Dev Environment",
"options": {
"enabled": {
Expand Down
131 changes: 88 additions & 43 deletions features/src/vip-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,104 @@ if [ "${ENABLED}" = "true" ]; then
install -d -D -m 0755 /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli
install -m 0644 devcontainer-feature.json devcontainer-features.env /usr/local/etc/vscode-dev-containers/vip-codespaces/vip-cli/

if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1; then
# shellcheck source=/dev/null
. /etc/os-release

: "${ID:=}"
: "${ID_LIKE:=${ID}}"

case "${ID_LIKE}" in
"debian")
export DEBIAN_FRONTEND=noninteractive

if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1 || ! hash npx >/dev/null 2>&1; then
PACKAGES=""
if ! hash curl >/dev/null 2>&1; then
PACKAGES="${PACKAGES} curl"
fi

if ! hash update-ca-certificates >/dev/null 2>&1; then
PACKAGES="${PACKAGES} ca-certificates"
fi

if [ -n "${PACKAGES}" ]; then
apt-get update
# shellcheck disable=SC2086
apt-get install -y --no-install-recommends ${PACKAGES}
fi

curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
chmod +x nodesource_setup.sh
./nodesource_setup.sh
apt-get install -y nodejs

apt-get clean
rm -rf /var/lib/apt/lists/*
# shellcheck source=/dev/null
. /etc/os-release

: "${ID:=}"
: "${ID_LIKE:=${ID}}"

TMP_PKGS=""

case "${ID_LIKE}" in
"debian")
export DEBIAN_FRONTEND=noninteractive
PACKAGES=""
if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1 || ! hash npx > /dev/null 2>&1; then
if ! hash curl > /dev/null 2>&1; then
PACKAGES="${PACKAGES} curl"
fi
;;

"alpine")
if ! hash node >/dev/null 2>&1 || ! hash npm >/dev/null 2>&1; then
apk add --no-cache nodejs npm
if ! hash update-ca-certificates > /dev/null 2>&1; then
PACKAGES="${PACKAGES} ca-certificates"
fi
fi

if [ -n "${PACKAGES}" ]; then
apt-get update
# shellcheck disable=SC2086
apt-get install -y --no-install-recommends ${PACKAGES}
fi

if ! hash node > /dev/null 2>&1 || ! hash npm > /dev/null 2>&1 || ! hash npx > /dev/null 2>&1; then
curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
chmod +x nodesource_setup.sh
./nodesource_setup.sh
apt-get install -y nodejs
fi

if ! hash g++ > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} g++"
fi

if ! hash make > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} make"
fi

if ! hash python3 > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} python3"
fi

if [ -n "${TMP_PKGS}" ]; then
apt-get update
# shellcheck disable=SC2086
apt-get install -y --no-install-recommends ${TMP_PKGS}
fi
;;

"alpine")
apk add --no-cache nodejs npm
if ! hash g++ > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} g++"
fi

if ! hash make > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} make"
fi

if ! hash python3 > /dev/null 2>&1; then
TMP_PKGS="${TMP_PKGS} python3"
fi

if [ -n "${TMP_PKGS}" ]; then
# shellcheck disable=SC2086
apk add --no-cache ${TMP_PKGS}
fi
;;

*)
echo "(!) Unsupported distribution: ${ID}"
exit 1
*)
echo "(!) Unsupported distribution: ${ID}"
exit 1
;;
esac
fi
esac

npm i -g "@automattic/vip@${VIP_CLI_VERSION}"

install -D -m 0755 -o root -g root vip-sync-db.sh /usr/local/bin/vip-sync-db

if [ "${ID_LIKE}" = "debian" ]; then
if [ -n "${TMP_PKGS}" ]; then
# shellcheck disable=SC2086
apt-get remove -y --purge ${TMP_PKGS}
fi

apt-get clean
rm -rf /var/lib/apt/lists/*
elif [ "${ID_LIKE}" = "alpine" ]; then
if [ -n "${TMP_PKGS}" ]; then
# shellcheck disable=SC2086
apk del --no-cache ${TMP_PKGS}
fi
fi

echo 'Done!'
fi
Loading