Trying to write a shell script to configure my server environment on Ubuntu through Vagrant, and I ran into a problem when the script ends unexpectedly. I added the shell script path in the Vagrant provisioning configuration.
Vagrant:
# Specify our provision script config.vm.provision "shell", path: "scripts/bootstrap.sh"
My script:
#!/bin/bash # Install dependencies for Ruby sudo apt-get update sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common # Setting up rbenv echo 'Setting up rbenv' git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL
After starting, I expect the repository to be cloned into the .rbenv folder and rbenv will be added to $ PATH in ~ / .bashrc along with the init rbenv function evaluated and placed in ~ / .bashrc. However, when the script is executed at the Vagrant submission stage, I end up with the script just cloning the git repository, and then exiting without executing anything else in my script.
Output:
==> default: Processing triggers for libc-bin (2.19-0ubuntu6) ... ==> default: Setting up rbenv ==> default: Cloning into '.rbenv'...
And then the script exits and ~ / .bashrc remains unchanged. I was wondering how I can change my shell script so that it performs the required action (which adds rbenv to ~ / .bashrc). Any ideas?
source share