Skip to content

🌱 Fix envsubstr installation in Devbox #5452

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

Merged
merged 2 commits into from
Apr 4, 2025
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
1 change: 1 addition & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"shell": {
"init_hook": [
"export PATH=$PWD/bin:$PATH",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that once you are in the devbox shell, you by default use envsubst & clusterawsadm from bin

"./scripts/devbox-init-hook.sh"
],
"scripts": {
Expand Down
32 changes: 8 additions & 24 deletions scripts/devbox-init-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,13 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR="$(dirname $DIR)"

# Set install path
INSTALL_DIR="$HOME/.local/bin"
INSTALL_DIR="$SRC_DIR/bin"
mkdir -p "$INSTALL_DIR"

# Check if envsubst.old exists
if [[ ! -f "/usr/bin/envsubst.old" ]]; then
echo "envsubst.old does not exist. Proceeding with installation..."

ENVSUBST_VERSION="v1.4.3"
URL="https://github.com/a8m/envsubst/releases/download/$ENVSUBST_VERSION/envsubst-$(uname -s)-$(uname -m)"
echo "Downloading: $URL"

curl -sL $URL -o $INSTALL_DIR/envsubst
chmod +x "$INSTALL_DIR/envsubst"

# Replace existing envsubst if present
if [[ -f "/usr/bin/envsubst" ]]; then
sudo mv /usr/bin/envsubst /usr/bin/envsubst.old
sudo ln -s "$INSTALL_DIR/envsubst" /usr/bin/envsubst
echo "Replaced existing envsubst with the new one at /usr/bin/envsubst"
else
touch /usr/bin/envsubst.old
fi
if [[ ! -f "$INSTALL_DIR/envsubst" ]]; then
echo "Installing github.com/a8m/envsubst into bin"
make -C "$SRC_DIR/hack/tools" bin/envsubst
ln -s "$SRC_DIR/hack/tools/bin/envsubst" "$INSTALL_DIR/envsubst"

# Verify installation
if ! command -v envsubst &>/dev/null; then
Expand All @@ -34,8 +19,7 @@ if [[ ! -f "/usr/bin/envsubst.old" ]]; then
fi

# Use build location by default
if [[ ! -e "$INSTALL_DIR/clusterawsadm" ]]; then
echo "Linking [$SRC_DIR/bin/clusterawsadm] [$INSTALL_DIR/clusterawsadm]"
mkdir -p "$INSTALL_DIR"
ln -s "$SRC_DIR/bin/clusterawsadm" $INSTALL_DIR/clusterawsadm
if [[ ! -f "$INSTALL_DIR/clusterawsadm" ]]; then
echo "Installing clusterawsadm into bin"
make -C "$SRC_DIR" clusterawsadm
fi