aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2022-06-10 21:37:11 +0300
committerGitHub <noreply@github.com>2022-06-10 21:37:11 +0300
commita71a223511b29a41cfefea61e577e7255d46e207 (patch)
tree15931c889d64c58334ea6555aa2a564978b0305f
parenta81ff33fda426c57267aa9e027dd8420fe812349 (diff)
ruby: fix permissions and ln for oryx (#43)
* ruby: fix permissions and ln for oryx * add sudo_if
-rw-r--r--src/ruby/install.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ruby/install.sh b/src/ruby/install.sh
index f4c7b10..5152893 100644
--- a/src/ruby/install.sh
+++ b/src/ruby/install.sh
@@ -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
@@ -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