Skip to content

Commit

Permalink
fix: support non root user and install specified aqua version (#16)
Browse files Browse the repository at this point in the history
* fix: add a test of non root user

* fix: support non root user

* refactor: remove unnecessary redirect

* refactor: remove debug codes

* fix: specify aqua version

* fix: use aqua-installer -v option

* chore: update version
  • Loading branch information
suzuki-shunsuke authored May 9, 2024
1 parent 7823c9d commit caf6bef
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
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"
}
}
}
}

0 comments on commit caf6bef

Please sign in to comment.