Easy Post-Install Software Thingy

To be used on new linux (debian-based) installations.  I'll usually give new users their pc with freshly installed linux and a copy of this script on the desktop, so they can double click and install from a list of commonly used software.  The purpose is to give new users a non-daunting, non-cryptic way to install things.  Point-and-click:  the windows way.  While some distros (read Ubuntu) already have the software centre to handle stuff like this, it wasn't always like that.  It used to be a bit more difficult, for newcomers, that is.  Ubuntu doesn't even support gksu any more but that's because it wants to be an odd ball.  Debian, on the other hand, is still on the path of the righteous -_-


#!/bin/bash

## easy installer
## by Jon Tohrs 
## Send me money!  -_-
##
## script to automatically install whichever software is chosen by the user
## from a list of commonly used apps.


## gain root power, because we have to

gksudo -k -m "What's the magic word?" /bin/echo "got r00t?"
sudo -v


## make a backup copy, if necessary, of sources.list, before we make a mistake :o

if [ -e "/etc/apt/sources.list.bak" ]

 then
 diff -i -b -B -q /etc/apt/sources.list /etc/apt/sources.list.bak
 if [ ! $? -eq 0 ]
  then
  sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
 fi
else
 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
fi

## uncomment repositories in sources.list

 if $(zenity --question --no-wrap --title "easy installer" --text "do you wish to update
\n repository info?") ; then

(
sudo sed -i 's/\(^# *\)\(deb.[^c]\)/\2/' /etc/apt/sources.list
sudo apt-get --quiet update

## add the medibuntu repository, if necessary
## the following lines have been commented out, because medibuntu is no longer needed
## ubuntu has resolved multimedia issues differently.
## i won't remove the lines, because medibuntu might actually come back some day... not!
## I didn't replace with debian-multimedia because there'd been some issues with that, too

#if [ ! -e "/etc/apt/sources.list.d/medibuntu.list" ]
# then
#sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
#fi

## display a nifty progress bar while repositories update :)

) | zenity --progress --pulsate --auto-close --auto-kill --title="easy installer" --text="updating repository"  --percentage=0 --width 350 --height 25

fi

## create a bash script within the user's home directory

echo "#!/bin/bash" > $HOME/files
echo " " >> $HOME/files

## determine which packages/apps/files are going to be installed
## replace "software" and "description" with the name of the package and it's description.

ans=$(zenity  --list  --width 500 --height 500 --title="easy installer"  --text "What do you want to install?" --checklist  --column "Pick" --column "options"  --column "description" FALSE "software" "description" FALSE "software" "description" FALSE "software" "description"  --separator=" "); echo "sudo apt-get install --yes --force-yes $ans" >> $HOME/files
if $ans
 then
 exit 0
fi

## make the resulting file executable

sudo chmod a+rx $HOME/files

## install files

cd $HOME
(
./files
) | zenity --progress --pulsate --auto-close --auto-kill --title="easy installer" --text="installing packages"  --percentage=0 --width 350 --height 25

## remove resulting file, given it's not necessary any more

rm $HOME/files

## update menu entries

(
if [ -e "/usr/bin/update-menus" ]
 then sudo update-menus
else
 sudo apt-get install --yes --force-yes menu
 sudo update-menus
fi
) | zenity --progress --pulsate --auto-close --auto-kill --title="easy installer" --text="updating menu entries"  --percentage=0 --width 350 --height 25

exit 0