web-dev-qa-db-ja.com

シェルスクリプト内でシェルを更新できますか?

最小限のCentOS6インストールで開始し、Ruby開発用にプロビジョニングするスクリプトをセットアップしようとしています。

#!/bin/bash

# Add PostgreSQL Repo
rpm -i http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm

# Add NginX Repo
echo '[nginx]' > /etc/yum.repos.d/nginx.repo
echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo
echo 'baseurl=http://nginx.org/packages/centos/6/$basearch/' >> /etc/yum.repos.d/nginx.repo
echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo
echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo

# Update
yum update -y

# Install NginX, PostgreSQL, and Ruby Dependencies
yum install -y nginx postgresql91-server postgresql91-contrib gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison piconv-devel sqlite-devel git-core

# PostgreSQL Post Install
service postgresql-9.1 initdb
chkconfig postgresql-9.1 on

# Install rbenv system wide install
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv

# Install Ruby-build
git clone git://github.com/sstephenson/Ruby-build.git /usr/local/rbenv/plugins/Ruby-build

# Add rbenv to the path
echo '# rbenv setup - only add RBENV PATH variables if no single user install found' > /etc/profile.d/rbenv.sh
echo 'if [[ ! -d "${HOME}/.rbenv" ]]; then' >> /etc/profile.d/rbenv.sh
echo '  export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
echo '  export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo '  eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
echo 'fi'  >> /etc/profile.d/rbenv.sh
chmod +x /etc/profile.d/rbenv.sh

# Shell NEEDS TO BE REFRESHED HERE

# Install latest Ruby
rbenv install 1.9.3-p286

# Set Global Ruby
rbenv global 1.9.3-p286

シェルがコマンドを認識するためにシェルを更新/再起動する必要があるため、rbenvを使用するポイントに到達すると、rbenv:command notfoundエラーが発生します。どうすればこれを達成できますか?ありがとう。

5
CT.

新しい環境ファイルを入手してみてください。上を見ると、私は推測します、

# Shell NEEDS TO BE REFRESHED HERE
source /etc/profile.d/rbenv.sh

および/または

source ${HOME}/.rbenv

さらに、現在のシェルに含める必要のある、作成されたその他のファイル。

6
EightBitTony