Skip to content
Merged
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
14 changes: 13 additions & 1 deletion src/ruby/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ check_packages() {
fi
}

sudo_if() {
COMMAND="$*"
if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then
su - "$USERNAME" -c "$COMMAND"
else
"$COMMAND"
fi
}

# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -271,11 +279,15 @@ if [ "${SKIP_RBENV_RBUILD}" != "true" ]; then

if [ "${USERNAME}" != "root" ]; then
mkdir -p /home/${USERNAME}/.rbenv/plugins
chown -R ${USERNAME} /home/${USERNAME}/.rbenv
sudo_if chown -R ${USERNAME} /home/${USERNAME}/.rbenv
sudo_if chown -R ${USERNAME} /usr/local/rvm/

if [[ ! -d "/home/${USERNAME}/.rbenv/plugins/ruby-build" ]]; then
ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build
fi

ln -s /usr/local/rvm/rubies/default/bin/ruby /usr/local/rvm/gems/default/bin

fi
fi

Expand Down