#!/bin/sh

    # OpenOffice.orgܸƳץ for Linux ver 0.0.1
    # (C) 2002 OpenOffice.orgܥ桼. All Right Reserved.
    #
    # ΥץۡѤˡʤ餺READMEˤʤäƤ
    #ޤˡREADME˴ޤޤƤޤ

#OpenOffice.orgΥۡǥ쥯ȥ
    ooohome=$1
    echo "OpenOffice.orgۡǥ쥯ȥ : ${ooohome}"
#桼ꤷOpenOffice.orgΥۡǥ쥯ȥνü"/"ǤäˤϺ
    ooohome=`echo ${ooohome} | sed -e s/\\\/$//g`
#OpenOffice.orguserǥ쥯ȥ
    user_dir=${ooohome}/user
#OpenOffice.orguserǥ쥯ȥǡ"/"Фƥץ"\\/"ղäʸ
    Euser_dir=`echo ${user_dir} | sed -e s/\\\//\\\\\\\\\\\//g`
#OpenOffice.orgCommon.xml֤Ƥǥ쥯ȥ
    common_dir=${user_dir}/config/registry/instance/org/openoffice/Office
#OpenOffice.orgSetup.xml֤Ƥǥ쥯ȥ
    setup_dir=${user_dir}/config/registry/instance/org/openoffice
#OpenOffice.orgγƼƥץ졼Ȥ֤ǥ쥯ȥ
    template_dir=${user_dir}/template
#OpenOffice.orgγƼƥץ졼Ȥ֤ǥ쥯ȥǡ"/"Фƥץ"\\/"ղäʸ
    Etemplate_dir=`echo ${template_dir} | sed -e s/\\\//\\\\\\\\\\\//g`

#ɸǻѤե̾
    font_name=$2
    echo "ե̾ : ${font_name}"

#Common.xmlν
#
#Common.xmlοǤCommon.xml.tmp"FONT_NAME"ȤʸɸǻѤեִ̾OpenOffice.orgCommon.xml֤ǥ쥯ȥCommon.xmlȤưưǤˤCommon.xml񤭤Ƥޤ
#ޤܸޤե̾ꤵ줿ȤΤᡢiconvˤäʸɤUTF-8ѴƤ
    rm -f Common.xml
    iconv --from-code=UTF-8 --to-code=EUC-JP Common.xml.tmp | sed -e s/FONT_NAME/"$font_name"/g | iconv --from-code=EUC-JP --to-code=UTF-8 --output=Common.xml
    echo "Common.xml.tmp  Common.xml ޤ"

    mv -f Common.xml ${common_dir}
    echo "Common.xml  ${common_dir} ˥ԡޤ"

#Setup.xmlν
#
#Setup.xmlοǤSetup.xml.tmp"TEMPLATE_DIR"ȤʸƼƥץ졼Ȥ֤ǥ쥯ȥ̾ˡ"SETUP_INSTALL_DIR"ȤʸOpenOffice.orguserǥ쥯ȥִ̾OpenOffice.orgSetup.xml֤ǥ쥯ȥSetup.xmlȤưưǤˤSetup.xml˾񤭤Ƥޤ
#ޤܸޤǥ쥯ȥ̾ꤵ줿ȤΤᡢiconvˤäʸɤUTF-8ѴƤ
    rm -f Setup.xml
    iconv --from-code=UTF-8 --to-code=EUC-JP Setup.xml.tmp | sed -e s/TEMPLATE_DIR/"${Etemplate_dir}"/g -e s/SETUP_INSTALL_DIR/"${Euser_dir}"/g | iconv --from-code=EUC-JP --to-code=UTF-8 --output=Setup.xml
    echo "Setup.xml.tmp  Setup.xml ޤ"

    mv -f Setup.xml ${setup_dir}
    echo "Setup.xml  ${setup_dir} ˥ԡޤ"

#Ƽƥץ졼ȤΥԡ
#
#normal.stw,normal.stc,normal.std,normal.sxm,normalinmpress.stiOpenOffice.orgγƼƥץ졼Ȥ֤ǥ쥯ȥ˥ԡ롣    
    cp -f normal.stw ${template_dir}
    echo "normal.stw  ${template_dir} ˥ԡޤ"
    cp -f normal.stc ${template_dir}
    echo "normal.stc  ${template_dir} ˥ԡޤ"
    cp -f normal.std ${template_dir}
    echo "normal.std  ${template_dir} ˥ԡޤ"
    cp -f normal.sxm ${template_dir}
    echo "normal.sxm  ${template_dir} ˥ԡޤ"
    cp -f normalimpress.sti ${template_dir}
    echo "normalimpress.sti  ${template_dir} ˥ԡޤ"

    echo "λ"