Symlinking shared libraries from a platform-specific directory
Seems like you can do the if statement to set a variable to the first part of the path, then put all the file copies at the end after that.

(Warning: My bash is kind of bad. Haven't used it for a while. I think this is how it's done though... Might need quotes around the libpath assignments?)

# this is to get PNG and JPEG support working in PIL on Ubuntu
if [ -d /usr/lib/x86_64-linux-gnu ] ; then # 64 bit ubuntu
    libpath=/usr/lib/x86_64-linux-gnu
fi

if [ -d /usr/lib/i386-linux-gnu/ ] ; then # 32 bit ubuntu
    libpath=/usr/lib/i386-linux-gnu
fi

if [ -d /usr/lib64/ ] ; then # Redhat
    libpath=/usr/lib64
fi

sudo ln -s $libpath/libfreetype.so /usr/lib/
sudo ln -s $libpath/libz.so /usr/lib/
sudo ln -s $libpath/libjpeg.so /usr/lib/