#!/bin/bash
### BEGIN INIT INFO
# Provides:		sharp gnome fonts
# Author:		Mongi Gazelle
# Short-Description:	This script will download and install sharp fonts for UBUNTU.
### END INIT INFO
ROOT_UID=0
if grep -q "Ubuntu" /etc/issue ; then VERSION="Ubuntu"
elif grep -q "Debian" /etc/issue ; then VERSION="Debian"
else
echo "Sharpfonts is only tested on Debian and Ubuntu. If you are using an older (or newer testing) release consider changing"
exit 1
fi
# Need sudo privileges
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must have sudo privileges to run this script. Try sudo ./sharpfonts.sh"
exit $E_NOTROOT
fi
#Make sure no processes which will conflict are running
function conflict_check {
sleep 1
if ps -U root -u root u | grep "synaptic" | grep -v grep > /dev/null;
then echo "Installation didn't work. Close Synaptic first then try again.";
exit 1;
elif ps -U root -u root u | grep "update-manager" | grep -v grep > /dev/null;
then echo "Installation didn't work. Close update-manager first then try again.";
exit 1;
elif ps -U root -u root u | grep "apt-get" | grep -v grep > /dev/null;
then echo "Installation didn't work. Wait for apt-get to finish running, or exit it, then try again.";
exit 1;
elif ps -U root -u root u | grep "dpkg" | grep -v grep > /dev/null;
then
killall -9 dpkg
sleep 1
if ps -U root -u root u | grep "dpkg" | grep -v grep > /dev/null;
then echo "Installation didn't work. Exit any independant instances of dpkg";
exit 1;
fi
fi
}
conflict_check
#Start installation
echo "Installing Sharpfonts. This may take a few minutes depending on connection speed..."
echo "Starting installation"
# Download all needed fonts
echo "Installing MS fonts..."
apt-get install -y cabextract ttf-mscorefonts-installer
# Download the xml files and extract the configuration files into /etc/fonts/
echo "Downloading the xml files and extracting the configuration files into /etc/fonts/"
wget http://www.osresources.com/files/centos-windows-fonts/fontconfig.tbz
tar xvjpf fontconfig.tbz -C /etc/fonts/
rm fontconfig.tbz
echo "Installation done... Please remember to logout and login again"


