Родитель
8cb8584640
Коммит
b192845130
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,57 +1,17 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
# Run definition specific tests
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
# checkExtension "<Extension ID goes here>"
|
||||
# check "<label>" command goes here
|
||||
# checkOSPackages "<label>" package list goes here
|
||||
# checkMultiple "<label>" condition1 condition2
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- chown the test-project folder to make sure non-root can access it --
|
||||
sudo chown -R $(id -u) .
|
||||
|
||||
# -- Actual tests - add more here --
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,57 +1,17 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
# Run definition specific tests
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
# checkExtension "<Extension ID goes here>"
|
||||
# check "<label>" command goes here
|
||||
# checkOSPackages "<label>" package list goes here
|
||||
# checkMultiple "<label>" condition1 condition2
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- chown the test-project folder to make sure non-root can access it --
|
||||
sudo chown -R $(id -u) .
|
||||
|
||||
# -- Actual tests - add more here --
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,50 +1,17 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
# Run definition specific tests
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
# checkExtension "<Extension ID goes here>"
|
||||
# check "<label>" command goes here
|
||||
# checkOSPackages "<label>" package list goes here
|
||||
# checkMultiple "<label>" condition1 condition2
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- Actual tests - add more here --
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -29,6 +29,11 @@ if [ "${SWITCHED_TO_BASH}" != "true" ]; then
|
|||
exit $?
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -156,6 +161,27 @@ fi
|
|||
EOF
|
||||
)"
|
||||
|
||||
# code shim, it fallbacks to code-insiders if code is not available
|
||||
cat << 'EOF' > /usr/local/bin/code
|
||||
#!/bin/bash
|
||||
|
||||
get_in_path_except_current() {
|
||||
which -a "$1" | grep -v "$0" | head -1
|
||||
}
|
||||
|
||||
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
|
||||
EOF
|
||||
chmod +x /usr/local/bin/code
|
||||
|
||||
# Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
|
||||
CODESPACES_BASH="$(cat \
|
||||
<<EOF
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if apk info -e "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="git \
|
||||
openssh-client \
|
||||
gnupg \
|
||||
procps \
|
||||
lsof \
|
||||
htop \
|
||||
net-tools \
|
||||
psmisc \
|
||||
curl \
|
||||
wget \
|
||||
rsync \
|
||||
ca-certificates \
|
||||
unzip \
|
||||
zip \
|
||||
nano \
|
||||
vim \
|
||||
less \
|
||||
jq \
|
||||
libgcc \
|
||||
libstdc++ \
|
||||
krb5-libs \
|
||||
libintl \
|
||||
libssl1.1 \
|
||||
lttng-ust \
|
||||
tzdata \
|
||||
userspace-rcu \
|
||||
zlib \
|
||||
sudo \
|
||||
coreutils \
|
||||
sed \
|
||||
grep \
|
||||
which \
|
||||
ncdu \
|
||||
shadow \
|
||||
strace \
|
||||
man-pages"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,56 +1,10 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils-alpine.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip wget curl jq less nano unzip
|
||||
check "bash" bash --version
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,7 +22,7 @@ RUN bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "$
|
|||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
|
||||
|
||||
# Install Truffle Suite and Ganache CLI
|
||||
RUN su ${USERNAME} -c "source ${NVM_DIR}/nvm.sh \
|
||||
RUN su ${USERNAME} -c ". ${NVM_DIR}/nvm.sh \
|
||||
&& npm i --unsafe-perm -g truffle \
|
||||
&& npm i -g ganache-cli" 2>&1
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,56 +1,14 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Run definition specific tests
|
||||
checkExtension "ms-vscode.azurecli"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
check "azure-cli" az --version
|
||||
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "source ${NVM_DIR}/nvm.sh && nvm install --lts",
|
||||
"postCreateCommand": ". ${NVM_DIR}/nvm.sh && nvm install --lts",
|
||||
|
||||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode"
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -131,5 +136,6 @@ fi
|
|||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install gradle
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export GRADLE_USER_HOME=\${HOME}/.gradle"
|
||||
|
||||
echo "Done!"
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,7 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
if [ "${JAVA_VERSION}" != "none" ]; then
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
fi
|
||||
|
||||
echo "Done!"
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install Maven
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export M2=\$HOME/.m2"
|
||||
|
||||
echo "Done!"
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -81,7 +86,7 @@ if [ -d "/usr/local/rvm" ]; then
|
|||
echo "Ruby Version Manager already exists."
|
||||
if [ "${RUBY_VERSION}" != "none" ]; then
|
||||
echo "Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
fi
|
||||
SKIP_GEM_INSTALL="false"
|
||||
else
|
||||
|
@ -93,7 +98,7 @@ else
|
|||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
fi
|
||||
|
||||
|
@ -101,7 +106,7 @@ if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ];
|
|||
# Non-root user may not have "gem" in path when script is run and no ruby version
|
||||
# is installed by rvm, so handle this by using root's default gem in this case
|
||||
ROOT_GEM="$(which gem)"
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}"
|
||||
fi
|
||||
|
||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||
|
|
|
@ -21,6 +21,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -80,5 +85,6 @@ EOF
|
|||
|
||||
# Add CARGO_HOME, RUSTUP_HOME and bin directory into bashrc/zshrc files (unless disabled)
|
||||
updaterc "export CARGO_HOME=\"${CARGO_HOME}\"\nexport RUSTUP_HOME=\"${RUSTUP_HOME}\"\nexport PATH=\"\${CARGO_HOME}/bin:\${PATH}\""
|
||||
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# SSH uses a login shells, so we need to ensure these get the same initial PATH as non-login shells.
|
||||
# /etc/profile wipes out the path which is a problem when the PATH was modified using the ENV directive in a Dockerfile.
|
||||
echo "export PATH=${PATH//$(bash -lc 'echo $PATH')/\${PATH}}" > /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash -i
|
||||
cd $(dirname "$0")
|
||||
|
||||
USERNAME=$1
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if "$@"; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL="$1"
|
||||
shift
|
||||
check "$LABEL" dpkg-query --show -f='${Package}: ${Version}\n' "$@"
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Settings
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "/home/vscode" [ -d "/home/${USERNAME}" ]
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "code" bash -i -c "code --version"
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed common tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All common tests passed!"
|
||||
exit 0
|
||||
fi
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,57 +1,19 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh codespace
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if "$@"; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL="$1"
|
||||
shift
|
||||
check "$LABEL" dpkg-query --show -f='${Package}: ${Version}\n' "$@"
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
USERNAME=codespace
|
||||
if ! ./test-common.sh ${USERNAME}; then
|
||||
FAILED+=("common-tests")
|
||||
fi
|
||||
# Check default extensions
|
||||
checkExtension "gitHub.vscode-pull-request-github"
|
||||
|
||||
# Check Oryx
|
||||
check "oryx" oryx platforms
|
||||
check "oryx" oryx --version
|
||||
|
||||
# Check .NET
|
||||
check "dotnet" dotnet --info
|
||||
check "dotnet" dotnet --list-sdks
|
||||
|
||||
# Check Python
|
||||
check "python" python --version
|
||||
|
@ -67,20 +29,21 @@ check "bandit" bandit --version
|
|||
check "virtualenv" virtualenv --version
|
||||
|
||||
# Check Java tools
|
||||
check "java" java --version
|
||||
check "sdkman" sdk --version
|
||||
check "java" java -version
|
||||
check "sdkman" bash -c ". /usr/local/sdkman/bin/sdkman-init.sh && sdk --version"
|
||||
check "gradle" gradle --version
|
||||
check "maven" mvn --version
|
||||
|
||||
# Check Ruby tools
|
||||
check "ruby" ruby --version
|
||||
check "rvm" rvm --version
|
||||
check "rake" rake --version
|
||||
check "rvm" bash -c ". /usr/local/rvm/scripts/rvm && rvm --version"
|
||||
check "ruby" bash -c ". /usr/local/rvm/scripts/rvm && ruby --version"
|
||||
check "rake" bash -c ". /usr/local/rvm/scripts/rvm && rake --version"
|
||||
check "rbenv" bash -c 'eval "$(rbenv init -)" && rbenv --version'
|
||||
|
||||
# Node.js
|
||||
check "node" node --version
|
||||
check "nvm" nvm --version
|
||||
check "nvs" nvs --version
|
||||
check "nvm" bash -c ". /home/codespace/.nvm/nvm.sh && nvm --version"
|
||||
check "nvs" bash -c ". /home/codespace/.nvs/nvs.sh && nvs --version"
|
||||
check "yarn" yarn --version
|
||||
check "npm" npm --version
|
||||
|
||||
|
@ -110,13 +73,7 @@ check "fish" fish --version
|
|||
check "zsh" zsh --version
|
||||
|
||||
# Check expected commands
|
||||
check "git-ed" test "$(cat $(which git-ed.sh))" = "$(cat ./git-ed-expected.txt)"
|
||||
check "git-ed" [ "$(cat /home/codespace/.local/bin/git-ed.sh)" = "$(cat ./git-ed-expected.txt)" ]
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -90,7 +90,7 @@ RUN bash /tmp/scripts/node-debian.sh "${NVM_DIR}" "none" "${USERNAME}" \
|
|||
# Install SDKMAN, OpenJDK8 (JDK 11 already present), gradle (maven already present)
|
||||
RUN bash /tmp/scripts/gradle-debian.sh "latest" "${SDKMAN_DIR}" "${USERNAME}" "true" \
|
||||
&& bash /tmp/scripts/java-debian.sh "8.0.275.hs-adpt" "${SDKMAN_DIR}" "${USERNAME}" "true" \
|
||||
&& su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh \
|
||||
&& su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh \
|
||||
&& sdk install java opt-java-11 /opt/java/11.0 \
|
||||
&& sdk install java opt-java-lts /opt/java/lts \
|
||||
&& sdk default java opt-java-lts"
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -131,5 +136,6 @@ fi
|
|||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install gradle
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export GRADLE_USER_HOME=\${HOME}/.gradle"
|
||||
|
||||
echo "Done!"
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,7 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
if [ "${JAVA_VERSION}" != "none" ]; then
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
fi
|
||||
|
||||
echo "Done!"
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install Maven
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export M2=\$HOME/.m2"
|
||||
|
||||
echo "Done!"
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -81,7 +86,7 @@ if [ -d "/usr/local/rvm" ]; then
|
|||
echo "Ruby Version Manager already exists."
|
||||
if [ "${RUBY_VERSION}" != "none" ]; then
|
||||
echo "Installing specified Ruby version."
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && rvm install ruby ${RUBY_VERSION}"
|
||||
fi
|
||||
SKIP_GEM_INSTALL="false"
|
||||
else
|
||||
|
@ -93,7 +98,7 @@ else
|
|||
# Install RVM
|
||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
||||
usermod -aG rvm ${USERNAME}
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && rvm fix-permissions system"
|
||||
rm -rf ${GNUPGHOME}
|
||||
fi
|
||||
|
||||
|
@ -101,7 +106,7 @@ if [ "${INSTALL_RUBY_TOOLS}" = "true" ] && [ "${SKIP_GEM_INSTALL}" != "true" ];
|
|||
# Non-root user may not have "gem" in path when script is run and no ruby version
|
||||
# is installed by rvm, so handle this by using root's default gem in this case
|
||||
ROOT_GEM="$(which gem)"
|
||||
su ${USERNAME} -c "source /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}"
|
||||
su ${USERNAME} -c ". /usr/local/rvm/scripts/rvm && \"$(which gem || ${ROOT_GEM})\" install ${DEFAULT_GEMS}"
|
||||
fi
|
||||
|
||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||
|
|
|
@ -21,6 +21,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -80,5 +85,6 @@ EOF
|
|||
|
||||
# Add CARGO_HOME, RUSTUP_HOME and bin directory into bashrc/zshrc files (unless disabled)
|
||||
updaterc "export CARGO_HOME=\"${CARGO_HOME}\"\nexport RUSTUP_HOME=\"${RUSTUP_HOME}\"\nexport PATH=\"\${CARGO_HOME}/bin:\${PATH}\""
|
||||
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# SSH uses a login shells, so we need to ensure these get the same initial PATH as non-login shells.
|
||||
# /etc/profile wipes out the path which is a problem when the PATH was modified using the ENV directive in a Dockerfile.
|
||||
echo "export PATH=${PATH//$(bash -lc 'echo $PATH')/\${PATH}}" > /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash -i
|
||||
cd $(dirname "$0")
|
||||
|
||||
USERNAME=$1
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if "$@"; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL="$1"
|
||||
shift
|
||||
check "$LABEL" dpkg-query --show -f='${Package}: ${Version}\n' "$@"
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Settings
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "/home/vscode" [ -d "/home/${USERNAME}" ]
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "code" bash -i -c "code --version"
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed common tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All common tests passed!"
|
||||
exit 0
|
||||
fi
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,57 +1,19 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh codespace
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if "$@"; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL="$1"
|
||||
shift
|
||||
check "$LABEL" dpkg-query --show -f='${Package}: ${Version}\n' "$@"
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
USERNAME=codespace
|
||||
if ! ./test-common.sh ${USERNAME}; then
|
||||
FAILED+=("common-tests")
|
||||
fi
|
||||
# Check default extensions
|
||||
checkExtension "gitHub.vscode-pull-request-github"
|
||||
|
||||
# Check Oryx
|
||||
check "oryx" oryx platforms
|
||||
check "oryx" oryx --version
|
||||
|
||||
# Check .NET
|
||||
check "dotnet" dotnet --info
|
||||
check "dotnet" dotnet --list-sdks
|
||||
|
||||
# Check Python
|
||||
check "python" python --version
|
||||
|
@ -68,19 +30,20 @@ check "virtualenv" virtualenv --version
|
|||
|
||||
# Check Java tools
|
||||
check "java" java -version
|
||||
check "sdkman" sdk --version
|
||||
check "sdkman" bash -c ". /usr/local/sdkman/bin/sdkman-init.sh && sdk --version"
|
||||
check "gradle" gradle --version
|
||||
check "maven" mvn --version
|
||||
|
||||
# Check Ruby tools
|
||||
check "ruby" ruby --version
|
||||
check "rvm" rvm --version
|
||||
check "rvm" bash -c ". /usr/local/rvm/scripts/rvm && rvm --version"
|
||||
check "rbenv" bash -c 'eval "$(rbenv init -)" && rbenv --version'
|
||||
check "rake" rake --version
|
||||
|
||||
# Node.js
|
||||
check "node" node --version
|
||||
check "nvm" nvm --version
|
||||
check "nvs" nvs --version
|
||||
check "nvm" bash -c ". /home/codespace/.nvm/nvm.sh && nvm --version"
|
||||
check "nvs" bash -c ". /home/codespace/.nvs/nvs.sh && nvs --version"
|
||||
check "yarn" yarn --version
|
||||
check "npm" npm --version
|
||||
|
||||
|
@ -110,13 +73,7 @@ check "fish" fish --version
|
|||
check "zsh" zsh --version
|
||||
|
||||
# Check expected commands
|
||||
check "git-ed" test "$(cat $(which git-ed.sh))" = "$(cat ./git-ed-expected.txt)"
|
||||
check "git-ed" [ "$(cat /home/codespace/.local/bin/git-ed.sh)" = "$(cat ./git-ed-expected.txt)" ]
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,48 +1,14 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Run definition specific tests
|
||||
checkExtension "ms-vscode.cpptools"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release g++ gcc cmake cppcheck valgrind
|
||||
checkOSPackages "command-line-tools" build-essential cmake cppcheck valgrind clang lldb llvm gdb
|
||||
check "g++" g++ -g main.cpp -o main.out
|
||||
rm main.out
|
||||
mkdir -p build
|
||||
|
@ -51,11 +17,5 @@ check "cmake" cmake ..
|
|||
cd ..
|
||||
rm -rf build
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
## Report result
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,56 +1,10 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release wget curl jq less nano unzip
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
source test-utils.sh vscode
|
||||
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,62 +1,18 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# chown the test-project folder to make sure non-root can access it
|
||||
sudo chown -R $(id -u) .
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Run Docker init script
|
||||
/usr/local/share/docker-init.sh
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "ms-azuretools.vscode-docker"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
check "docker" docker ps -a
|
||||
check "docker-compose" docker-compose --version
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,59 +1,18 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Run Docker init script
|
||||
/usr/local/share/docker-init.sh
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "ms-azuretools.vscode-docker"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
check "docker" docker ps -a
|
||||
check "docker-compose" docker-compose --version
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,64 +1,20 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- Actual tests --
|
||||
EXPECTED_USER=vscode
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id ${EXPECTED_USER}"
|
||||
check "/home/${EXPECTED_USER}" [ -d "/home/${EXPECTED_USER}" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
|
||||
# Check platforms
|
||||
# Definition specific tests
|
||||
checkExtension "ms-dotnettools.csharp"
|
||||
checkExtension "ionide.ionide-fsharp"
|
||||
check "dotnet" dotnet --info
|
||||
check "nuget" dotnet restore
|
||||
check "msbuild" dotnet msbuild
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
check "yarn" yarn install
|
||||
|
||||
# Check expected shells
|
||||
check "bash" bash --version
|
||||
check "zsh" zsh --version
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,66 +1,20 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- Actual tests --
|
||||
EXPECTED_USER=vscode
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id ${EXPECTED_USER}"
|
||||
check "/home/${EXPECTED_USER}" [ -d "/home/${EXPECTED_USER}" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
|
||||
# Check platforms
|
||||
# Definition specific tests
|
||||
checkExtension "ms-dotnettools.csharp"
|
||||
checkExtension "ms-mssql.mssql"
|
||||
check "dotnet" dotnet --info
|
||||
check "nuget" dotnet restore
|
||||
check "msbuild" dotnet msbuild
|
||||
check "nvm" nvm --version
|
||||
check "node" node --version
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
check "yarn" yarn install
|
||||
|
||||
# Check expected shells
|
||||
check "bash" bash --version
|
||||
check "zsh" zsh --version
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,66 +1,19 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
# -- Utility functions --
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# -- Actual tests --
|
||||
EXPECTED_USER=vscode
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
check "non-root-user" "id ${EXPECTED_USER}"
|
||||
check "/home/${EXPECTED_USER}" [ -d "/home/${EXPECTED_USER}" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release
|
||||
|
||||
# Check platforms
|
||||
# Definition specific tests
|
||||
checkExtension "ms-dotnettools.csharp"
|
||||
check "dotnet" dotnet --info
|
||||
check "nuget" dotnet restore
|
||||
check "msbuild" dotnet msbuild
|
||||
check "nvm" nvm --version
|
||||
check "node" node --version
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
check "yarn" yarn install
|
||||
|
||||
# Check expected shells
|
||||
check "bash" bash --version
|
||||
check "zsh" zsh --version
|
||||
|
||||
# -- Report results --
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
# Report result
|
||||
reportResults
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "Elixir, Phoenix, Node.js & PostgresSQL",
|
||||
"name": "Elixir, Phoenix, Node.js & PostgresSQL (Community)",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "elixir",
|
||||
"workspaceFolder": "/workspace",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
example/
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,59 +1,23 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]"
|
||||
}
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]"
|
||||
checkExtension "jakebecker.elixir-ls"
|
||||
check "elixir" iex --version
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "node" node --version
|
||||
check "npm" npm install
|
||||
check "build test project" echo yes | mix phx.new example --live
|
||||
check "download deps" cd ./example && mix deps.get && mix deps.compile
|
||||
check "phoenix" mix test
|
||||
# Hex only installed for non-root user, so skip phoenix test for root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
check "phoenix" mix test --force
|
||||
fi
|
||||
rm -rf example
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -131,5 +136,6 @@ fi
|
|||
|
||||
# Add GOPATH variable and bin directory into PATH in bashrc/zshrc files (unless disabled)
|
||||
updaterc "export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${GOPATH}/bin:\${PATH}\""
|
||||
|
||||
echo "Done!"
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,39 +1,10 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Prep
|
||||
echo -e "\nGetting Maven wrapper..."
|
||||
|
@ -42,14 +13,8 @@ mv maven-wrapper-maven-wrapper-0.5.5/mvnw mvnw
|
|||
mv maven-wrapper-maven-wrapper-0.5.5/.mvn .mvn
|
||||
rm -rf mv maven-wrapper-maven-wrapper-0.5.5
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "vscjava.vscode-java-pack"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release curl
|
||||
check "java" java -version
|
||||
check "build-and-test-jar" ./mvnw package
|
||||
check "test-project" java -jar target/my-app-1.0-SNAPSHOT.jar
|
||||
|
@ -59,10 +24,4 @@ rm -f mvnw
|
|||
rm -rf .mvn
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install gradle
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export GRADLE_USER_HOME=\${HOME}/.gradle"
|
||||
|
||||
echo "Done!"
|
||||
|
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,7 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
if [ "${JAVA_VERSION}" != "none" ]; then
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION} && sdk flush archives && sdk flush temp"
|
||||
fi
|
||||
|
||||
echo "Done!"
|
|
@ -25,6 +25,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -68,6 +73,7 @@ if [ ! -d "${SDKMAN_DIR}" ]; then
|
|||
fi
|
||||
|
||||
# Install Maven
|
||||
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk flush archives && sdk flush temp"
|
||||
updaterc "export M2=\$HOME/.m2"
|
||||
|
||||
echo "Done!"
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,39 +1,10 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh vscode
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
# Prep
|
||||
echo -e "\nGetting Maven wrapper..."
|
||||
|
@ -42,14 +13,8 @@ mv maven-wrapper-maven-wrapper-0.5.5/mvnw mvnw
|
|||
mv maven-wrapper-maven-wrapper-0.5.5/.mvn .mvn
|
||||
rm -rf mv maven-wrapper-maven-wrapper-0.5.5
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "vscjava.vscode-java-pack"
|
||||
check "non-root-user" "id vscode"
|
||||
check "/home/vscode" [ -d "/home/vscode" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release curl
|
||||
check "java" java -version
|
||||
check "build-and-test-jar" ./mvnw package
|
||||
check "test-project" java -jar target/my-app-1.0-SNAPSHOT.jar
|
||||
|
@ -59,10 +24,4 @@ rm -f mvnw
|
|||
rm -rf .mvn
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,64 +1,20 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh node
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# chown the test-project folder to make sure non-root can access it
|
||||
sudo chown -R $(id -u) .
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "dbaeumer.vscode-eslint"
|
||||
check "non-root-user" "id node"
|
||||
check "/home/node" [ -d "/home/node" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release wget curl less unzip
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "node" "node --version"
|
||||
check "node" node --version
|
||||
check "yarn" yarn install
|
||||
check "npm" npm install
|
||||
check "eslint" "eslint server.js"
|
||||
check "eslint" eslint server.js
|
||||
check "test-project" npm run test
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 8"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,64 +1,20 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh node
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# chown the test-project folder to make sure non-root can access it
|
||||
sudo chown -R $(id -u) .
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "dbaeumer.vscode-eslint"
|
||||
check "non-root-user" "id node"
|
||||
check "/home/node" [ -d "/home/node" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release wget curl less unzip
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "node" "node --version"
|
||||
check "node" node --version
|
||||
check "yarn" yarn install
|
||||
check "npm" npm install
|
||||
check "eslint" "eslint server.js"
|
||||
check "eslint" eslint server.js
|
||||
check "test-project" npm run test
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 8"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
|
@ -11,9 +11,10 @@ ARG UPGRADE_PACKAGES="true"
|
|||
ARG USERNAME=node
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
ENV NVM_DIR=/usr/local/share/nvm
|
||||
ENV NVM_SYMLINK_CURRENT=true \
|
||||
PATH=${NVM_DIR}/current/bin:${PATH}
|
||||
PATH=${NPM_GLOBAL}/bin:${NVM_DIR}/current/bin:${PATH}
|
||||
COPY library-scripts/*.sh /tmp/library-scripts/
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
||||
|
@ -23,22 +24,18 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|||
# Install yarn, nvm
|
||||
&& rm -rf /opt/yarn-* /usr/local/bin/yarn /usr/local/bin/yarnpkg \
|
||||
&& bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "none" "${USERNAME}" \
|
||||
# Clean up
|
||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/library-scripts
|
||||
|
||||
# Configure global npm install location
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
RUN mkdir -p ${NPM_GLOBAL} \
|
||||
# Configure global npm install location
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& chown ${USERNAME}:root ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& sudo -u ${USERNAME} npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& echo "if [ \"\$(stat -c '%U' ${NPM_GLOBAL})\" != \"${USERNAME}\" ]; then sudo chown -R ${USERNAME}:root ${NPM_GLOBAL} ${NVM_DIR}; fi" \
|
||||
| tee -a /etc/bash.bashrc >> /etc/zsh/zshrc
|
||||
|
||||
# Install eslint
|
||||
RUN sudo -u ${USERNAME} npm install -g eslint \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
&& echo "if [ \"\$(stat -c '%U' ${NPM_GLOBAL})\" != \"\$USER\" ]; then sudo chown -R \$USER:root ${NPM_GLOBAL} \${NVM_DIR}; fi" \
|
||||
| tee -a /etc/bash.bashrc >> /etc/zsh/zshrc \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1 \
|
||||
# Clean up
|
||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/library-scripts
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
|
|
|
@ -22,6 +22,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# If in automatic mode, determine if a user already exists, if not use vscode
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
|
|
@ -20,6 +20,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
|
||||
rm -f /etc/profile.d/00-restore-env.sh
|
||||
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\${PATH}" > /etc/profile.d/00-restore-env.sh
|
||||
chmod +x /etc/profile.d/00-restore-env.sh
|
||||
|
||||
# Determine the appropriate non-root user
|
||||
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
|
||||
USERNAME=""
|
||||
|
@ -66,7 +71,7 @@ fi
|
|||
if [ -d "${NVM_DIR}" ]; then
|
||||
echo "NVM already installed."
|
||||
if [ "${NODE_VERSION}" != "" ]; then
|
||||
su ${USERNAME} -c "source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
#!/bin/bash
|
||||
|
||||
USERNAME=${1:-vscode}
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
|
||||
FAILED=()
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
echo -e "\n🧪 Testing $LABEL."
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
if [ $PASSED -ge $MINIMUMPASSED ]; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkOSPackages() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL"
|
||||
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
|
||||
echo "✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo "❌ $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
|
||||
EXTN_ID="$1"
|
||||
TIMEOUT_SECONDS="${2:-10}"
|
||||
RETRY_COUNT=0
|
||||
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
|
||||
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
|
||||
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
|
||||
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
|
||||
do
|
||||
sleep 1s
|
||||
(( RETRY_COUNT++ ))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
|
||||
echo -e "\n✅ Passed!"
|
||||
return 0
|
||||
else
|
||||
echo -e "\n❌ Extension $EXTN_ID not found."
|
||||
FAILED+=("$LABEL")
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkCommon()
|
||||
{
|
||||
PACKAGE_LIST="apt-utils \
|
||||
git \
|
||||
openssh-client \
|
||||
less \
|
||||
iproute2 \
|
||||
procps \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
nano \
|
||||
jq \
|
||||
lsb-release \
|
||||
ca-certificates \
|
||||
apt-transport-https \
|
||||
dialog \
|
||||
gnupg2 \
|
||||
libc6 \
|
||||
libgcc1 \
|
||||
libgssapi-krb5-2 \
|
||||
liblttng-ust0 \
|
||||
libstdc++6 \
|
||||
zlib1g \
|
||||
locales \
|
||||
sudo"
|
||||
|
||||
# Actual tests
|
||||
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
|
||||
checkMultiple "vscode-server" 1 "[ -d $HOME/.vscode-server/bin ]" "[ -d $HOME/.vscode-server-insiders/bin ]" "[ -d $HOME/.vscode-test-server/bin ]" "[ -d $HOME/.vscode-remote/bin ]" "[ -d $HOME/.vscode-remote/bin ]"
|
||||
check "non-root-user" id ${USERNAME}
|
||||
check "locale" [ $(locale -a | grep en_US.utf8) ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
|
||||
check "code" which code
|
||||
}
|
||||
|
||||
reportResults() {
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,63 +1,20 @@
|
|||
#!/bin/bash -i
|
||||
#!/bin/bash
|
||||
cd $(dirname "$0")
|
||||
|
||||
if [ -z $HOME ]; then
|
||||
HOME="/root"
|
||||
fi
|
||||
source test-utils.sh node
|
||||
|
||||
FAILED=()
|
||||
# Run common tests
|
||||
checkCommon
|
||||
|
||||
check() {
|
||||
LABEL=$1
|
||||
shift
|
||||
echo -e "\n🧪 Testing $LABEL: $@"
|
||||
if $@; then
|
||||
echo "🏆 Passed!"
|
||||
else
|
||||
echo "💥 $LABEL check failed."
|
||||
FAILED+=("$LABEL")
|
||||
fi
|
||||
}
|
||||
|
||||
checkMultiple() {
|
||||
PASSED=0
|
||||
LABEL="$1"
|
||||
shift; MINIMUMPASSED=$1
|
||||
shift; EXPRESSION="$1"
|
||||
while [ "$EXPRESSION" != "" ]; do
|
||||
if $EXPRESSION; then ((PASSED++)); fi
|
||||
shift; EXPRESSION=$1
|
||||
done
|
||||
check "$LABEL" [ $PASSED -ge $MINIMUMPASSED ]
|
||||
}
|
||||
|
||||
checkExtension() {
|
||||
checkMultiple "$1" 1 "[ -d ""$HOME/.vscode-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-server-insiders/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-test-server/extensions/$1*"" ]" "[ -d ""$HOME/.vscode-remote/extensions/$1*"" ]"
|
||||
}
|
||||
|
||||
# Actual tests
|
||||
checkMultiple "vscode-server" 1 "[ -d ""$HOME/.vscode-server/bin"" ]" "[ -d ""$HOME/.vscode-server-insiders/bin"" ]" "[ -d ""$HOME/.vscode-test-server/bin"" ]" "[ -d ""$HOME/.vscode-remote/bin"" ]"
|
||||
# Definition specific tests
|
||||
checkExtension "dbaeumer.vscode-eslint"
|
||||
check "node" "node --version"
|
||||
check "non-root-user" "id node"
|
||||
check "/home/node" [ -d "/home/node" ]
|
||||
check "sudo" sudo echo "sudo works."
|
||||
check "git" git --version
|
||||
check "command-line-tools" which top ip lsb_release wget curl jq less nano unzip
|
||||
check "zsh" zsh --version
|
||||
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
|
||||
check "node" node --version
|
||||
check "nvm" nvm --version
|
||||
check "yarn" yarn install
|
||||
check "npm" npm install
|
||||
check "eslint" "eslint server.js"
|
||||
check "eslint" eslint server.js
|
||||
check "test-project" npm run test
|
||||
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 8"
|
||||
check "nvm-node" bash -c ". /usr/local/share/nvm/nvm.sh && node --version"
|
||||
|
||||
# Report result
|
||||
if [ ${#FAILED[@]} -ne 0 ]; then
|
||||
echo -e "\n💥 Failed tests: ${FAILED[@]}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n💯 All passed!"
|
||||
exit 0
|
||||
fi
|
||||
reportResults
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче