Last active
December 28, 2015 03:49
-
-
Save clobrano/7437551 to your computer and use it in GitHub Desktop.
This is a script to install common utilities on a (K)Ubuntu machine just after installed the OS (Tested on Elementary OS)
This file contains hidden or 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 | |
| Author="Carlo Lobrano" | |
| Email="bytefalls@gmail.com" | |
| Version="2.2" | |
| Date="2014-05-25" | |
| Project="Ubuntu-derived OS post install script" | |
| # Changelog | |
| # 2014-06-07 Added indicator-cpufreq to eos (remember to copy the icons) | |
| # 2014-05-25 Separated package installation from ppa add. | |
| #======================================================== | |
| # List of packages to be checked for installation. | |
| #======================================================== | |
| # Packages list that starts with a distro name (EOS is for ElementaryOS), are specific for | |
| # the distribution (EOS will install also Ubuntu packages). | |
| # OTHER_PACKAGES is a list of applications indipendent from distribution, a part from the | |
| # fact that must be a Debian derivate (as for the rest of this script to work, btw). | |
| # This is the list you should modify the most if you like to add, remove or replace packages | |
| # you want. | |
| # The SPECIAL_PKGS list contains applications or scripts that need a special | |
| # function to be installed, that is, they cannot be installed through a simply | |
| # apt-get install. Let's that list unchanged | |
| # I have a Vaio notebook, this is why I added a NOTEBOOK_PGKS that apply to Vaio notebooks only. | |
| PPAs="ppa:versable/elementary-update ppa:fsvh/pacifica-icon-theme ppa:elementary-os/unstable-upstream \ | |
| ppa:vaiofand/ppa ppa:vaiopower/ppa" | |
| UBUNTU_PKGS="ubuntu-restricted-extras ttf-ubuntu-font-family" | |
| EOS_PKGS="elementary-tweaks indicator-synapse \ | |
| indicator-cpufreq \ | |
| elementary-colors-theme elementary-lion-theme elementary-elfaenza-icons" | |
| KUBUNTU_PKGS="kubuntu-restricted-extras" | |
| OTHER_PGKS="openjdk-7-jre icedtea-7-plugin openjdk-7-jdk \ | |
| chromium-browser chromium-codecs-ffmpeg-extra firefox \ | |
| gnome-system-monitor locate konsole recoll baobab git dropbox \ | |
| zip tar gparted psensor baobab tree" | |
| SPECIAL_PKGS="flashplugin_midory libdvdread4_installer conky_installer" | |
| NOTEBOOK_PKGS="vaiopower vaiofand" | |
| #======================================================== | |
| # GLOBALS | |
| #======================================================== | |
| TO_INSTALL="" | |
| #======================================================== | |
| # FUNCTIONS | |
| #======================================================== | |
| ## Logging | |
| log(){ | |
| echo "[+]" $@ | |
| } | |
| err(){ | |
| echo "[ERROR]" $@ | |
| } | |
| milestone(){ | |
| echo "" | |
| log "===================================" | |
| log $@ | |
| log "===================================" | |
| echo "" | |
| } | |
| fatal(){ | |
| echo "[FATAL]" $@ | |
| exit 1 | |
| } | |
| ## Utilities | |
| check_distro(){ | |
| DISTRO=$(lsb_release -si) | |
| ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/') | |
| VER=$(lsb_release -sr) | |
| log "Detected \"$DISTRO $VER $ARCH bits\". Is that right?" | |
| select choice in "yes, continue" "no, exit"; do | |
| case $choice in | |
| "yes, continue") | |
| break | |
| ;; | |
| "no, exit") | |
| exit 0 | |
| ;; | |
| esac | |
| done | |
| } | |
| __set_to_install(){ | |
| local package=$1 | |
| log "${package} not found. Install it?" | |
| select choice in "yes" "no"; do | |
| case $choice in | |
| "yes") | |
| TO_INSTALL="${TO_INSTALL} ${package}" | |
| break | |
| ;; | |
| "no") | |
| log "${package} won't be installed" | |
| break | |
| ;; | |
| ?) | |
| fatal "Wrong choice" | |
| break | |
| ;; | |
| esac | |
| done | |
| log ${TO_INSTALL} | |
| } | |
| __set_to_add(){ | |
| local ppa=$1 | |
| log "Add $ppa?" | |
| select choice in "yes" "no"; do | |
| case $choice in | |
| "yes") | |
| TO_ADD="${TO_ADD} ${ppa}" | |
| break | |
| ;; | |
| "no") | |
| log "${ppa} won't be added" | |
| break | |
| ;; | |
| ?) | |
| fatal "Wrong choice" | |
| break | |
| ;; | |
| esac | |
| done | |
| log ${add} | |
| } | |
| __check_package(){ | |
| local package=$1 | |
| [[ `dpkg -l | grep -i ${package} ` ]] | |
| } | |
| __check_and_install(){ | |
| local package=$1 | |
| __check_package ${package} || sudo apt-get install -y ${package} | |
| } | |
| #======================================================== | |
| # INSTALLERS | |
| #======================================================== | |
| elementary_ppa(){ | |
| milestone "Adding some Elementary PPA" | |
| log "Adding Elementary Tweaks PPA..." | |
| sudo apt-add-repository ppa:versable/elementary-update | |
| log "Adding Pacifica icon theme PPA..." | |
| sudo add-apt-repository ppa:fsvh/pacifica-icon-theme | |
| log "Adding Synapse indicator (search through files) PPA..." | |
| sudo add-apt-repository ppa:elementary-os/unstable-upstream | |
| } | |
| vaio_ppa(){ | |
| log "Adding vaiopower fan PPA..." | |
| sudo add-apt-repository ppa:vaiofand/ppa | |
| log "Adding vaiopower power management PPA..." | |
| sudo add-apt-repository ppa:vaiopower/ppa | |
| } | |
| libdvdread4_installer(){ | |
| log "Installing libdvdread4..." | |
| __check_and_install libdvdread4 | |
| sudo /usr/share/doc/libdvdread4/install-css.sh | |
| } | |
| flashplugin_midory(){ | |
| log "Setup flasplugin for midori" | |
| __check_and_install flashplugin-installer && | |
| __check_and_install nspluginwrapper | |
| set -x | |
| sudo ln -s /usr/lib/mozilla/plugins/flashplugin-alternative.so /usr/lib/mozilla/plugins/libflashplayer.so | |
| nspluginwrapper -v -a -n -i | |
| set +x | |
| } | |
| conky_installer(){ | |
| log "Adding conky" | |
| __check_and_install conky-all | |
| __check_and_install git | |
| git clone https://gist.github.com/ba148c621ee0e7afee65.git /tmp/conkyfolder || err "Could not clone repository for conky" | |
| mv /tmp/conkyfolder/conkyrc ~/.conkyrc || err "Could not create conkyrc" | |
| } | |
| #======================================================== | |
| # MAIN | |
| #======================================================== | |
| milestone "$Project" | |
| log "Author:${Author} - E-mail:$Email - Version:${Version} - Date:${Date}" | |
| check_distro | |
| PACKAGES="" | |
| case $DISTRO in | |
| "ubuntu") | |
| PACKAGES="${PACKAGES} ${UBUNTU_PKGS}" | |
| ;; | |
| "kbuntu") | |
| PACKAGES="${PACKAGES} ${KUBUNTU_PKGS}" | |
| ;; | |
| "elementary OS") | |
| PACKAGES="${PACKAGES} ${UBUNTU_PKGS} ${EOS_PKGS}" | |
| ;; | |
| esac | |
| milestone "Do you want to upgrade now?" | |
| select choice in yes no; do | |
| case $choice in | |
| yes) | |
| sudo apt-get update | |
| sudo apt-get upgrade | |
| break | |
| ;; | |
| no) | |
| log "Skip upgrade" | |
| break | |
| ;; | |
| ?) | |
| err "Wrong choice" | |
| ;; | |
| esac | |
| done | |
| PACKAGES="${PACKAGES} ${OTHER_PGKS} ${NOTEBOOK_PKGS}" | |
| milestone "Check PPAs to be added" | |
| for ppa in ${PPAs}; do | |
| __set_to_add ${ppa} | |
| done | |
| if [[ ! ${TO_ADD} = "" ]]; then | |
| milestone "Adding the following PPAs: ${TO_ADD}. Press ENTER to continue..." | |
| read | |
| for ppa in ${TO_ADD}; do | |
| sudo add-apt-repository ${ppa} | |
| done | |
| fi | |
| milestone "Check packages to be installed" | |
| for package in ${PACKAGES}; do | |
| __check_package ${package} && log "${package} already installed" || __set_to_install ${package} | |
| done | |
| if [[ ${TO_INSTALL} = "" ]]; then | |
| milestone "All packages already installed." | |
| else | |
| milestone "Following packages will be installed: ${TO_INSTALL}. Press ENTER to continue..." | |
| read | |
| for package in ${TO_INSTALL}; do | |
| sudo apt-get install -y ${package} | |
| done | |
| fi | |
| if [[ ! ${SPECIAL_PKGS} = "" ]]; then | |
| milestone "Running the following installer: ${SPECIAL_PKGS}. Press ENTER to continue..." | |
| read | |
| for installer in ${SPECIAL_PKGS}; do | |
| $installer | |
| done | |
| fi | |
| milestone "Update completed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment