Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support non root user and install specified aqua version #16

Merged
merged 7 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aqua-installer/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aqua-installer",
"id": "aqua-installer",
"version": "0.1.0",
"version": "0.1.1",
"description": "Install aqua",
"options": {
"aqua_version": {
Expand Down
30 changes: 23 additions & 7 deletions src/aqua-installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ if ! has_command curl && ! has_command wget; then
if has_command apt-get; then
apt-get update -y
apt-get install -y curl
elif has_command apk > /dev/null 2>&1; then
elif has_command apk; then
apk add curl
else
log_error "Neither curl nor wget is found. Please install either curl or wget to download aqua"
exit 1
fi
fi

pwd
ls

url=https://raw.githubusercontent.com/aquaproj/aqua-installer/v3.0.0/aqua-installer

tempdir=$(mktemp -d)
if [ "$_REMOTE_USER" = root ]; then
tempdir=$(mktemp -d)
else
tempdir=$(sudo -u "$_REMOTE_USER" mktemp -d)
fi
cd "$tempdir"

if has_command curl; then
Expand All @@ -54,7 +55,22 @@ fi

echo "8299de6c19a8ff6b2cc6ac69669cf9e12a96cece385658310aea4f4646a5496d aqua-installer" | sha256sum -c

chmod +x aqua-installer
./aqua-installer
chmod a+x aqua-installer
if [ "$_REMOTE_USER" = root ]; then
./aqua-installer -v "$AQUA_VERSION"
else
if ! has_command sudo; then
if has_command apt-get; then
apt-get update -y
apt-get install -y sudo
elif has_command apk; then
apk add sudo
else
log_error "Please install sudo to run aqua-installer as $_REMOTE_USER"
exit 1
fi
fi
sudo -u "$_REMOTE_USER" ./aqua-installer -v "$AQUA_VERSION"
fi

rm -R "$tempdir"
5 changes: 5 additions & 0 deletions test/aqua-installer/alpine-nonroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eu

aqua -v
6 changes: 6 additions & 0 deletions test/aqua-installer/alpine-nonroot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine:3.19.1
RUN apk add sudo && \
sed -i "s|# %wheel ALL=(ALL:ALL) NOPASSWD: ALL|%wheel ALL=(ALL:ALL) NOPASSWD: ALL|" /etc/sudoers && \
adduser -u 1000 -G wheel -D vscode && \
rm -rf /var/cache/apk/*
USER vscode
13 changes: 13 additions & 0 deletions test/aqua-installer/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,18 @@
"aqua_version": "v2.27.0"
}
}
},
"alpine-nonroot": {
"build": {
"dockerfile": "Dockerfile"
},
"remoteEnv": {
"PATH": "/home/vscode/.local/share/aquaproj-aqua/bin:${containerEnv:PATH}"
},
"features": {
"aqua-installer": {
"aqua_version": "v2.27.0"
}
}
}
}