Last active
December 10, 2015 23:58
-
-
Save alghanmi/4512832 to your computer and use it in GitHub Desktop.
VM Configuration for CS course developed for Ubuntu 12.04 LTS (the latest LTS). This was last tested with 12.04.3 64-bit image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Force to run as root | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
SCRIPT_USERNAME=$SUDO_USER | |
DESKTOP_SETUP=0 | |
DESKTOP_PACKAGES="" | |
## Check if this is a Desktop setup or not | |
is_desktop() { | |
ready=0 | |
while [ $ready == 0 ]; do | |
read -p "Do you wish to perform a desktop setup (y/n)? " answer | |
if [ "$answer" == 'Y' -o "$answer" == 'y' ]; then | |
ready=1 | |
DESKTOP_SETUP=1 | |
fi | |
if [ "$answer" == 'N' -o "$answer" == 'n' ]; then | |
ready=1 | |
DESKTOP_SETUP=0 | |
fi | |
done | |
} | |
# Ask user about desktop environment | |
is_desktop | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
echo "Adding desktop environment setup" | |
DESKTOP_PACKAGES="filezilla firefox google-chrome-stable" | |
fi | |
## | |
## Repository Setup | |
## | |
cp /etc/apt/sources.list /etc/apt/sources.list.default | |
# Enable main, restricted, universe and multiverse repositories | |
echo "deb http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" | tee /etc/apt/sources.list | |
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "" | tee -a /etc/apt/sources.list | |
echo "deb http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "" | tee -a /etc/apt/sources.list | |
echo "deb http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "" | tee -a /etc/apt/sources.list | |
echo "deb http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "deb-src http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted universe multiverse" | tee -a /etc/apt/sources.list | |
echo "" | tee -a /etc/apt/sources.list | |
echo "deb http://archive.canonical.com/ubuntu $(lsb_release -cs) partner" | tee -a /etc/apt/sources.list | |
echo "deb-src http://archive.canonical.com/ubuntu $(lsb_release -cs) partner" | tee -a /etc/apt/sources.list | |
echo "" | tee -a /etc/apt/sources.list | |
echo "deb http://extras.ubuntu.com/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list | |
echo "deb-src http://extras.ubuntu.com/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list | |
# PPAs for Git | |
echo "# Git PPA" | tee /etc/apt/sources.list.d/git.list | |
echo "deb http://ppa.launchpad.net/git-core/ppa/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/git.list | |
echo "deb-src http://ppa.launchpad.net/git-core/ppa/ubuntu $(lsb_release -cs) main " | tee -a /etc/apt/sources.list.d/git.list | |
echo "# Toolchain PPA" | tee /etc/apt/sources.list.d/toolchain.list | |
echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/toolchain.list | |
echo "deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $(lsb_release -cs) main " | tee -a /etc/apt/sources.list.d/toolchain.list | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
echo "# Google software repository" | tee /etc/apt/sources.list.d/google.list | |
echo "deb http://dl.google.com/linux/deb/ stable main" | tee -a /etc/apt/sources.list.d/google.list | |
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | tee -a /etc/apt/sources.list.d/google.list | |
echo "deb http://dl.google.com/linux/talkplugin/deb/ stable main" | tee -a /etc/apt/sources.list.d/google.list | |
fi | |
# Keys for sources not available in the default keyring | |
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3E5C1192 # Ubuntu Extras | |
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E1DF1F24 # Git | |
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com BA9EF27F # ToolChain | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
wget -q https://dl-ssl.google.com/linux/linux_signing_key.pub -O- | apt-key add - | |
fi | |
## Update Packages | |
apt-get install -y aptitude | |
aptitude update | |
aptitude upgrade | |
## | |
## Packages | |
## | |
aptitude install ssh openssh-server openssl build-essential binutils byobu \ | |
gcc-4.8 g++-4.8 \ | |
sudo ntp curl \ | |
gdb ddd valgrind cscope qemu colorgcc openjdk-7-jdk icedtea-7-plugin \ | |
bison flex \ | |
texinfo libncurses5-dev \ | |
libqt4-core libqt4-gui qt4-qmake qt4-qtconfig qt4-doc-html \ | |
qt4-dev-tools libqt4-dev libqt4-core libqt4-gui qtmobility-dev \ | |
doxygen \ | |
python-networkx python-matplotlib python-numpy graphviz \ | |
vim-gtk vim-scripts emacs23 emacs-goodies-el gedit gedit-plugins gedit-developer-plugins \ | |
nano enscript highlight astyle wdiff colordiff diffstat meld \ | |
subversion subversion-tools git mercurial \ | |
unzip zip gqview \ | |
$DESKTOP_PACKAGES | |
## | |
## System Configuration | |
## | |
usermod -a -G sudo $SCRIPT_USERNAME | |
usermod -a -G adm $SCRIPT_USERNAME | |
usermod -a -G www-data $SCRIPT_USERNAME | |
usermod -a -G vboxusers $SCRIPT_USERNAME | |
# GRUB Timeout | |
sed -i "s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=4/" /etc/default/grub | |
update-grub | |
# Local information | |
dpkg-reconfigure tzdata | |
locale-gen en_US.UTF-8 | |
update-locale LANG=en_US.UTF-8 | |
dpkg-reconfigure locales | |
select-default-wordlist | |
# Font Cache | |
fc-cache -fv | |
# Updaing alternatives to set defaults for editor, java and browser | |
update-alternatives --config editor | |
update-java-alternatives -s $(update-java-alternatives -l | tail -1 | awk '{ print $1 }') | |
JAVA_HOME_LOC=$(readlink -f /usr/bin/java | sed "s:bin/java::") | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
update-alternatives --config x-www-browser | |
fi | |
# Make gcc 4.8 the latest | |
update-alternatives --remove-all gcc | |
update-alternatives --remove-all g++ | |
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20 | |
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20 | |
update-alternatives --config gcc | |
update-alternatives --config g++ | |
# Install the latest GDB | |
sudo aptitude remove --purge gdb | |
wget http://ftp.gnu.org/gnu/gdb/gdb-7.6.2.tar.gz | |
tar zxvf gdb-*.tar.gz | |
cd gdb-* | |
./configure --prefix=/usr | |
make | |
make install | |
cd .. | |
rm -rf gdb-* | |
# Bash configuration | |
sed -i 's/^HISTCONTROL=.*/HISTCONTROL=ignoredups/' $HOME/.bashrc | |
sed -i 's/^HISTSIZE=.*/HISTSIZE=10000/' $HOME/.bashrc | |
sed -i '/^HISTFILESIZE=.*/ a\ | |
PROMPT_COMMAND="history -a;"' $HOME/.bashrc | |
sed -i 's/^#force_color_prompt=.*/force_color_prompt=yes/' $HOME/.bashrc | |
sed -i '/if \[ \"$color_prompt\" \= yes \]\; then/{N;s/\n.*//;}' $HOME/.bashrc | |
sed -i '/if \[ \"$color_prompt\" \= yes \]\; then/ a\ | |
PS1=\'\'\${debian_chroot:+\(\$debian_chroot\)}\\\\[\\\\033[01\;32m\\\\]\\\\u@\\\\h\\\\[\\\\033[00m\\\\]:\\\\[\\\\033[01\;34m\\\\]\\\\w\ \\\\[\\\\033[31m\\\\]\$\(__git_ps1\ \"\(%s\)\"\)\\\\[\\\\033[00m\\\\]\\\\[\\\\033[00m\\\\]\\\\$\ \''' $HOME/.bashrc | |
echo -e "\n\n#\n# User Modifications\n#" | tee -a $HOME/.bashrc | |
echo "# Java Setup" | tee -a $HOME/.bashrc | |
echo "export JAVA_HOME=$JAVA_HOME_LOC" | tee -a $HOME/.bashrc | |
echo "export CLASSPATH=." | tee -a $HOME/.bashrc | |
echo "" | tee -a $HOME/.bashrc | |
echo "# Package update" | tee -a $HOME/.bashrc | |
echo "alias update='sudo aptitude update; sudo aptitude upgrade'" | tee -a $HOME/.bashrc | |
echo "" | tee -a $HOME/.bashrc | |
echo "# Recusive checksums" | tee -a $HOME/.bashrc | |
echo "alias md5all='find \$@ ! -type d -exec md5sum {} \;'" | tee -a $HOME/.bashrc | |
echo "alias shaall='find \$@ ! -type d -exec sha1sum {} \;'" | tee -a $HOME/.bashrc | |
#Add nano syntax highlighting | |
find /usr/share/nano/ -name "*.nanorc" -print | sed -e 's/^\(.*\)$/include "\1"/g' >> $HOME/.nanorc | |
chown $SCRIPT_USERNAME:$SCRIPT_USERNAME $HOME/.nanorc | |
# Git basics | |
su - $SCRIPT_USERNAME -c "git config --global core.editor emacs" | |
su - $SCRIPT_USERNAME -c "git config --global color.diff auto" | |
su - $SCRIPT_USERNAME -c "git config --global color.status auto" | |
su - $SCRIPT_USERNAME -c "git config --global color.branch auto" | |
su - $SCRIPT_USERNAME -c "git config --global color.interactive auto" | |
su - $SCRIPT_USERNAME -c "git config --global color.ui auto" | |
su - $SCRIPT_USERNAME -c "git config --global core.autocrlf input" | |
su - $SCRIPT_USERNAME -c "git config --global push.default simple" | |
su - $SCRIPT_USERNAME -c "git config --global merge.tool vimdiff" | |
# Desktop Customization: | |
# - Disable guest login | |
# - Use Ubuntu 2D by default | |
# - Setup Unity Launcher apps | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.default | |
sed -i 's/^user-session=.*/user-session=ubuntu-2d/' /etc/lightdm/lightdm.conf | |
echo "allow-guest=false" | tee -a /etc/lightdm/lightdm.conf | |
fi | |
# Clean-up | |
aptitude clean | |
aptitude autoclean | |
rm -f /etc/apt/sources.list.d/google-chrome.list | |
if [ "$DESKTOP_SETUP" -eq 1 ]; then | |
su - $SCRIPT_USERNAME -c "gsettings set com.canonical.Unity.Launcher favorites \"['gnome-terminal.desktop', 'nautilus-home.desktop', 'gedit.desktop', 'gvim.desktop', 'emacs23.desktop', 'google-chrome.desktop', 'firefox.desktop', 'filezilla.desktop']\"" | |
rmdir ~/Documents/ ~/Downloads/ ~/Music/ ~/Pictures/ ~/Public/ ~/Templates/ ~/Videos/ | |
rm ~/examples.desktop | |
fi |
Eclipse Installation Guidelines:
- Head to the Eclipse Download page.
- Download the appropriate version of Eclipse
- Run the following script to install and setup Eclipse
#Extract files
sudo tar zxvf eclipse-*.tar.gz -C /opt/
#Change ownership to root
sudo chown -R root:root /opt/eclipse/
#Add a symlink for the executable to /usr/bin
sudo ln -s /opt/eclipse/eclipse /usr/bin/
#Create menu entry
echo "[Desktop Entry]" | sudo tee /usr/share/applications/eclipse.desktop
echo "Name=Eclipse IDE" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Comment=Integrated Development Environment" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "TryExec=/opt/eclipse/eclipse" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Exec=/opt/eclipse/eclipse" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Icon=/opt/eclipse/icon.xpm" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Categories=Development;IDE;Java;C;C++" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Terminal=false" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "Type=Application" | sudo tee -a /usr/share/applications/eclipse.desktop
echo "StartupNotify=true" | sudo tee -a /usr/share/applications/eclipse.desktop
Finally, if you wish to alter the launcher to include eclipse:
gsettings set com.canonical.Unity.Launcher favorites "['gnome-terminal.desktop', 'nautilus-home.desktop', 'eclipse.desktop', 'gedit.desktop', 'gvim.desktop', 'emacs23.desktop', 'google-chrome.desktop', 'firefox.desktop', 'filezilla.desktop']"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Desktop, you may want to consider install VirtualBox Guest Additions by selecting
Devices
->Install Guest Additions
.When creating an appliance make sure to compact properly, by running the following commands on the VM:
rm cs-course_vm.sh dd if=/dev/zero of=fillfile bs=1M rm fillfile history -c sudo shutdown -h now
Then, on the host side:
Also, you may want to enable ssh access by:
Optionally, you may add the following tweaks:
Devices
->Shared Clipboard
->Bidirectional
Edit
->Profile Preferences
:General
-> [ ]Terminal Bell
Scrolling
-> [x]Unlimited