#!/bin/bash ################################################################################ # Microsoft TrueType core fonts installation helper for Fedora Linux # # This script is installing the fonts without any untrustworthy 3rd-party RPMs # or build-hazzle. I think it is useful because the MS core web fonts are not # included in the main repositories (licensing issues). And (IMHO), it is a bit # extreme to build a package on your own just to install a few fonts. This # script is inspired by # . # # Tested on the following Fedora versions: # - Fedora 15 Lovelock # # I don't have the time to test *every* version out there. Therefore it does not # mean that this script does not work if your version is not listed above. Just # try it out and check for an update of this script after a new version of # Fedora is released: # # # Usage: # 1) Call this script with SUPERUSER privileges (->su -c, sudo ...) # 2) If something fails, correct the thing which prevents the successful # execution and call it again. This script is designed in a way that # re-calling it should be no problem. # # Please note that the yum/RPM database is bypassed, so you can't uninstall # the fonts by using "yum erase/remove". But you may run the following commands # to get rid of the fonts: # 1) su -c 'rm -rf "/usr/share/fonts/msttcorefonts/"' # 2) fc-cache -fv # # Please read the MS end user license agreement (, Mirror: # ) for all the rules that govern the use of the fonts. # Anyone can download and install these fonts for their own use but there are # some things to follow. See the mentioned EULA and/or Microsoft's permissions # site and/or for details. # # # LICENSE: This file (NOT THE FONTS) is open source software (OSS) and may be # copied under certain conditions. See the links below for details or # try to contact the author(s) of this file in doubt. # # @author Andreas Haerter # @copyright 2011, Andreas Haerter # @license GPLv2 (http://www.gnu.org/licenses/gpl2.html) # @license New/3-clause BSD (http://opensource.org/licenses/bsd-license.php) # @link http://blog.andreas-haerter.com/2011/07/01/install-microsoft-core-fonts-on-fedora # @link http://blog.andreas-haerter.com/2011/07/01/install-msttcorefonts-fedora.sh # @link http://andreas-haerter.com # @link http://en.wikipedia.org/wiki/Core_fonts_for_the_Web # @link http://corefonts.sourceforge.net # @version 2011-07-01 ################################################################################ ################################################################################ # Configuration ################################################################################ #Download mirrors MSTTF_DLMIRRORS[(${#MSTTF_DLMIRRORS[@]})]="http://heanet.dl.sourceforge.net/sourceforge/corefonts/" MSTTF_DLMIRRORS[(${#MSTTF_DLMIRRORS[@]})]="http://switch.dl.sourceforge.net/sourceforge/corefonts/" MSTTF_DLMIRRORS[(${#MSTTF_DLMIRRORS[@]})]="http://dfn.dl.sourceforge.net/sourceforge/corefonts/" MSTTF_DLMIRRORS[(${#MSTTF_DLMIRRORS[@]})]="http://kent.dl.sourceforge.net/sourceforge/corefonts/" MSTTF_DLMIRRORS[(${#MSTTF_DLMIRRORS[@]})]="http://mesh.dl.sourceforge.net/sourceforge/corefonts/" #Files to download + checksums MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="andale32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="cbdc2fdd7d2ed0832795e86a8b9ee19a" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="c4db8cbe42c566d12468f5fdad38c43721844c69" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="0524fe42951adc3a7eb870e32f0920313c71f170c859b5f770d82b4ee111e970" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="arial32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="9637df0e91703179f0723ec095a36cb5" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="6d75f8436f39ab2da5c31ce651b7443b4ad2916e" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="85297a4d146e9c87ac6f74822734bdee5f4b2a722d7eaa584b7f2cbf76f478f6" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="arialb32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="c9089ae0c3b3d0d8c4b0a95979bb9ff0" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="d45cdab84b7f4c1efd6d1b369f50ed0390e3d344" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="a425f0ffb6a1a5ede5b979ed6177f4f4f4fdef6ae7c302a7b7720ef332fec0a8" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="comic32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="2b30de40bb5e803a0452c7715fc835d1" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="2371d0327683dcc5ec1684fe7c275a8de1ef9a51" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="9c6df3feefde26d4e41d4a4fe5db2a89f9123a772594d7f59afd062625cd204e" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="courie32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="4e412c772294403ab62fb2d247d85c60" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="06a745023c034f88b4135f5e294fece1a3c1b057" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="bb511d861655dde879ae552eb86b134d6fae67cb58502e6ff73ec5d9151f3384" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="georgi32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="4d90016026e2da447593b41a8d8fa8bd" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="90e4070cb356f1d811acb943080bf97e419a8f1e" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="2c2c7dcda6606ea5cf08918fb7cd3f3359e9e84338dc690013f20cd42e930301" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="impact32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="7907c7dd6684e9bade91cff82683d9d7" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="86b34d650cfbbe5d3512d49d2545f7509a55aad2" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="6061ef3b7401d9642f5dfdb5f2b376aa14663f6275e60a51207ad4facf2fccfb" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="times32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="ed39c8ef91b9fb80f76f702568291bd5" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="20b79e65cdef4e2d7195f84da202499e3aa83060" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="db56595ec6ef5d3de5c24994f001f03b2a13e37cee27bc25c58f6f43e8f807ab" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="trebuc32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="0d7ea16cac6261f8513a061fbfcdb2b5" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="50aab0988423efcc9cf21fac7d64d534d6d0a34a" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="5a690d9bb8510be1b8b4fe49f1f2319651fe51bbe54775ddddd8ef0bd07fdac9" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="webdin32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="230a1d13a365b22815f502eb24d9149b" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="2fb4a42c53e50bc70707a7b3c57baf62ba58398f" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="64595b5abc1080fba8610c5c34fab5863408e806aafe84653ca8575bed17d75a" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="verdan32.exe" MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="12d2a75f8156e10607be1eaa8e8ef120" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="f5b93cedf500edc67502f116578123618c64a42a" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="c1cb61255e363166794e47664e2f21af8e3a26cb6346eb8d2ae2fa85dd5aad96" MSTTF_DLFILES[(${#MSTTF_DLFILES[@]})]="wd97vwr32.exe" #contains tahoma in Vierwer1.cab MSTTF_CHKMD5[(${#MSTTF_CHKMD5[@]})]="efa72d3ed0120a07326ce02f051e9b42" MSTTF_CHKSHA1[(${#MSTTF_CHKSHA1[@]})]="8edf758f92513094a94e50b7826cd6f2b7696b8c" MSTTF_CHKSHA256[(${#MSTTF_CHKSHA256[@]})]="f61126a6d17b2d126a7f31b142504dce4934f7989c55f1c13c6477b3fe80b3d2" #target path MSTTF_INSTTARGETDIR="/usr/share/fonts/msttcorefonts" ################################################################################ # Process ################################################################################ #welcome user clear echo "###############################################################################" echo "# Microsoft TTF Core Fonts installation helper" echo "# Found OS: $(cat /etc/fedora-release)" echo "#" echo "# Have a look at and/or" echo "# " echo "# for more information." echo "#" echo "# Please read the end user license agreement (EULA) (, " echo "# ) and/or Microsoft's permissions site and/or" echo "# for details and" echo "# font copying plus license information." echo "#" echo "# Note: internet connection is mandatory!" echo "###############################################################################" #check: are we root? if [ $(id -u) -ne 0 ] then echo "" echo "Superuser privileges needed. E.g. call this script using 'su -c'." 1>&2 exit 1 fi echo -n "Start? [y|n]: " read INPUT if [ ! "${INPUT}" == "y" ] && [ ! "${INPUT}" == "Y" ] && [ ! "${INPUT}" == "j" ] && [ ! "${INPUT}" == "J" ] then echo "Operation canceled by user" exit 0 fi #check if required tools are installed echo "" echo "Checking if all helper programs are available (this may take some time)..." hash wget > /dev/null 2>&1 if [ $? -ne 0 ] then echo "wget is missing, trying to install it..." yum -y install wget if [ $? -ne 0 ] then echo "Could not install missing wget" 1>&2 exit 1 fi fi hash cabextract > /dev/null 2>&1 if [ $? -ne 0 ] then echo "cabextract is missing, trying to install it..." yum -y install cabextract if [ $? -ne 0 ] then echo "Could not install missing cabextract" 1>&2 exit 1 fi fi hash ttmkfdir > /dev/null 2>&1 if [ $? -ne 0 ] then echo "ttmkfdir is missing, trying to install it..." yum -y install ttmkfdir if [ $? -ne 0 ] then echo "Could not install missing ttmkfdir" 1>&2 exit 1 fi fi echo "All needed programs found. Let's go!" echo "" #Download MSTTF_TMPDIR=$(mktemp -d "/tmp/msttf.XXXXXXXXXXXXX") #prevent symlink race condition... RND=${#MSTTF_DLMIRRORS[@]} #we need this temp var, [@] would not work (-> subshell problem: http://www.tldp.org/LDP/abs/html/subshells.html#PARVIS) RND=$((RANDOM % ${RND})) MSTTF_DLMIRROR=${MSTTF_DLMIRRORS[${RND}]} echo "Setting download mirror to ${MSTTF_DLMIRROR}" echo "" DLTRY=0 for ((i=0; i < ${#MSTTF_DLFILES[@]}; i++)) do echo "Downloading '${MSTTF_DLFILES[${i}]}'..." mkdir -p "${MSTTF_TMPDIR}" > /dev/null 2>&1 wget -nv --timeout=30 "${MSTTF_DLMIRROR}${MSTTF_DLFILES[${i}]}" -O "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}" if [ $? -ne 0 ] then echo "Download failed, trying another mirror..." RND=${#MSTTF_DLMIRRORS[@]} #we need this temp var, [@] would not work (-> subshell problem: http://www.tldp.org/LDP/abs/html/subshells.html#PARVIS) RND=$((RANDOM % ${RND})) MSTTF_DLMIRROR=${MSTTF_DLMIRRORS[${RND}]} echo "Setting download mirror to ${MSTTF_DLMIRROR}" sleep 3 wget -nv --timeout=90 "${MSTTF_DLMIRROR}${MSTTF_DLFILES[${i}]}" -O "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}" if [ $? -ne 0 ] then echo "Download of ${MSTTF_DLFILES[${i}]} failed again, please check your connection and try again." 1>&2 #clean up rm --preserve-root -rf "${MSTTF_TMPDIR}/" > /dev/null 2>&1 exit 1 fi fi echo "Download was successful, checking file..." MSTTF_TMPMD5=$(md5sum "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}") MSTTF_TMPMD5=$(basename ${MSTTF_TMPMD5}) MSTTF_TMPSHA1=$(sha1sum "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}") MSTTF_TMPSHA1=$(basename ${MSTTF_TMPSHA1}) MSTTF_TMPSHA256=$(sha256sum "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}") MSTTF_TMPSHA256=$(basename ${MSTTF_TMPSHA256}) if [ ! "${MSTTF_TMPMD5}" == "${MSTTF_CHKMD5[${i}]}" ] || [ ! "${MSTTF_TMPSHA1}" == "${MSTTF_CHKSHA1[${i}]}" ] || [ ! "${MSTTF_TMPSHA256}" == "${MSTTF_CHKSHA256[${i}]}" ] then echo "${MSTTF_DLFILES[${i}]} is corrupted, trying again (using random mirror)..." RND=${#MSTTF_DLMIRRORS[@]} #we need this temp var, [@] would not work (-> subshell problem: http://www.tldp.org/LDP/abs/html/subshells.html#PARVIS) RND=$((RANDOM % ${RND})) MSTTF_DLMIRROR=${MSTTF_DLMIRRORS[${RND}]} echo "Setting download mirror to ${MSTTF_DLMIRROR}." sleep 3 let DLTRY=${DLTRY}+1 if [ ${DLTRY} -gt 1 ] then echo "${MSTTF_DLFILES[${i}]} is corrupted again, please check your connection and try again." 1>&2 echo "Expected MD5: ${MSTTF_CHKMD5[${i}]}" 1>&2 echo "Found MD5: ${MSTTF_TMPMD5}" 1>&2 echo "Expected SHA1: ${MSTTF_CHKSHA1[${i}]}" 1>&2 echo "Found SHA1: ${MSTTF_TMPSHA1}" 1>&2 echo "Expected SHA256: ${MSTTF_CHKSHA256[${i}]}" 1>&2 echo "Found SHA256: ${MSTTF_TMPSHA256}" 1>&2 #clean up rm --preserve-root -rf "${MSTTF_TMPDIR}/" > /dev/null 2>&1 exit 1 fi let i=${i}-1 else echo "${MSTTF_DLFILES[${i}]} is OK, going on." DLTRY=0 fi echo "" done #extract mkdir -p "${MSTTF_TMPDIR}/archive-contents" > /dev/null 2>&1 mkdir -p "${MSTTF_TMPDIR}/fonts" > /dev/null 2>&1 cd "${MSTTF_TMPDIR}" for ((i=0; i < ${#MSTTF_DLFILES[@]}; i++)) do cabextract --lowercase --directory="${MSTTF_TMPDIR}/archive-contents" "${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}" if [ $? -ne 0 ] then echo "Could not extract contents of '${MSTTF_TMPDIR}/${MSTTF_DLFILES[${i}]}'." 1>&2 exit 1 fi done #wd97vwr32.exe contains tahoma within Vierwer1.cab cabextract --lowercase --directory="${MSTTF_TMPDIR}/archive-contents" "${MSTTF_TMPDIR}/archive-contents/viewer1.cab" if [ $? -ne 0 ] then echo "Could not extract contents of '${MSTTF_TMPDIR}/archive-contents/viewer1.cab'." 1>&2 exit 1 fi cp "${MSTTF_TMPDIR}/archive-contents/"*.ttf "${MSTTF_TMPDIR}/fonts" if [ $? -ne 0 ] then echo "It seems that there are no TTF files in '${MSTTF_TMPDIR}/archive-contents/'?!" 1>&2 exit 1 fi #ttmkfdir is a tool to create valid and complete fonts.dir files from TrueType fonts echo "Creating fonts.dir and font.scale file..." cd "${MSTTF_TMPDIR}/fonts" ttmkfdir > fonts.dir if [ $? -ne 0 ] then echo "Could not create fonts.dir and font.scale." 1>&2 exit 1 fi echo "Installing fonts..." mkdir -p "${MSTTF_INSTTARGETDIR}" > /dev/null 2>&1 if [ $? -ne 0 ] then echo "Could not create '${MSTTF_INSTTARGETDIR}' dir." 1>&2 exit 1 fi cp -f "${MSTTF_TMPDIR}/fonts/"*.ttf "${MSTTF_TMPDIR}/fonts/fonts.dir" "${MSTTF_TMPDIR}/fonts/fonts.scale" "${MSTTF_INSTTARGETDIR}" if [ $? -ne 0 ] then echo "Could not copy needed files into '${MSTTF_INSTTARGETDIR}'." 1>&2 exit 1 else echo "SUCCESS. Fonts installed." echo "" fi #clean up rm --preserve-root -rf "${MSTTF_TMPDIR}/" > /dev/null 2>&1 echo "Re-building the system's font cache now..." fc-cache -fv if [ $? -ne 0 ] then echo "Updating the system's font cache failed. However, the fonts were installed" 1>&2 echo "successfully. You may try to update the cache by yourtself with 'fc-cache -fv'" 1>&2 exit 1 fi #finished echo "" echo "" echo "###############################################################################" echo "# Font installation done." echo "###############################################################################" echo "You should reboot to make everything work as expected." echo -n "Reboot now ? [y|n]: " read INPUT if [ "${INPUT}" == "y" ] || [ "${INPUT}" == "Y" ] || [ "${INPUT}" == "j" ] || [ "${INPUT}" == "J" ] then echo "" echo "!!!System will reboot in 5 seconds. Press CTRL+C to prevent this!!!" echo "" sleep 5 reboot exit 0 fi exit 0