jcanfield
1/18/2014 - 5:22 PM

After installing Ubuntu, simply run this script to configure a fresh installation.

After installing Ubuntu, simply run this script to configure a fresh installation.

#!/bin/bash
# Ubuntu 13.10 and 14.04 should work perfectly with this script.

# PPAS
   ## Essentials
   sudo add-apt-repository -y "deb http://archive.canonical.com $(lsb_release -sc) partner"
   sudo add-apt-repository -y ppa:mc3man/mpv-tests # MPV (ffmpeg version)
   sudo add-apt-repository -y ppa:atareao/nautilus-extensions # Nautilus Image Extensions
   sudo add-apt-repository -y ppa:ubuntu-wine/ppa # Updated Wine Packages from Wine Developers
   sudo add-apt-repository -y ppa:webupd8team/y-ppa-manager # Namely for YAD

   ## Theme PPAs
   sudo add-apt-repository -y ppa:noobslab/themes
   sudo add-apt-repository -y ppa:noobslab/icons
   sudo add-apt-repository -y ppa:noobslab/icons2
   sudo add-apt-repository -y ppa:noobslab/nitrux-os
   sudo add-apt-repository -y ppa:noobslab/malys-themes
   sudo add-apt-repository -y ppa:snwh/moka-gtk-theme-daily

   ## Trusty Fixes
   if [ -n "$(cat /etc/lsb-release | grep development)" ]; then
      sudo sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/noobslab*
      sudo sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/snwh*
      sudo sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/atareao*
   fi

# Install Software
sudo apt-get update
   
   ## Essentials
   sudo apt-get install -y gdebi ubuntu-restricted-extras libtxc-dxtn-s2tc-bin mesa-utils ooo-thumbnailer ffmpegthumbnailer p7zip-full lrzip cifs-utils nfs-common git lynx screen nautilus-image-tools yad curl unity-tweak-tool ppa-purge

   ## Internet
   sudo apt-get install -y geary qbittorrent
   sudo apt-get remove -y thunderbird transmission

   ## Multimedia
   sudo apt-get install -y gimp mypaint scribus openshot audacious pyrenamer rednotebook mpv
   sudo apt-get remove -y rhythmbox
   sudo /usr/share/doc/libdvdread4/install-css.sh

#      ### Encoding Tools
#      cd /tmp
#      git clone https://github.com/mmstick/ubuntu-10bit-encoding-tools
#      cd ubuntu-10bit-encoding-tools
#      ./install.sh

   ## Games
   sudo apt-get install -y steam playonlinux wine1.7

   ## Other
   sudo apt-get install -y keepassx

   ## Development
   # sudo apt-get install

# System Configuration
   ## Hosts File
   cd /tmp   
   wget "http://winhelp2002.mvps.org/hosts.txt" -O hosts-new
   sudo mv /etc/hosts /tmp/hosts-old
   cat hosts-old hosts-new > hosts
   sudo mv hosts /etc

   ## Disable Apport
   sudo sed -i 's/enabled=1/enabled=0/g' /etc/default/apport 

   ## /tmp in RAM
   RAM=$(grep MemTotal /proc/meminfo | awk -F " " '{print $2}')
   if [ $RAM -ge 4000000 ]; then
      sudo sh -c "echo '## Mount /tmp to RAM' >> /etc/fstab"
      sudo sh -c "echo 'tmpfs /tmp tmpfs defaults 0 0' >> /etc/fstab"
      sudo sh -c "echo 'tmpfs /var/cache/apt/archives tmpfs defaults 0 0' >> /etc/fstab"
   fi

   ## PulseAudio Settings
      ### Current Settings
      sampleRate=$(grep "default-sample-rate" /etc/pulse/daemon.conf)
      sampleFormat=$(grep "default-sample-format" /etc/pulse/daemon.conf)
      resampleMethod=$(grep "resample-method" /etc/pulse/daemon.conf)
      defaultFragments=$(grep "default-fragments" /etc/pulse/daemon.conf)
      defaultFragmentSizeMsec=$(grep "default-fragment-size-msec" /etc/pulse/daemon.conf)

      ### New Settings
      sudo sed -i s/"$resampleMethod"/"resample-method = src-sinc-medium-quality"/g /etc/pulse/daemon.conf
      sudo sed -i s/"$sampleFormat"/"default-sample-format = float32ne"/g /etc/pulse/daemon.conf
      sudo sed -i s/"$sampleRate"/"default-sample-rate = 48000"/g /etc/pulse/daemon.conf
      sudo sed -i s/"$defaultFragments"/"default-fragments = 8"/g /etc/pulse/daemon.conf
      sudo sed -i s/"$defaultFragmentSizeMsec"/"default-fragment-size-msec = 25"/g /etc/pulse/daemon.conf
   pulseaudio -k

   ## Templates
   touch ~/Templates/Document.odt
   touch ~/Templates/Spreadsheet.ods
   
# Extra Hardware Configuration
   ## GPU Upgrade
   if [ -n "$(lspci | grep NVIDIA)" ]; then
      isNVIDIA=true
   fi

   ## Install GPU drivers
   if [ "$isNVIDIA" == "true" ]; then
      sudo apt-get install nvidia-current-updates nvidia-settings -y
   else
      if [ -n "$(cat /etc/lsb-release | grep precise)" ]; then
         sudo add-apt-repository -y ppa:pali/graphics-drivers -y
      else
         sudo add-apt-repository -y ppa:oibaf/graphics-drivers -y
         ### Install the Latest Linux Kernel
         cd /tmp
         sudo rm *.deb

         if [ "$(getconf LONG_BIT)" = "64" ]; then arch=amd64; else arch=i386; fi

         function download() {
            wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep "$1" | grep "$2" | grep "$arch" | cut -d ' ' -f 4)
         }

         # Kernel URL
         read -p "Do you want the latest RC?" rc
         case "$rc" in
            y*) kernelURL=$(lynx -dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | tail -1 | cut -d ' ' -f 3) ;;
            n*) kernelURL=$(lynx -dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | grep -v rc | tail -1 | cut -d ' ' -f 3) ;;
         esac

         read -p "Do you want the lowlatency kernel?" lowlatency
         case "$lowlatency" in
            y*) lowlatency=1 ;;
            n*) lowlatency=0 ;;
         esac

         # Download Kernel
         if [ "$lowlatency" == "0" ]; then
            echo "Downloading the latest generic kernel."
            download generic header
            download generic image
         elif [ "$lowlatency" == "1" ]; then
            echo "Downloading the latest lowlatency kernel."
            download lowlatency header
            download lowlatency image
         fi

         # Shared Kernel Header
         wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep all | cut -d ' ' -f 4)

         # Install Kernel
         echo "Installing Linux Kernel"
         sudo dpkg -i linux*.deb
      fi
      sudo apt-get update
      sudo apt-get dist-upgrade -y
 
   fi

   ## Logitech Unifying Receiver
   if [ -n "lsusb | grep Unifying" ]; then
      sudo add-apt-repository ppa:daniel.pavel/solaar -y
      if [ -n "$(cat /etc/lsb-release | grep development)" ]; then
         sudo sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/daniel_pavel-solaar-*
      fi
      sudo apt-get update
      sudo apt-get install solaar -y
   fi