These instructions detail setting up an Oracle VirtualBox Virtual Machine for development and maintenance of AMS guidelines.
VirtualBox can be downloaded for free from Oracle.
For the best experience, you will also need to download an Ubuntu ISO (also free and open source) from Ubuntu. Choose the 32-bit desktop version of the 14.04.1 LTS release and download it to your system.
Run the VirtualBox installer and install it to the default location.
After the install has completed, download the VM extension pack. Run the extension pack installer by double-clicking on in.
- Run VirtualBox and choose
New
machine. - Name: Ubuntu 14.04.1
- Type: Linux (if not already selected)
- Version: Ubuntu (32 bit)
Next
- Memory Size: Half of the available RAM if your system has at least 8GB (ie. 4096 MB)
- Hard drive: Create virtual hard drive now
Create
- Hard drive file type: VMDK
Next
- Storage on physical hard drive: Fixed size (for speed)
- Name: Ubuntu 14.04.1
- Size: 10GB
Create
Settings
- General > Advanced
- Shared Clipboard: Bidirectional
- Display > Video
- Video Memory: 128 MB
- Enable 3D Acceleration
- Network > Adapter 1
- Attached to: Bridged Adapter
OK
- General > Advanced
- Settings > Storage
- Select the CD Controller (probably IDE) and select the
Empty
option - Find and click the 'Choose a virtual CD' icon
- Browse to the downloaded ISO
OK
- Select the CD Controller (probably IDE) and select the
Start
Install Ubuntu
Continue
Erase disk and install Ubuntu
Install Now
- Choose your location
- Choose your keyboard layout
- Name: vagrant
- Computer's Name: ams-vm
- Password: vagrant
Require password to log in
Continue
- After install completes,
Restart Now
- The OS will restart, then pause, giving you a chance to 'remove' the CD
Enter
(the CD is programatically ejected)
-
Log in to the OS (yes the display size sucks. We'll fix that in a moment)
-
<Ctrl-Alt-T>
to open a terminal. While it's open find its icon on the task bar, right click and choose 'Lock to Launcher' -
Install dkms
sudo apt-get install -y dkms #DO NOT RUN...NOT NEEDED...sudo /etc/init.d/vboxadd setup sudo apt-get install -y build-essential linux-headers-$(uname -r)
-
On the VirtualBox menu,
Devices > Insert Guest Additions CD image...
-
Run the installer
-
Press
Return
when terminal tells you to do so -
Restart the OS, in the terminal:
sudo shutdown -r now
-
After reboot, you should have a much better display resolution
-
In a terminal:
sudo apt-get update -y # Update existing packages sudo apt-get upgrade -y # Restart the OS sudo shutdown -r now
-
Add the vagrant user to the sudoers file:
sudo su - visudo # Add the following line to the end of the file vagrant ALL=(ALL) NOPASSWD:ALL
Exit the editor with <Ctrl-x>
, choose y
to save, and <Enter>
to accept the current filename.
-
Exit the super user terminal
exit
mkdir -p ~/.ssh
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O ~/.ssh/authorized_keys
# Ensure we have the correct permisssions
chmod 0700 ~/.ssh
chmod 0600 ~/.ssh/authorized_keys
chown -R vagrant ~/.ssh
sudo apt-get install -y openssh-server
Edit the config with vim:
sudo vi /etc/ssh/sshd_config
Alternately, to edit the config with nano:
sudo nano /etc/ssh/sshd_config
Ensure the following are set:
Port 22
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PermitEmptyPasswords no
AuthorizedKeysFile
probably already exists, it's just commented out.
Remove the #
from the beginning of the line to uncomment it.
:wq
(if using vi) to save and exit the editor, <Ctrl-x>
(if using nano)
Restart the daemon to pull in the config changes
sudo service ssh restart
sudo apt-get install -y git
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
During the install (below), accept the Oracle terms to continue the install...
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y oracle-java8-set-default
See if it installed correctly:
java -version
Expecting something like:
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) Client VM (build 25.74-b02, mixed mode)
sudo apt-get install -y oracle-java7-installer
sudo apt-get install -y oracle-java7-set-default
See if it installed correctly:
java -version
Expecting something like:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Install prerequisites
sudo apt-get install -y curl zlib1g-dev libssl-dev libreadline-dev \
libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev \
libcurl4-openssl-dev python-software-properties
Install 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
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
List available rubies:
rbenv install -l
Install the latest stable version (2.3.0 at this time)
export RUBY_CONFIGURE_OPTS="--enable-shared"
This will download the ruby source code and build ruby locally... it will take a while...
rbenv install 2.3.0
Set the newly built ruby as the system default
rbenv global 2.3.0
ruby -v
Expected output:
ruby 2.3.0p0 (2015-12-25 revision 53290) [i686-linux]
Tell rubygems not to install local docs
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
Install bundler
gem install bundler
#sudo apt-get install -y chromium-browser pepperflashplugin-nonfree unity-chromium-extension
sudo apt-get install -y chromium-browser pepperflashplugin-nonfree
sudo apt-get install -y chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin/chromedriver
Test that chromedriver doesn't error out:
chromedriver --help
Expected output:
Usage: chromedriver [OPTIONS]
...
If you receive an error, similar to Details:
echo '/usr/lib/chromium-browser/libs' >> /tmp/chrome_lib.conf
sudo mv /tmp/chrome_lib.conf /etc/ld.so.conf.d/
sudo ldconfig
and try help
again
chromedriver --help
sudo apt-get install -y tidy
See Vim Wiki for details
on setting up your .vimrc
to use Tidy.
Go to System Settings > Security and Privacy > Search (tab) and set
Include Online Results
to Off
Remove from launcher (right click icon and choose Unlock from Launcher
):
- Firefox
- Libre Office Impress
- Software Center
- Amazon App
- System Settings
Unmount VBoxAdditions CD (from the launcher, right click and choose Eject
)
sudo add-apt-repository ppa:freyja-dev/unity-tweak-tool-daily
sudo apt-get update && sudo apt-get install -y unity-tweak-tool
sudo apt-get install -y compizconfig-settings-manager
sudo add-apt-repository ppa:alexx2000/doublecmd
sudo apt-get update
sudo apt-get install -y doublecmd-gtk
Start Double Commander from the command line
/usr/bin/doublecmd
Pin it to the launcher by right-clicking the launcher icon and selecting Lock to Launcher
(Ubuntu w/Unity only).
Quit Double Commander using the X
in the upper left corner of its window.
sudo apt-get install -y fonts-inconsolata
sudo apt-get remove -y vim-tiny vim-common
cd ~
git clone https://github.com/vim/vim.git
sudo apt-get install -y libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
checkinstall
cd vim
Now configure the build script and build and install vim:
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=dynamic \
--enable-pythoninterp=dynamic \
--enable-perlinterp \
--enable-luainterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim74
Create the install package
sudo checkinstall
Enter a short description:
Vim 7.4 build from source<Enter>
<Enter>
<Enter>
again
For the question Do you want me to list them?
choose n
For the question Should I exclude them from the package?
choose n
Creating the .deb
package can take quite a while (~30 minutes)...
After the install has completed, we need to test to see if vim can find the ruby dynamic library.
Make sure we have the correct vim
which vim
should return something like
/usr/bin/vim
Start vim
vim
Type :ruby 1
and hit <Enter>
If you see an error (something about not finding libruby.so.2.3.0), you'll need to create the link below.
First, find the library. It will be based on the ruby version installed. So,
because we installed 2.3.0, it should be located at /home/vagrant/.rbenv/versions/2.3.0/lib/libruby.so.2.3.0
.
Find your version and create the link as follows (changing the path to match
your specific path):
sudo ln -s ~/.rbenv/versions/2.3.0/lib/libruby.so.2.3.0 /usr/lib/libruby.so.2.3.0
Now, in vim, type :ruby 1
and <Enter>
. If no error is displayed, we're looking good!
Try :ruby puts 'hello'
and <Enter>
. hello
should be printed to the command bar.
Quit vim with :q<Enter>
If successfully built and installed, clean up with
cd ..
sudo rm -rf /home/vagrant/vim/
Vim can be uninstalled with:
sudo dpkg -r vim
Set Vim as the default editor
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
sudo update-alternatives --set editor /usr/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
sudo update-alternatives --set vi /usr/bin/vim
Prevent apt
from updating your custom built version of vim:
sudo apt-mark hold vim
To remove the 'hold' run the following:
sudo apt-mark unhold vim
cd ~
git clone https://[email protected]/ktechsystems/vimfiles.git
Copy and rename the _vimrc.example
file to your home directory
cp vimfiles/_vimrc.example ~/.vimrc
Install plugins
cd ~/vimfiles
./install-plugs.sh
Plugins will be git clone
d into the bundle
directory and vim will be started
to generate help tags.
Close vim with :q
To update the plugins, run
cd ~/vimfiles
./update-plugs.sh
Install exuberant ctags for use with vim-taglist using
sudo apt-get install -y exuberant-ctags
Update ~/.bashrc
to your needs.
Add ~/.bash_aliases
with git aliases
Here are some handy aliases I use:
# Git aliases
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias ga='git add'
alias gamend='git commit --amend'
alias gcom='git commit'
alias gca='git commit -a'
alias gcm='git commit -m'
alias gcam='git commit -am'
alias gl='git log'
alias grevert='git checkout --'
alias gbtree="git log --graph --simplify-by-decoration --pretty=format:'%d' --all"
alias gbbtree="git log --graph --pretty=format:'%C(yellow)%h%Creset%C(blue)%d%Creset %C(white bold)%s%Creset %C(white dim)(by %an %ar)%Creset' --all"
alias glg="git log --graph --oneline --decorate"
# Grep within the current git repo files
alias gg="git grep"
# Case insensitive git grep
alias ggi="git grep -i"
# Git checkout. Usage: gc branch-name
alias gc="git checkout"
# Git branch create (checkout branch). Usage: gbc branch-name
alias gbc="git checkout -b"
# Git branch merge. Usage: gbm branch-name
alias gbm="git merge"
# Git branch delete. Usage: gbd branch-name
alias gbd="git branch -d"
# Git branch stash. Usage: gbs branch-name
alias gbs="git add .; git stash; git stash branch"
# Really clear the screen (scrollback buffer too!)
alias cls='echo -en "\ec"'
# Simple logging
# Work logs
function log_write() {
echo "$(date +%H:%M:%S) $*" >> ~/work_logs/$(date +%Y-%m-%d)
}
function log_edit() {
vim ~/work_logs/$(date +%Y-%m-%d)
}
function log_peek() {
tail ~/work_logs/$(date +%Y-%m-%d)
}
alias log_arrived=' log_write arrived'
alias log_left=' log_write left'
alias lw='log_write'
alias lp='log_peek'
alias le='log_edit'
Create ~/bin
dir and ~/bin/.git-prompt.sh
script and ~/.bash_gitprompt
.
mkdir ~/bin
curl https://gist.githubusercontent.com/jmcaffee/9abc964c6fcb50dd06a8/raw/69b34624d1b6a367788a5389616caad0a38f134b/.git-prompt.sh -o ~/bin/.git-prompt.sh
curl https://gist.githubusercontent.com/jmcaffee/7e01a4ab7837bdf66df1/raw/e98dc9a8ec836bce81222e94eac5f8e9a205e3c1/.bash_gitprompt -o ~/.bash_gitprompt
Make the script executable
chmod +x ~/bin/.git-prompt.sh
Modify .bashrc
:
echo "" >> ~/.bashrc
echo "# Modify the prompt to display git branch" >> ~/.bashrc
echo "if [ -f ~/.bash_gitprompt ]; then" >> ~/.bashrc
echo " . ~/.bash_gitprompt" >> ~/.bashrc
echo "fi" >> ~/.bashrc
echo "" >> ~/.bashrc
echo "# Add local .bin and bin dirs to path" >> ~/.bashrc
echo "export PATH="./.bin:./bin:$PATH" >> ~/.bashrc
. .bashrc
Because I've included .bin
in my path, and we're using network shared
directories for our projects (which are shared from a windows host), we'll
see warning: Insecure world writable dir
warnings whenever we execute a
ruby script from our project dir.
To prevent this (ie. hide the warning), create a wrapper script for the ruby binary.
cd $(dirname $(rbenv which ruby))
mv ruby ruby.orig
echo "#!/bin/bash" > ruby
echo "(ruby.orig \"\$@\" 3>&1 1>&2 2>&3 | grep -v 'Insecure world writable dir'; exit ${PIPESTATUS[0]}) 3>&1 1>&2 2>&3" >> ruby
chmod +x ruby
cd -
NOTE: the important line (without the escaping) looks like:
(ruby.orig "$@" 3>&1 1>&2 2>&3 | grep -v 'Insecure world writable dir'; exit ${PIPESTATUS[0]}) 3>&1 1>&2 2>&3
See StackOverflow for more information.
sudo apt-get install -y meld
sudo apt-get install -y p7zip-full p7zip-rar
sudo apt-get install -y silversearcher-ag
sudo apt-get remove --purge thunderbird* -y
sudo apt-get autoremove
sudo apt-get clean
# This will error out... and that's ok.
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
cat /dev/null > ~/.bash_history && history -c
# Shutdown the machine
sudo shutdown -h now
Install vagrant
Note: To see vagrant debugging info, in the windows cmd prompt, type SET VAGRANT_LOG=debug
vagrant package --base <VB VM NAME> --output amsbase.box
is the name of the VBox VM seen when running
vboxmanage list vms
in this case, it's "Ubuntu 14.04.2":
vagrant package --base "Ubuntu 14.04.2" --output amsbase.box
this will create a file called amsbase.box
.
vagrant box add {boxname} amsbase.box
In this case:
vagrant box add amsbase amsbase.box
Go to a different folder and type:
vagrant init amsbase
Edit the generated Vagrantfile
and uncomment the following line:
config.vm.provider "virtualbox" do |v|
v.gui = true
end
Add/set/uncomment the following line in Vagrantfile
:
config.vm.network = :public_network
This prevents issues with no network access within the VM when changing networks (ie. taking your laptop to the office).
vagrant up