Skip to content

Commit 635e993

Browse files
committed
Fix envsubstr installation in Devbox
For users using devbox directly on their machines, envsubstr is now installed in the isolated devbox environment. Thus not conflicting with the GNU system installation. Fix the below clusterawsadm installation error when re-entering the devbox environment "ln: failed to create symbolic link '$INSTALL_DIR/clusterawsadm': File exists"
1 parent c470da2 commit 635e993

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

scripts/devbox-init-hook.sh

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,16 @@
22
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
33
SRC_DIR="$(dirname $DIR)"
44

5-
# Set install path
6-
INSTALL_DIR="$HOME/.local/bin"
7-
mkdir -p "$INSTALL_DIR"
8-
9-
# Check if envsubst.old exists
10-
if [[ ! -f "/usr/bin/envsubst.old" ]]; then
11-
echo "envsubst.old does not exist. Proceeding with installation..."
5+
# Set install path to devbox packages directory
6+
INSTALL_DIR="$DEVBOX_PACKAGES_DIR/bin"
127

8+
if [[ ! -f "$INSTALL_DIR/envsubst" ]]; then
139
ENVSUBST_VERSION="v1.4.3"
1410
URL="https://github.com/a8m/envsubst/releases/download/$ENVSUBST_VERSION/envsubst-$(uname -s)-$(uname -m)"
1511
echo "Downloading: $URL"
16-
17-
curl -sL $URL -o $INSTALL_DIR/envsubst
18-
chmod +x "$INSTALL_DIR/envsubst"
19-
20-
# Replace existing envsubst if present
21-
if [[ -f "/usr/bin/envsubst" ]]; then
22-
sudo mv /usr/bin/envsubst /usr/bin/envsubst.old
23-
sudo ln -s "$INSTALL_DIR/envsubst" /usr/bin/envsubst
24-
echo "Replaced existing envsubst with the new one at /usr/bin/envsubst"
25-
else
26-
touch /usr/bin/envsubst.old
27-
fi
12+
echo "Installing github.com/a8m/envsubst into Devbox shell"
13+
sudo curl -sL $URL -o $INSTALL_DIR/envsubst
14+
sudo chmod +x "$INSTALL_DIR/envsubst"
2815

2916
# Verify installation
3017
if ! command -v envsubst &>/dev/null; then
@@ -34,8 +21,7 @@ if [[ ! -f "/usr/bin/envsubst.old" ]]; then
3421
fi
3522

3623
# Use build location by default
37-
if [[ ! -e "$INSTALL_DIR/clusterawsadm" ]]; then
24+
if [[ ! -L "$INSTALL_DIR/clusterawsadm" ]]; then
3825
echo "Linking [$SRC_DIR/bin/clusterawsadm] [$INSTALL_DIR/clusterawsadm]"
39-
mkdir -p "$INSTALL_DIR"
40-
ln -s "$SRC_DIR/bin/clusterawsadm" $INSTALL_DIR/clusterawsadm
26+
sudo ln -s "$SRC_DIR/bin/clusterawsadm" $INSTALL_DIR/clusterawsadm
4127
fi

0 commit comments

Comments
 (0)