#!/bin/sh # ----------------------------------------------------- # Red Hat wrapper script for OpenOffice.org # ----------------------------------------------------- # (partially based on Mandrake wrapper script for 641c) OOVERSION= OOVERSIONRC="$HOME/.sversionrc" OOHOME="$HOME/.openoffice" # Remove any entry in .sversionrc if not already installed from RPM if [ -f "$OOVERSIONRC" ]; then oohome=$(cat $OOVERSIONRC | tr '\r' '\n' | perl -n -e "m|^OpenOffice.org ${OOVERSION}=file://(.*)$| and print \$1") if [ -n "$oohome" -a "$oohome" != "$OOHOME" ]; then cp $OOVERSIONRC $OOVERSIONRC.orig perl -ni -e "m|file://${oohome}| or print" $OOVERSIONRC fi fi # Issue a workstation-type installation for the user, if necessary if [ -d "$OOHOME" -a -e "$OOHOME/soffice" -a -e "$OOHOME/spadmin" ] ; then : else echo "Checking for existing user installation ... ... NOT FOUND" setup="/usr/lib/OpenOffice.org${OOVERSION}/program/setup" if [ -d "$OOHOME" ] then echo -n "Updating existing installation for user ... " setup="$setup -reinstall" else echo -n "Performing first-time installation for user ... " fi rm -f $OOHOME/setup $OOHOME/soffice $OOHOME/spadmin if grep -q application/vnd.s $HOME/.mime.types 2>/dev/null; then # setup adds .mime.types unconditionally sed -e '/^application\/vnd.stardivision.calc sdc$/d' \ -e '/^application\/vnd.stardivision.draw sda$/d' \ -e '/^application\/vnd.stardivision.impress sdd sdp$/d' \ -e '/^application\/vnd.stardivision.math smf$/d' \ -e '/^application\/vnd.stardivision.writer-global sgl$/d' \ -e '/^application\/vnd.stardivision.writer sdw vor$/d' \ -e '/^application\/vnd.sun.xml.calc sxc$/d' \ -e '/^application\/vnd.sun.xml.calc.template stc$/d' \ -e '/^application\/vnd.sun.xml.draw sxd$/d' \ -e '/^application\/vnd.sun.xml.draw.template std$/d' \ -e '/^application\/vnd.sun.xml.impress sxi$/d' \ -e '/^application\/vnd.sun.xml.impress.template sti$/d' \ -e '/^application\/vnd.sun.xml.math sxm$/d' \ -e '/^application\/vnd.sun.xml.writer.global sxg$/d' \ -e '/^application\/vnd.sun.xml.writer sxw$/d' \ -e '/^application\/vnd.sun.xml.writer.template stw$/d' \ $HOME/.mime.types > $HOME/.mime.types.tmp \ && mv -f $HOME/.mime.types.tmp $HOME/.mime.types fi # rename old .sversonrc [ -f $HOME/.sversionrc ] && mv -f $HOME/.sversionrc $HOME/.sversionrc.old # run the automated setup if $setup -R:/etc/openoffice/autoresponse.conf; then # make the user/work link and use "My Documents" directory #mkdir -p $HOME/"My Documents" #ln -s $HOME/"My Documents" $OOHOME/user/work ln -s $HOME $OOHOME/user/work setup_xml=$HOME/.openoffice/user/config/registry/instance/org/openoffice/Setup.xml if ! grep -q '' $setup_xml; then lang="$LC_ALL" if [ -z "$lang" ]; then lang="$LANG" fi lang=$(echo "$lang" | sed -n "s/\([a-z]*_[A-Z]*\).*/\1/p") if [ -z "$lang" ]; then lang=en_US fi cp -a $setup_xml $setup_xml.tmp sed -e '/^\ en-US\ '${lang/_/-}'\ ' $setup_xml.tmp > $setup_xml rm -f $setup_xml.tmp linguistic_xml=$HOME/.openoffice/user/config/registry/instance/org/openoffice/Office/Linguistic.xml if [ ! -f $linguistic_xml ]; then cat > $linguistic_xml < ${lang/_/-} EOF sed -n 's/^.*\(/p' \ /usr/lib/OpenOffice.org${OOVERSION}/share/config/registry/instance/org/openoffice/Office/Linguistic.xml \ >> $linguistic_xml cat >> $linguistic_xml < EOF fi fi case `LC_ALL=C xdpyinfo | grep dimensions | head -1` in *640x*pixels*|*800x*pixels*) scale=120;; *1152x*pixels*|*1024x*pixels*) scale=110;; *) scale=100;; esac common_xml=$HOME/.openoffice/user/config/registry/instance/org/openoffice/Office/Common.xml if ! grep -q '\ \ \ \ true\ true\ Andale Sans UI\ Luxi Sans\ \ \ true\ \ \ \ \ 8\ \ '$scale'\ ' $common_xml.tmp > $common_xml rm -f $common_xml.tmp fi if [ ! -f $HOME/.openoffice/user/psprint/psprint.conf ]; then # Default to paper size from locale setting case `/usr/bin/locale -k LC_PAPER | grep width` in *216) paper="Letter";; *) paper="A4";; esac lang="$LC_ALL" if [ -z "$lang" ]; then lang="$LANG" fi lang=$(echo "$lang" | sed -n "s/\([a-z]*_[A-Z]*\).*/\1/p") if [ -z "$lang" ]; then lang=en_US fi # Printer font substitution looks horrible for ISO-8859-2 # languages, since some letters are taken from the printer # fonts and accented letters in between are downloaded case "$lang" in bs*|cs*|hr*|hu*|pl*|ro*|sk*|sl*|sr*) subst=false;; *) subst=true;; esac sed -n -e '/^\[Generic Printer/,${s/\(PerformFontSubstitution=\)\(false\|true\)/\1'$subst'/;s/Command=/Command=lpr/;/^[[A-Za-z]/p;/^Command=/a\ Features=\ Copies=1\ Scale=1\ Orientation=Portrait\ PSLevel=0\ ColorDevice=0\ ColorDepth=24\ MarginAdjust=-1,-1,-1,-1\ PPD_PageSize='$paper' ;}' /usr/lib/OpenOffice.org${OOVERSION}/share/psprint/psprint.conf \ > $HOME/.openoffice/user/psprint/psprint.conf echo >> $HOME/.openoffice/user/psprint/psprint.conf sed -n -e '/^\[Generic Printer/,${s/\(PerformFontSubstitution=\)\(false\|true\)/\1'$subst'/;s/Command=/Command=\/usr\/bin\/gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="(OUTFILE)" -/;s/Generic Printer/PDF converter/;s/\(DefaultPrinter\)=1/\1=0/;/^[[A-Za-z]/p;/^Command=/a\ Features=pdf=\ Copies=1\ Scale=0\ Orientation=Portrait\ PSLevel=0\ ColorDevice=0\ ColorDepth=24\ MarginAdjust=0,0,0,0\ PPD_PageSize='$paper' ;}' /usr/lib/OpenOffice.org${OOVERSION}/share/psprint/psprint.conf \ >> $HOME/.openoffice/user/psprint/psprint.conf fi echo "... DONE" else echo "... FAILED" exit 1 fi # Don't use above by default... mv -f $HOME/.openoffice/user/psprint/psprint.conf $HOME/.openoffice/user/psprint/psprint.conf.disabled fi # Expand TrueType and Type1 font paths chkfontpath="/usr/sbin/chkfontpath" if [ -x "$chkfontpath" ]; then fontpath=$($chkfontpath | perl -ne '/[0-9]+: (.*)/ and print "$1;"') else ttf_fontpath="/usr/X11R6/lib/X11/fonts/TTF;/usr/share/fonts/default/TrueType" for fontdir in /usr/share/fonts/ttf/*; do ttf_fontpath="$ttf_fontpath;$fontdir" done type1_fontpath="/usr/X11R6/lib/X11/fonts/Type1;/usr/share/fonts/default/Type1" fontpath="$ttf_fontpath;$type1_fontpath" fi SAL_FONTPATH_USER="$fontpath;$SAL_FONTPATH_USER" # Get rid of broken Japanese fonts for now SAL_FONTPATH_USER=$(echo "$SAL_FONTPATH_USER" | sed -e "s|/usr/share/fonts/ja/TrueType;||g") # Get rid of broken Chinese fonts for now SAL_FONTPATH_USER=$(echo "$SAL_FONTPATH_USER" | sed -e "s|/usr/share/fonts/zh_TW/TrueType;||g") export SAL_FONTPATH_USER # Adjust what user interface language we want to use lang="$LC_ALL" if [ -z "$lang" ]; then lang="$LC_MESSAGES" if [ -z "$lang" ]; then lang="$LANG" fi fi lang=$(echo "$lang" | sed -n "s/\([a-z]*_[A-Z]*\).*/\1/p") lang=${lang/_/-} if [ -n "$lang" ] && \ [ -e "/usr/lib/OpenOffice.org${OOVERSION}/help/${lang%%-*}" -o \ -e "/usr/lib/OpenOffice.org${OOVERSION}/help/$lang" ]; then setup_xml=$HOME/.openoffice/user/config/registry/instance/org/openoffice/Setup.xml oldlang=`sed -n 's|^.*\([a-z]*-[A-Z]*\).*$|\1|p' $setup_xml` if [ -n "$oldlang" -a "$lang" != "$oldlang" ]; then cp -a $setup_xml $setup_xml.tmp sed 's|\(\)'$oldlang'\(\)|\1'$lang'\2|' \ $setup_xml.tmp > $setup_xml rm -f $setup_xml.tmp common_xml=$HOME/.openoffice/user/config/registry/instance/org/openoffice/Office/Common.xml case "$lang" in ja-JP) font="Kochi Gothic";; zh-TW) font="AR PL Mingti2L Big5";; zh-CN) font="ZYSong18030";; ko-KR) font="Baekmuk Dotum";; ru-RU) font="Nimbus Sans L";; *) font="Luxi Sans";; esac case "$oldlang" in ja-JP) oldfont="Kochi Gothic";; zh-TW) oldfont="AR PL Mingti2L Big5";; zh-CN) oldfont="ZYSong18030";; ko-KR) oldfont="Baekmuk Dotum";; ru-RU) oldfont="Nimbus Sans L";; *) oldfont="Luxi Sans";; esac if [ "$font" != "$oldfont" ]; then cp -a $common_xml $common_xml.tmp sed '//,/<\/Font>/{//,/<\/Substitution>/{//{//{/Andale Sans UI<\/ReplaceFont>/,/<\/FontReplacement>/{s/^\([ ]*\)'"$oldfont"'\(<\/SubstituteFont>[ ]*\)$/\1'"$font"'\2/;};};};};}' \ $common_xml.tmp > $common_xml rm -f $common_xml.tmp fi fi fi echo "Starting OpenOffice.org ..." prog="/usr/lib/OpenOffice.org${OOVERSION}/program/`basename $0 | sed 's/^oo/s/'`" [ -x $prog ] && exec $prog "$@" case "$0" in *oosetup) exec $OOHOME/setup "$@";; *oopadmin) exec $OOHOME/spadmin "$@";; *) exec $OOHOME/soffice "$@";; esac