#!/bin/sh

# This script will install DVD Shrink 3.2 in Ubuntu
# This script needs to be run as root and have 755 permission
# WINE emulator must be installed for DVD Shrink to function
#
# Authored by Bob Nelson  admin@stchman.com
#

script_name="dvdshrink.sh"

# Script must run as root 
if [ $USER != "root" ]; then
	echo "You need to run this script as root."
	echo "Use 'sudo ./$script_name' then enter your password when prompted."
	exit 1
fi

# This script will install to the users home folder
# change to the users home folder
cd ~

# download the .tar.gz archive from www.stchman.com
wget http://www.stchman.com/tools/dvd_shrink/DVD_Shrink.tar.gz

# unzip the archive to the users home folder in the newly created folder
sudo tar -C /opt -zxvf ~/DVD_Shrink.tar.gz

# make menu entry in Application-->Games
# script will do this by creating a mshearts.desktop text file
# the > creates the file while >> appends to the file
sudo echo "[Desktop Entry]" > /usr/share/applications/dvdshrink.desktop
sudo echo "Encoding=UTF-8" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Name=DVD Shrink 3.2" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Comment=Shrink your DVDs" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Categories=GNOME;GTK;AudioVideo;" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Exec=/usr/bin/wine /opt/DVD_Shrink/DVD_Shrink_3.2.exe" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Icon=/opt/DVD_Shrink/Web/Images/dvdshrink.gif" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Terminal=false" >> /usr/share/applications/dvdshrink.desktop
sudo echo "Type=Application" >> /usr/share/applications/dvdshrink.desktop

# remove the .zip archive as it is no longer needed
rm -f ~/DVD_Shrink.tar.gz


