diff options
author | Samruddhi Khandale <skhandale@microsoft.com> | 2022-06-10 21:37:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 21:37:11 +0300 |
commit | a71a223511b29a41cfefea61e577e7255d46e207 (patch) | |
tree | 15931c889d64c58334ea6555aa2a564978b0305f /src/ruby | |
parent | a81ff33fda426c57267aa9e027dd8420fe812349 (diff) |
ruby: fix permissions and ln for oryx (#43)
* ruby: fix permissions and ln for oryx
* add sudo_if
Diffstat (limited to 'src/ruby')
-rw-r--r-- | src/ruby/install.sh | 14 |
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 |