diff options
author | NeonXP <i@neonxp.ru> | 2024-01-28 20:43:11 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.ru> | 2024-01-28 22:07:35 +0300 |
commit | 11412b2e720f754900b39d195f33af39ed11d085 (patch) | |
tree | 96d7e561f21809aead3c0f25034f083f46ef064c /features/src/common-utils/bin | |
parent | 6c00916212073678bbeb3bdde3f121c4efad707a (diff) |
Diffstat (limited to 'features/src/common-utils/bin')
-rwxr-xr-x | features/src/common-utils/bin/code | 16 | ||||
-rwxr-xr-x | features/src/common-utils/bin/devcontainer-info | 35 | ||||
-rwxr-xr-x | features/src/common-utils/bin/systemctl | 7 |
3 files changed, 58 insertions, 0 deletions
diff --git a/features/src/common-utils/bin/code b/features/src/common-utils/bin/code new file mode 100755 index 0000000..b0d517f --- /dev/null +++ b/features/src/common-utils/bin/code @@ -0,0 +1,16 @@ +#!/bin/sh + +get_in_path_except_current() { + which -a "$1" | grep -A1 "$0" | grep -v "$0" +} + +code="$(get_in_path_except_current code)" + +if [ -n "$code" ]; then + exec "$code" "$@" +elif [ "$(command -v code-insiders)" ]; then + exec code-insiders "$@" +else + echo "code or code-insiders is not installed" >&2 + exit 127 +fi diff --git a/features/src/common-utils/bin/devcontainer-info b/features/src/common-utils/bin/devcontainer-info new file mode 100755 index 0000000..abbb682 --- /dev/null +++ b/features/src/common-utils/bin/devcontainer-info @@ -0,0 +1,35 @@ +#!/bin/sh + +# Load meta.env +if [ -f "/usr/local/etc/vscode-dev-containers/meta.env" ]; then + . /usr/local/etc/vscode-dev-containers/meta.env +fi +if [ -f "/usr/local/etc/dev-containers/meta.env" ]; then + . /usr/local/etc/dev-containers/meta.env +fi + +# Minimal output +if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then + echo "${VERSION}" + exit 0 +elif [ "$1" = "release" ]; then + echo "${GIT_REPOSITORY_RELEASE}" + exit 0 +elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then + echo "${CONTENTS_URL}" + exit 0 +fi + +#Full output +echo +echo "Development container image information" +echo +if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi +if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi +if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi +if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi +if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi +if [ ! -z "${GIT_REPOSITORY_REVISION}" ]; then echo "- Source code revision: ${GIT_REPOSITORY_REVISION}"; fi +if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi +if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi +echo diff --git a/features/src/common-utils/bin/systemctl b/features/src/common-utils/bin/systemctl new file mode 100755 index 0000000..4ead985 --- /dev/null +++ b/features/src/common-utils/bin/systemctl @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +if [ -d "/run/systemd/system" ]; then + exec /bin/systemctl "$@" +else + echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services instead. e.g.: \n\nservice --status-all' +fi |