#!/bin/bash

# Automated multimedia and restricted formats support script.
# Enables multimedia and restricted formats on your Ubuntu system.
# Many thanks to ubuntu-freak at the Ubuntu forums for his great guide.
# For more information, configuration, and troubleshooting visit:
# http://ubuntuforums.org/showthread.php?t=766683
# or my post on that thread here (alinux.deb):
# http://ubuntuforums.org/showthread.php?t=766683&page=136

# Requires an internet connection. Tested on Ubuntu Karmic 9.10 32 bit.
# The script may have to be modified to suit your system needs and configuration.
# Visit http://ubuntuforums.org/showthread.php?t=766683 for more info.

# The script must be run with root or superuser privileges:
# Open a terminal where the script is located and run...
# sudo ./multimedia.sh

# Checking for administrative rights.
ROOT_UID=0     # This script must be run as root.
E_NOTROOT=67   # Non-root exit error.

if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root to run this script. Open the script with a text editor for detailed instructions."
  exit $E_NOTROOT
fi  

# Enabling Medibuntu repositories
echo "Enabling Medibuntu repositories."
sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

# Removing free flash support
echo "Removing free flash support."
apt-get remove gnash gnash-common libflashsupport mozilla-plugin-gnash swfdec-mozilla -y

# Removing browser streaming capabilities
echo "Removing browser streaming capabilities."
apt-get remove kaffeine-mozilla mozilla-helix-player mozilla-mplayer mozilla-plugin-vlc totem-mozilla xine-plugin -y

# Enabling multimedia and restricted formats support
# Sometime in the installation you'll have to accept sun's license for java
# If you know a way of override or automatizing this step, please contact me at:
# javahelpbash@trashmail.net
# or at the Ubuntu formus with the name: alinux.deb
echo "Enabling multimedia and restricted formats support."
apt-get install alsa-oss faac faad flashplugin-nonfree gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-pitfdll libmp3lame0 non-free-codecs sun-java6-fonts sun-java6-jre sun-java6-plugin unrar p7zip-full moonlight-plugin-core moonlight-plugin-mozilla w32codecs libdvdcss2 libdvdread4 libdvdnav4 -y

# Enabling browser streaming capabilities
echo "Enabling browser streaming capabilities."
apt-get install gnome-mplayer gecko-mediaplayer -y

# Update, upgrade of packages and cleanup
echo "Update, upgrade of packages and cleanup."
apt-get update && apt-get upgrade -y && apt-get autoremove -y && apt-get autoclean -y

# Rebooting the system
echo "Rebooting the system."
reboot

exit
