My Ubuntu Java Environment Setup Script

I know this has been done. And I know mine isn’t so great (I left out ALL error checking), but this is my quick set up script for when I install Ubuntu on a laptop or VM. I put it on a flash drive just in case because just in case happened to me 3 times in the past month or so. Note: a couple lines wrapped so I used \ to mark them.

#!/bin/sh
CURDIR=`pwd`
# export BACKUP=/media/MYFLASHDRIVE/backup
export BACKUP=/media/LIFESTUDIO/MediaBackup/Downloads
export ME=dave
export GRP=dave

delete() {
	if [ -f $1 ]
	then
		sudo rm -f $1
	else
		echo "does not exist"
	fi
}

install() {
	if [ ! -x /usr/bin/$1 ]
	then
		sudo apt-get install -y $1
	fi
}

install curl
install git
install zsh
if [ ! -x ~/.oh-my-zsh ]
then
	curl -L \ https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
fi
install autojump
install ack-grep
cd ~/.oh-my-zsh
tar -xvzpf $DOWN/custom.tar.gz
sudo chmod +rwx $ME:$GRP ~/.oh-my-zsh/custom
cp $DOWN/config.zshrc ~/.zshrc

#Java
if [ ! -x /usr/share/jdk1.7.0_40 ]
then
	tar -xvzpf $BACKUP/jdk-7u40-linux-x64.tar.gz
	sudo mv jdk1.7.0_40 /usr/share
	cd /usr/bin
	delete java
	sudo ln -s /usr/share/jdk1.7.0_40/bin/java
fi

#Maven
if [ ! -x /usr/bin/mvn ]
then
	sudo apt-get install maven
fi

#Intellij Idea
if [ ! -x /usr/share/idea-IC-129.713 ]
then
	tar -xvzpf $BACKUP/ideaIC-12.1.4.tar.gz
	sudo mv idea-IC-129.713 /usr/share
	cd /usr/bin
	delete idea
	sudo ln -s /usr/share/idea-IC-129.713/bin/idea.sh idea
fi

#JMeter
install jmeter

#RUBY
if [ ! -x /home/dave/.rvm/rubies/ruby-2.0.0-p247/bin/ruby ]
then
	install curl
	curl -L https://get.rvm.io | bash -s stable --ruby
	/bin/bash --login
	rvm install ruby-2.0.0-p247
	sudo chown -R dave:dave .gem
	gem install map_by_method
	gem install what_methods
	gem install bundler
fi

#Sublime Text 2
if [ ! -x /usr/bin/sublime ]
then
	cd ~
	tar xf $BACKUP/Sublime_Text_2.0.2_x64.tar.bz2
	sudo mv 'Sublime Text 2' /usr/share/Sublime_Text_2
	cd /usr/bin
	sudo ln -s /usr/share/Sublime_Text_2/sublime_text
	sudo ln -s /usr/share/Sublime_Text_2/sublime_text sublime
	sudo cp $BACKUP/sublime.desktop /usr/share/applications
	cat /usr/share/applications/defaults.list | \
		sed s/gedit.desktop/sub\lime.desktop/g > ~/defaults.list
	sudo cp ~/defaults.list /usr/share/applications/
fi

#Skype and recorder
if [ ! -x /usr/bin/skype ]
then
	sudo dpkg -i $BACKUP/skype-ubuntu-precise_4.2.0.11-1_i386.deb
fi
if [ ! -x /usr/bin/skype-call-recorder ]
then
	sudo dpkg -i $BACKUP/skype-call-recorder-ubuntu_0.10_amd64.deb
	sudo apt-get -f install
fi

#Favorite Browser
if [ ! -x /opt/google/chrome ]
then
	install libxss1
	sudo dpkg -i $BACKUP/google-chrome-stable_current_amd64.deb
fi

#other personalizations
if [ ! -x /usr/bin/dconf-editor ]
then
	sudo apt-get install -y dconf-tools
fi
install nautilus-open-terminal
install ushare
install gimp

cd $CURDIR
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s