Ubuntu setup – post installation script

My iPhone apps as of February 2010
My iPhone apps as of February 2010 (Photo credit: dougbelshaw)

If you have done a new installation of Ubuntu or Fedora, then yuou know you have to search all kind of blogs to find out what all to install. So, here is a easier way to do that. Just run this script, it will install some applications which are mostly a “MUST” for all the installations. And the list of applications that are installed are :

colorgcc vim-gnome vim-gtk vlc evolution-exchange vlc smplayer mplayer
w32codecs skype wireshark patch openssh-server tkcvs g++ g++-multilib
libaio1 libpq5 libqscintilla2-8 libfam0 libqt3-mt libc6-dev
ubuntu-restricted-addons ubuntu-restricted-extras and
mediubutu repository.

And here is the script::

#!/bin/bash -
#===============================================================================
#
#          FILE:  ubuntu.sh
#
#         USAGE:  ./ubuntu.sh
#
#   DESCRIPTION:  Ububntu Post-Installation script.
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka)
#       CREATED: 26/06/12 13:13:21 IST
# Last modified: Fri Jun 29, 2012  04:54PM
#      REVISION:  ---
#===============================================================================

apps=(""  colorgcc vim-gnome vim-gtk  vlc evolution-exchange vlc smplayer mplayer w32codecs  skype wireshark patch openssh-server tkcvs g++ g++-multilib libaio1 libpq5 libqscintilla2-8 libfam0 libqt3-mt libc6-dev )
apps_desc=("" 
    "Colorgcc displays nice colrs for all the errors in compilation" 
    "Vim for Gnome" 
    "Required for Vim"
    "VLC Media Player"
    "Exchange plugin for Evolution"
    "GUI for mplayer"
    "Codecs to play all video/audio files"
    "skype :)"
    "Wireshark(a.k.a formely Ethereal)"
    "Utility to apply cvs diff or diff output to directory as patch"
    "SSH Server(not required for clients)"
    "GUI For CVS"
    "Dev Tool - C++ compiler"
    "Dev Tool to get the correct libraries" 
    "lib required for building applicatons" 
    "lib required for building applications" 
    "lib required for building applications" 
    "lib required for building applications" 
    "lib required for building applications" 
    "lib required for building applications" 
    "lib required for building applications" 
    "lib required for building applications"  )

echo '
Created by Amit Agarwal
'

if [[ $UID -ne 0 ]]
then
    echo "run with root user"
    exit
fi

if [[ ! -f /etc/sudoers.d/users ]]
then
    read -p "Please enter usernames to allow seperated by comma and no space allowed :: " a
    if [[ $a != "" ]]
    then

        echo "#Added by Amit Agarwal" >>/etc/sudoers.d/users
        for i in ${a//,/ /}
        do
            echo "$i ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers.d/users
        done
        chmod 0440 /etc/sudoers.d/users
    else
        echo "No entries added to sudoers"
    fi
else
    echo "Changes for sudo are already present"
    echo "List of users allowed without password in the sudoers file is ::"
    cat /etc/sudoers.d/users|awk '$1!="#.*"{print $1}'
    echo
fi

if [[ ! -f /etc/apt/sources.list.d/medibuntu.list ]]
then
    echo "Add the medibuntu repo.."
    wget http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list --output-document=/etc/apt/sources.list.d/medibuntu.list
    apt-get --yes -q --allow-unauthenticated install medibuntu-keyring
    echo "Update the apt with 'apt-get update' if you do not install anything."
else
    echo "Mediubuntu repo is already present"
fi

echo "Updating apt-get cache, wait for some time....."

i=1
while [[ $i -lt ${#apps[*]} ]]
do
    printf "%10s %3d. %-30s %-30sn" "" $i "${apps[$i]}" "${apps_desc[$i]}"
    ((i++))
done
echo "Please make your selection (enter the number)"
echo "(enter one at a time and end with blank line) ::"
read -p "Do you want to install all [y/N] ::" yesno
if [[ $yesno != "y" || $yesno != "Y" ]]
then
    readval=" "
    while [[ $readval != "" ]]
    do
        read -p "Enter the value :: " readval
        if [[ $(echo $readval|grep -c "[^0-9]") -ge 1 ]]
        then
            echo "Value is not acceptable, retry."
            readval=""
        else
            #echo "Selected now :: ${apps[$readval]}"
            appsinstall="$appsinstall ${apps[$readval]}"
            #echo "Selected so far $appsinstall"
        fi
    done
else
    appsinstall="${apps[*]}"
    echo "Selected apps are $appsinstall"
fi

apt-get -y install ubuntu-restricted-addons ubuntu-restricted-extras
if [[ ${#appsinstall} -ge 3 ]]
then
    echo "Apps selected to be udpated are $appsinstall"
    echo "Now updating apt-get cache"
    apt-get update -q >/dev/null
    apt-get -y --allow-unauthenticated install $appsinstall
fi
if [[ $? -ne 0 ]]
then
    echo "Something went wrong :("
    exit -1
fi

if [[ $appsinstall == *colorgcc* ]]
then
    echo "To use colorgcc, create a link with 'ln -s $(which colorgcc) g++'"
    echo "in ~/bin directory and add ~/bin to your PATH"
fi
Enhanced by Zemanta