Skip to content

Commit d20fa27

Browse files
authored
Merge pull request #9 from FuelLabs/sophie/pathFix
Fix fuelup path and permissions
2 parents 32aae67 + 07aea0e commit d20fa27

11 files changed

Lines changed: 54 additions & 31 deletions

File tree

src/fuelup/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Install Fuel Toolchain",
33
"id": "fuelup",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "Install the Fuel toolchain using fuelup",
66
"options": {
77
"toolchain": {

src/fuelup/install.sh

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

44
echo "Installing fuelup with provided toolchain: ${TOOLCHAIN}"
55

66
export DEBIAN_FRONTEND=noninteractive
7-
export PATH=$HOME/.fuelup/bin:$PATH
7+
export FUELUP_HOME=$HOME/.fuelup
8+
export REMOTE_FUELUP_HOME=$_REMOTE_USER_HOME/.fuelup
9+
export PATH=$FUELUP_HOME/bin:$PATH
810

911
if [ "$(id -u)" -ne 0 ]; then
1012
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
1113
exit 1
1214
fi
1315

14-
# Add fuelup the the path for all new login shells.
15-
echo "export PATH=\$PATH:\$HOME/.fuelup/bin" > /etc/profile.d/00-fuelup.sh
16-
chmod +x /etc/profile.d/00-fuelup.sh
16+
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
17+
rm -f /etc/profile.d/00-restore-env.sh
18+
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
19+
chmod +x /etc/profile.d/00-restore-env.sh
20+
21+
# Updates bashrc and zshrc files with the given string if not already present.
22+
updaterc() {
23+
echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..."
24+
if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then
25+
echo -e "$1" >> /etc/bash.bashrc
26+
fi
27+
if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then
28+
echo -e "$1" >> /etc/zsh/zshrc
29+
fi
30+
}
1731

1832
# Updates apt-get if the cache is empty.
1933
apt_get_update()
@@ -33,7 +47,7 @@ check_packages() {
3347
}
3448

3549
# Install required packages to build if missing.
36-
check_packages curl git-all sudo
50+
check_packages curl git-all
3751

3852
# Install fuelup.
3953
curl --proto '=https' --tlsv1.2 -sSf https://install.fuel.network/fuelup-init.sh | sh -s -- --no-modify-path
@@ -45,11 +59,20 @@ if [ "${TOOLCHAIN}" != "latest" ]; then
4559
fuelup default ${TOOLCHAIN}
4660
fi
4761

62+
# Ensure fuelup and forc are installed.
63+
fuelup --version
64+
forc --version
65+
4866
# If the remote user is a different user, copy the fuelup directory to the remote user's home.
4967
if [ "$HOME" != "$_REMOTE_USER_HOME" ]; then
50-
sudo cp -r $HOME/.fuelup $_REMOTE_USER_HOME/.fuelup
68+
mv $FUELUP_HOME $REMOTE_FUELUP_HOME
69+
chmod 775 -R $REMOTE_FUELUP_HOME
70+
chown -R $_REMOTE_USER:$_REMOTE_USER $REMOTE_FUELUP_HOME
5171
fi
5272

53-
# Ensure fuelup and forc are installed.
54-
fuelup --version
55-
forc --version
73+
# Add FUELUP_HOME and bin directory into bashrc/zshrc files.
74+
updaterc "$(cat << EOF
75+
export FUELUP_HOME="${REMOTE_FUELUP_HOME}"
76+
if [[ "\${PATH}" != *"\${FUELUP_HOME}/bin"* ]]; then export PATH="\${FUELUP_HOME}/bin:\${PATH}"; fi
77+
EOF
78+
)"

test/fuelup/beta-1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
7+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
8+
check "execute command" forc --version | grep 'forc [0-9].'
99
check "execute command" fuelup default | grep 'beta-1'
1010

1111
reportResults

test/fuelup/beta-2.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
7+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
8+
check "execute command" forc --version | grep 'forc [0-9].'
99
check "execute command" fuelup default | grep 'beta-2'
1010

1111
reportResults

test/fuelup/beta-3.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
7+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
8+
check "execute command" forc --version | grep 'forc [0-9].'
99
check "execute command" fuelup default | grep 'beta-3'
1010

1111
reportResults

test/fuelup/default.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ set -e
1818
source dev-container-features-test-lib
1919

2020
# Feature-specific tests
21-
check "execute command" fuelup --version | grep 'fuelup'
22-
check "execute command" forc --version | grep 'forc'
21+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
22+
check "execute command" forc --version | grep 'forc [0-9].'
2323
check "execute command" fuelup default | grep 'latest'
2424

2525
# If any of the checks above exited with a non-zero exit code, the test will fail.

test/fuelup/latest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
7+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
8+
check "execute command" forc --version | grep 'forc [0-9].'
99
check "execute command" fuelup default | grep 'latest'
1010

1111
reportResults

test/fuelup/nightly.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
7+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
8+
check "execute command" forc --version | grep 'forc [0-9].'
99
check "execute command" fuelup default | grep 'nightly'
1010

1111
reportResults

test/fuelup/root.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set -e
44
source dev-container-features-test-lib
55

66
# Feature-specific tests
7-
check "execute command" fuelup --version | grep 'fuelup'
8-
check "execute command" forc --version | grep 'forc'
9-
check "execute command" fuelup default | grep 'latest'
107
check "execute command" whoami | grep 'root'
8+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
9+
check "execute command" forc --version | grep 'forc [0-9].'
10+
check "execute command" fuelup default | grep 'latest'
1111

1212
reportResults

test/fuelup/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ source dev-container-features-test-lib
2626

2727
# Feature-specific tests
2828
# The 'check' command comes from the dev-container-features-test-lib.
29-
check "execute command" fuelup --version | grep 'fuelup'
30-
check "execute command" forc --version | grep 'forc'
29+
check "execute command" fuelup --version | grep 'fuelup [0-9].'
30+
check "execute command" forc --version | grep 'forc [0-9].'
3131
check "execute command" fuelup default | grep 'latest'
3232

3333
# Report result

0 commit comments

Comments
 (0)