Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # super-setep installer script
- # by Noki
- sVer="17" #script version
- ## required updates:
- ## 1. sudo start section
- ## 2. chrome install flakey, delete erreor
- ## 2. Change directory (cd) to ~/.config/google-chrome/Default
- ## 2. Delete the file named “Web Data”: rm -rf Web\ Data;
- ## 3. better logging
- ## 4. aptdcon
- ## 5. build-dep (virtualbox etc)
- ############################################################
- # functions
- ############################################################
- function logInfo() {
- case $1 in
- 0 )
- echo "[`date`][INFO] $2" >> ~/super-setup.log;;
- 1 )
- echo "[`date`][INFO] $2" >> ~/super-setup.log
- echo "$2";;
- 2 )
- echo "[`date`][WARN] $2" >> ~/super-setup.log
- echo "$2";;
- 3 )
- echo "[`date`][ERROR] $2" >> ~/super-setup.log
- echo "$2";;
- 4 )
- echo "[`date`][FIXME] $2" >> ~/super-setup.log
- echo "$2";;
- esac
- }
- function bannerSmall() {
- clear
- echo "####"
- echo "#### $1"
- echo "####"
- echo
- }
- function bannerBig() {
- clear
- figlet -f big $1
- echo
- echo "################################################################################"
- echo
- echo $2
- echo
- echo "################################################################################"
- echo
- }
- function cleanUpgrade() {
- sudo apt-get purge && sudo apt-get clean && sudo apt-get check
- sudo apt-get update -qq
- sudo apt-get upgrade -yqq && sudo apt-get dist-upgrade -yqq
- sudo apt-get -y autoremove && sudo apt-get autoclean
- }
- function addPPA() {
- grep -h "^deb.*$1" /etc/apt/sources.list.d/* > /dev/null 2>&1
- if [ $? -ne 0 ] ; then
- echo
- echo
- echo "Adding ppa:$1"
- sudo add-apt-repository -y ppa:$1
- return 0
- fi
- echo
- echo
- echo "ppa:$1 already exists, skipping repo."
- return 1
- }
- function appCheck() {
- case "$1" in
- [0] ) # check single only
- dpkg -l | grep -q $2
- if [ $? -eq 0 ] ; then
- return 0 # app found
- fi
- return 1 # not found
- ;;
- [1] ) # check array only
- local tmp=$2[@]
- local ask=0
- local arrArg=(${!tmp})
- for i in ${arrArg[*]}
- do
- :
- dpkg -l | grep -q $i
- if [ $? -eq 1 ] ; then
- ask=1
- fi
- done
- if [ $ask -eq 0 ] ; then
- return 0 # app found
- else
- return 1 # not found
- fi
- ;;
- esac
- }
- function runInstall() {
- local carryOn=0
- appCheck 0 $1
- if [ $? -ne 0 ] ; then
- bannerSmall "Simulating install for '$1'"
- if sudo apt-get --simulate install $1
- then carryOn=1
- else carryOn=0 && echo "Install test failed!!!"
- fi
- if [ $carryOn -ne 1 ] ; then
- sleep 2
- read -p "Retry (selecting 'NO' will exit the script)? " -n 1 -r
- if [[ $REPLY =~ ^[Yy]$ ]] ; then
- if sudo apt-get --simulate install $1
- then echo "Simulation Passed, but you won't see this message!"
- else echo "Simulation failed again, proceeding anyway..." && echo && sleep 2
- fi
- else
- clear && exit
- fi
- fi
- bannerSmall "Beginning install for '$1' and any dependencies."
- sudo apt-get -yqq install $1
- if [ $? -eq 0 ] ; then
- logInfo 1 "'$1' was installed with all of its dependencies."
- return 0
- else
- echo "#### Failed installation for $1 ####"
- return 1
- fi
- else
- echo
- echo "$1 is already installed, skipping..."
- return 0
- fi
- }
- function askInstall() {
- local tmp=("${!2}")
- clear
- bannerBig "Install $1 ?" "The following are the main applications in this section:"
- echo ${tmp[*]}
- echo
- read -p "Proceed? " -n 1 -r
- if [[ $REPLY =~ ^[Yy]$ ]] ; then
- local complete=0
- if [ ! -z $3 ] ; then
- addPPA $3
- if [ ! -z $4 ] ; then
- addPPA $4
- fi
- fi
- for i in ${tmp[@]}
- do
- :
- mainList+=($i)
- done
- else
- local complete=1
- if [ ! -z $3 ] ; then
- skipList+=("$1 repo: 'sudo add-apt-repository ppa:$3'")
- if [ ! -z $4 ] ; then
- skipList+=("$1 repo 2: 'sudo add-apt-repository ppa:$4'")
- fi
- fi
- for i in ${tmp[@]}
- do
- :
- skipList+=($i)
- done
- fi
- echo
- if [ $complete -eq 0 ] ; then
- return 0
- else
- return 1
- fi
- }
- function downloadPackage() {
- clear
- if [ -f $2 ] ; then
- wget -O $2.new $3 && rm $1
- if [ $? -ne 0 ] ; then
- mv $2.new $2
- echo
- return 0
- else
- logInfo 3 "$1 failed to download: $3"
- return 1
- fi
- else
- wget -O $2 $3
- echo
- return 0
- fi
- }
- function askRemove() {
- clear
- echo "Remove '$1' from the system?"
- echo
- read -p "Proceed? " -n 1 -r
- if [[ $REPLY =~ ^[Yy]$ ]] ; then
- local complete=0
- echo
- echo "Removing '$1' and any dependencies from system."
- sudo apt-get -yqq autoremove $1
- if [ $? -eq 0 ] ; then
- echo "#### Done with $1 ####"
- return 0
- else
- echo "#### Failed removal for $1 ####"
- return 1
- fi
- fi
- }
- ############################################################
- # START!
- ############################################################
- clear
- #crap, fix this (1)
- echo "Hello $USER"
- sudo clear
- # run log
- logInfo 0 "Beginning super-setup $sVer run by $USER"
- echo "#### Installing lsb-core to prevent errors in script."
- sudo apt-get -yqq install lsb-core && echo
- echo "#### Installing figlet for fun and mirth!"
- sudo apt-get -yqq install figlet
- echo "#### Installing dctrl-tools to check for installed packages."
- sudo apt-get -yqq install dctrl-tools
- mkdir -p ~/Downloads/Keepers
- bannerBig "Beginning Super Amazing Awesome Script of Doom" "version number $sVer" && sleep 2
- # declare 64 bit dependencies here
- if [ `uname -m` = "x86_64" ] ; then
- sudo dpkg --add-architecture i386
- chromeVer=amd64
- skypeVer=64
- else
- chromeVer=i386
- skypeVer=32
- fi
- ############################################################
- # arrays and variables
- ############################################################
- # mainlist will be installed, others are optionally appended to this
- declare -a mainList=( python-software-properties pkg-config software-properties-common rar unrar compizconfig-settings-manager compiz-plugins compiz-plugins-extra ghex gksu preload wmctrl dkms curl gcc pinta Unetbootin gprename qbittorrent smartmontools medit gparted )
- # first app list, no repo's required
- declare -a mediaList=( ubuntu-restricted-extras audacity audacious vlc mpv lame libav-tools calibre libdvdread4 gimp flashplugin-installer k3b flac faac faad sox ffmpeg2theora libmpeg2-4 uudeview mpeg3-utils mpegdemux liba52-dev mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 icedax lame libmad0 libjpeg-progs libdvdnav4 ) #odd logic, bluray # libdvdcss2 libdvdread4
- declare -a webcamList=( cheese gnome-video-effects-extra )
- declare -a sharingList=( nfs-common filezilla cifs-utils ssh samba samba-common smbclient apache2 )
- declare -a gameList=( xserver-xorg-dev p7zip-full scanmem glibc-doc-reference playonlinux wine ttf-mscorefonts-installer )
- declare -a devList=( eclipse git-core git subversion byacc flex build-essential checkinstall cvs mercurial automake ruby ruby-capybara cucumber bundler nodejs rbenv bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev libtool )
- declare -a unityTweakList=( unity-tweak-tool )
- declare -a chromiumList=( chromium-browser flashplugin-installer pepperflashplugin-nonfree )
- # download apps
- declare -a chrome=( google-chrome-stable )
- declare -a chromeList=( libxss1 libappindicator1 libcurl3 )
- declare -a skypeList=( skype )
- # third Party apps requiring repo's
- declare -a xbmcList=( kodi )
- declare -a handbrakeList=( handbrake-gtk )
- declare -a gnomeList=( gnome-shell gnome-shell-extensions )
- declare -a blurayList=( libaacs0 libbluray-bdj libbluray1 )
- declare -a halList=( hal hal-info )
- declare -a playmusicList=( google-musicmanager-beta )
- # third Party apps repo's
- wineRepo='ubuntu-wine/ppa'
- xbmcRepo='team-xbmc/ppa'
- gnomeRepo1='gnome3-team/gnome3-next'
- gnomeRepo2='gnome3-team/gnome3-staging'
- blurayRepo='n-muench/vlc'
- halRepo='mjblenner/ppa-hal'
- handbrakeRepo='stebbins/handbrake-snapshots'
- # downloaded apps # CURL
- chromeFile=~/Downloads/Keepers/google-chrome-stable_current_$chromeVer.deb
- chromeWeb=https://dl.google.com/linux/direct/google-chrome-stable_current_$chromeVer.deb
- skypeFile=~/Downloads/Keepers/skype-linux-beta-ubuntu-$skypeVer.deb
- skypeWeb=http://www.skype.com/go/getskype-linux-beta-ubuntu-$skypeVer
- steamFile=~/Downloads/Keepers/steam_latest.deb
- steamWeb=http://repo.steampowered.com/steam/archive/precise/steam_latest.deb
- sc2File=~/Downloads/Keepers/StarCraft-II-Setup-enGB.exe
- sc2Web=http://dist.blizzard.com/downloads/sc2-installers/full/StarCraft-II-Setup-enGB.exe
- diabloFile=~/Downloads/Keepers/Diablo-III-Setup-enGB.exe
- diabloWeb=http://dist.blizzard.com/downloads/d3-installers/9ed8c6bce632597fa6646acda77b8025/retail_1/Diablo-III-Setup-enGB.exe
- # removal apps
- declare -a removeList=( transmission-common gedit-common )
- ################################################################################
- # Ask questions...
- ################################################################################
- bannerBig "Section 1 of 2" "Applications from Ubuntu Main & .deb packages."
- echo ${mainList[*]} && sleep 3
- if ! appCheck 1 sharingList ; then
- askInstall "File Sharing Software" sharingList[@]
- fi
- if ! appCheck 1 unityTweakList ; then
- askInstall "Unity Tweak Tool" unityTweakList[@]
- fi
- if ! appCheck 1 mediaList ; then
- askInstall "Media Software" mediaList[@]
- if [ $? -eq 0 ] ; then
- dvdplayback=true
- handbrake=true
- blurayskip=false
- echo
- echo "Include Dolby Support?"
- echo
- read -p "Proceed? " -n 1 -r
- echo
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- then
- mainlist+=('pavucontrol')
- fi
- fi
- else
- blurayskip=true
- handbrake=false
- dvdplayback=false
- fi
- if ! appCheck 1 webcamList ; then
- askInstall "Optional Web Cam Extras" webcamList[@]
- fi
- if ! appCheck 1 chromiumList ; then
- askInstall "Chromium Browser" chromiumList[@]
- if [ $? -eq 0 ] ; then
- chromium=true
- fi
- fi
- if ! appCheck 1 chrome ; then
- askInstall "Google Chrome Browser" chromeList[@]
- if [ $? -eq 0 ] ; then
- chromeDownload=true
- fi
- fi
- if ! appCheck 1 skypeList ; then
- bannerBig "Download Skype?" "manual install required..."
- read -p "Proceed? " -n 1 -r
- echo
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- then
- skypeDownload=true
- else
- skipList+=('Skype Installer Available')
- skipList+=('To install Skype visit skype.com/en/download-skype/skype-for-linux/')
- fi
- fi
- if ! appCheck 1 devList ; then
- askInstall "Developer Kit Software" devList[@]
- fi
- if ! appCheck 1 gameList ; then
- askInstall "Game Software" gameList[@]
- if [ $? -eq 0 ] ; then
- games=true
- fi
- else
- games=false
- wineInstall=false
- fi
- if [ "$games" = true ] ; then
- echo
- echo "Add Wine Repo and update to the latest version?"
- read -p "This is required for Steam under Wine, are you sure? " -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- then
- wineInstall=true #defer for update
- addPPA $wineRepo
- fi
- echo
- echo "Playing Starcraft II and/or Diablo III through Wine? "
- echo "1. Both"
- echo "2. Starcraft II only"
- echo "3. Diablo III only"
- echo
- read -p "Enter 1, 2 or 3. " choice
- echo
- case $choice in
- 1 ) # both
- sc2Download=true
- diabloDownload=true
- kernelMode=true ;;
- 2 ) # sc2
- sc2Download=true
- diabloDownload=false
- kernelMode=true ;;
- 3 ) # diablo
- diabloDownload=true
- sc2Download=false
- kernelMode=true ;;
- * )
- echo "Cancelled/Invalid input." >> ~/super-setup.log
- echo ;;
- esac
- fi
- bannerBig "Section 2 of 2" "These applications need additional Repositories in order to be installed." && sleep 3
- if ! appCheck 1 xbmcList ; then
- askInstall "Kodi Media Centre" xbmcList[@] $xbmcRepo
- fi
- if [ "$handbrake" = true ]; then
- if ! appCheck 1 handbrakeList ; then
- askInstall "HandBrake - DVD ripper" handbrakeList[@] $handbrakeRepo
- fi
- fi
- if ! appCheck 1 gnomeList ; then
- askInstall "GNOME 3 - Desktop Manager" gnomeList[@] $gnomeRepo1 $gnomeRepo2
- fi
- if ! appCheck 1 halList ; then
- askInstall "HAL - DVD streaming 4od" halList[@] $halRepo
- fi
- if ! appCheck 1 playmusicList ; then
- askInstall "Google Play Music - beta" playmusicList[@]
- if [ $? -eq 0 ] ; then
- sudo sh -c 'echo "deb http://dl.google.com/linux/musicmanager/deb/ stable main" >> /etc/apt/sources.list.d/google-musicmanager.list'
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- fi
- fi
- if [ "$bluraySkip" = false ]; then
- app_check 1 blurayList
- if [ $? -eq 1 ] ; then
- askInstall "Bluray support - VLC Extension" blurayList[@] $blurayRepo
- if [ $? -eq 0 ] ; then
- mkdir -p ~/.config/aacs/
- if [ -f /home/$USER/.config/aacs/KEYDB.cfg ] ; then
- sudo rm -f /home/$USER/.config/aacs/KEYDB.cfg
- wget -O /home/$USER/.config/aacs/KEYDB.cfg http://vlc-bluray.whoknowsmy.name/files/KEYDB.cfg
- fi
- fi
- fi
- fi
- ############################################################
- # begin install
- ############################################################
- bannerBig "Right then!" "Updating and installing software..."
- cleanUpgrade
- # wine version now that apt-get is updated
- if [ "$wineInstall" = true ] ; then
- declare -a WineVersion
- wineVersion=(`apt-cache search --names-only wine[0-9]*[.][0-9]* | awk -F' ' '{ print $1 }' | awk -F'-' '{ print $1 }' | sort -nr | uniq`)
- mainlist+=(${wineVersion[0]})
- fi
- # application install
- for i in "${mainList[@]}"
- do
- :
- runInstall $i
- if [ $? -ne 0 ] ; then
- failList+=($i)
- fi
- done
- # DVD Script
- if [ "$dvdplayback" = true ] ; then
- sudo /usr/share/doc/libdvdread4/install-css.sh
- echo
- fi
- # download and installs
- if [ "$chromium" = true ] ; then
- sudo update-pepperflashplugin-nonfree --install
- fi
- if [ "$chromeDownload" = true ] ; then
- downloadPackage "Google Chrome" $chromeFile $chromeWeb
- if [ $? -eq 0 ] ; then
- sudo dpkg -i $chromeFile
- rm /home/$USER/.config/google-chrome/SingletonLock
- fi
- fi
- if [ "$skypeDownload" = true ] ; then
- downloadPackage "Skype - beta" $skypeFile $skypeWeb
- fi
- if [ "$games" = true ] ; then
- downloadPackage "Steam" $steamFile $steamWeb
- fi
- if [ "$sc2Download" = true ] ; then
- downloadPackage "StarCraft II (exe)" $sc2File $sc2Web
- fi
- if [ "$diabloDownload" = true ] ; then
- downloadPackage "Diable III (exe)" $diabloFile $diabloWeb
- fi
- if [ "$dvdPlayback" = true ] ; then
- sudo /usr/share/doc/libdvdread4/install-css.sh
- fi
- # ask about removing some crap
- for i in "${removeList[@]}"
- do
- :
- appCheck 0 $i
- if [ $? -eq 0 ] ; then
- askRemove $i
- fi
- done
- ############################################################
- # install done failures and skip
- ############################################################
- declare -a failList
- declare -i failed=0
- for i in "${failList[@]}"
- do
- :
- failed=`expr $failed + 1`
- done
- if [ $failed -ne 0 ] ; then
- declare -a failList2=()
- clear
- logInfo 2 "Some installations failed, these include:"
- echo
- for i in "${failList[@]}"
- do
- :
- logInfo 2 ":: $i"
- done
- echo
- read -p "Retry these apps? " -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- then
- for i in "${failList[@]}"
- do
- :
- runInstall $i
- if [ $? -ne 0 ] ; then
- failList2+=($i)
- fi
- done
- failed=0
- for i in "${failList2[@]}"
- do
- :
- failed=`expr $failed + 1`
- done
- if [ $failed -ne 0 ] ; then
- clear
- logInfo 3 "Some installations failed thrice, these include:"
- echo
- for i in "${failList2[@]}"
- do
- :
- if [ "$i" = 'kodi' ] ; then
- logInfo 3 ":: $i :: http://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux"
- else
- logInfo 3 ":: $i"
- fi
- done
- fi
- else
- echo
- logInfo 3 "Some installations failed twice, these include:"
- echo
- for i in "${failList2[@]}"
- do
- :
- if [ "$i" = 'kodi' ] ; then
- logInfo 3 ":: $i"
- logInfo 3 ":: http://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux"
- else
- logInfo 3 ":: $i"
- fi
- done
- fi
- fi
- declare -a skipList=()
- declare -i skipped=0
- for i in "${skipList[@]}"
- do
- :
- skipped=`expr $skipped + 1`
- done
- if [ $skipped -ne 0 ] ; then
- bannerSmall "Skipped item details."
- logInfo 1 "You opted out of installing some apps during the script."
- logInfo 1 "You can use the following command to install them:"
- logInfo 1 "'sudo apt-get install APPNAME'"
- echo
- logInfo 1 "The following are from the Ubuntu Repository"
- logInfo 1 "Or installed from: /home/$USER/Downloads/Keepers:"
- for i in "${skipList[@]}"
- do
- :
- logInfo 1 ":: $i"
- done
- sleep 1
- fi
- if [ "$wineInstall" = true ] ; then
- logInfo 1 "Alternate wine versions available (apt source added):"
- for i in "${wineVersion[@]}"
- do
- :
- logInfo 1 ":: $i"
- done
- sleep 1
- fi
- ############################################################
- # fail/skip done, final messages
- ############################################################
- echo && cleanUpgrade
- bannerSmall "Super Amazing Awesome Script of Doom Completed!" "$USER completed this run, version number $sVer !"
- if [ "$kernelMode" = true ] ; then
- sudo sysctl kernel.yama.ptrace_scope=0
- logInfo 1 "Blizzard games require a non-default kernel setting:"
- logInfo 1 ":: 'sudo sysctl kernel.yama.ptrace_scope=0'"
- logInfo 1 "Kernel mode has been SET, change 0 to 1 in order to reset."
- echo
- fi
- if [ "$steam" = true ] || [ "$sc2Download" = true ] || [ "$diabloDownload" = true ] || [ "$skypeDownload" = true ]; then
- bannerSmall "Game options selected, file locatations:"
- if [ "$skypeDownload" = true ] ; then
- logInfo 1 "Skype installer in shell is flakey, run this is GUI:"
- logInfo 1 "$skypeFile"
- echo
- fi
- if [ "$sc2Download" = true ] ; then
- logInfo 1 "StarCraft II is located here, run this in PlayOnLinux:"
- logInfo 1 "$sc2File"
- echo
- fi
- if [ "$diabloDownload" = true ] ; then
- logInfo 1 "Diablo III is located here, run this in PlayOnLinux:"
- logInfo 1 "$diabloFile"
- echo
- fi
- if [ "$steam" = true ] ; then
- logInfo 1 "Steam installer in shell is flakey, run this is GUI:"
- logInfo 1 "$steamFile"
- echo
- fi
- fi
- logInfo 0 "Super-setup $sVer completed by $USER."
- echo >> ~/super-setup.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement