4 # Setup script fuer die Nutzung der fancy-LaTeX Umgebung oder
5 # der Label-Print erweiterung (lp) in LX-Office-erp.
6 # Welches Setup ist von der Position innerhalb des Dateisystems abhaengig.
7 # Das Script kann auch nach erfolgtem Setup erneut aufgerufen werden
15 # Revision 0.2 (13.02.2011) add lp
16 # setup add determination of company data
17 # Revision 0.1 (19.12.2010) initial script create
22 DB_AUTH='../../config/lx_office.conf'
35 label_nn_brief_a4_de.tex
55 ../../config/lx_office.conf.default
83 BASE_DIR=`readlink -f $0 | sed 's/setup\.sh$//'`
85 MODUL=`basename ${BASE_DIR}`
86 export TEXINPUTS=".:${BASE_DIR}:"
93 USAGE="\n\n setup LaTeX templates for lx-office erp (www.lx-office.org)
94 \n\n USAGE: ./`basename $0` [OPTION] \n
99 OPTIONS for trouble shooting:\n\n
100 -D don't connect to any database\n
101 -C no colored output (don't use any terminal escape character)\n
103 RECOMMENDED USE ./setup.sh
112 while getopts "hDC" flag
132 ##########################################################################
134 ##########################################################################
136 # Dies ist ein Script zum Einrichten von LaTeX Templates #
137 # (fancy-latex (f-tex)) oder (label-print (lp) fuer #
139 # lx-office erp (www.lx-erp.org) #
141 # Obwohl LX-Office sich an deutschsprachige Anwender richtet ist dieses #
142 # Script in Englisch und soll auch nicht uebersetzt werden. #
144 # * es richtet sich an System-Administratoren #
145 # * da es das Script nur in einer Sprache gibt, ist es viel leichter #
146 # bei Fehlern und Fehlermeldungen aus dem Script selbst, im Internet #
147 # nach Loesungen zu suchen. #
149 ##########################################################################
151 # This script provides an easy to use setup for the fancy LaTeX #
152 # environment of lx-office erp (templates/f-tex) #
154 # Normal use is to run ./setup.sh without any parameter. You may also #
159 # The script tries to be as save as possible to avoid unwanted file #
160 # overwriting by being very interactive. It's designed to be invoked #
161 # multiple times inside the same template directory. So it is possible #
162 # to rerun the script if there are updates available or after you break #
163 # your LaTeX templates by any changes. #
165 # I recommend to backup your installation and database before you run #
168 # ANYHOW: I do not take responsibility for any harm initiated by this #
169 # script. (Wulf Coulmann -- scripts_at_gpl.coulmann.de) #
171 ##########################################################################
176 QUESTION=' I understand the above warnings [YES/NO/Q]:'
178 echo -n "${QUESTION} "
181 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
183 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
186 until [ "${ANSWER}" = YES ]\
187 || [ "${ANSWER}" = NO ] \
188 || [ "${ANSWER}" = N ] \
189 || [ "${ANSWER}" = n ] \
190 || [ "${ANSWER}" = q ] \
191 || [ "${ANSWER}" = Q ] ; do
192 echo -n "${QUESTION} "
193 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
195 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
204 echo ' script aborted by user input'
210 FEEDBACK='################################\n # FEEDBACK:\n
217 echo '[error]' ...... $1 ...... '[terminate script]'
222 [ "${NO_COLOR}" = 1 ] || echo -ne "${MARK}"
224 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
231 until [ "${ANSWER}" = y ]\
232 || [ "${ANSWER}" = Y ] \
233 || [ "${ANSWER}" = j ] \
234 || [ "${ANSWER}" = J ] \
235 || [ "${ANSWER}" = n ] \
236 || [ "${ANSWER}" = N ] \
237 || [ "${ANSWER}" = Q ] \
238 || [ "${ANSWER}" = q ] ; do
239 echo -n "${QUESTION}"
251 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
253 echo ' script aborted by user input'
259 function latex_pack_check {
260 echo ' -> search LaTeX package '$1' '
262 if [ ! `kpsewhich ${1}.sty` ] ; then
264 echo " can't find package ${1}"
265 echo " on debian systems you may install apt-file"
266 echo " aptitude install apt-file"
267 echo " apt-file update"
268 echo " apt-file search ${1}.sty"
269 echo " this will show which package contains the needet LaTeX .sty file"
270 echo " on other systems, please refer to their documentation on how to "
271 echo " find matching packages."
273 echo " If you are done, rerun this script"
274 echo " [unsatisfied dependencies]' ...... ${1} ...... [terminate script]"
282 function check_accepted_names {
283 echo ' -> check for suspect characters in '${2}
284 echo -n ${1} | egrep '[^-_\.!A-Za-z0-9]' && echo ' [suspect characters found] in ... '${2}' ... [terminate script]' && exit 72
288 echo ' -> check for suspect characters in '${2}
289 echo -n ${1} | egrep '[^0-9]' && echo ' [suspect characters found] in ... '${2}' ... [terminate script]' && exit 72
292 function create_file {
294 if [ "${1}" = ln ] ;then
296 echo -n ' -> try to create symbolic link '${3}
297 if [ -e "${3}" ] ; then
298 if [ -L "${3}" ] ; then
299 if [ "`ls -l ${3} | awk '{print $10}'`" = "${2}" ]; then
300 echo ' ... symbolic link already exists, nothing to do!'
303 echo ' ... symbolic link with different target exist!'
306 echo ' [d] delete and replace the current link'
307 echo ' [m] move current link to '${3}.${TIME}.old
308 echo ' [s] skip -- leave it as it is'
309 echo ' [q] abort setup.sh'
310 QUESTION=' what do do? [d/m/s/q]: '
312 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
314 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
315 until [ "${ANSWER}" = D ] \
316 || [ "${ANSWER}" = d ] \
317 || [ "${ANSWER}" = m ] \
318 || [ "${ANSWER}" = s ] \
319 || [ "${ANSWER}" = q ] ; do
320 echo -n "${QUESTION}"
326 rm -f ${3} || error ' unable to delete symbolic link '${3}
329 mv -f ${3} ${3}.${TIME}.old || error ' unable to move symbolic link '${3}
332 echo ' as you decide, we leave it as it is!'
336 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
338 echo ' script aborted by user input'
344 echo ' ... file already exists where I tried to create a symbolic link!'
347 echo ' [S] show the file (exit file display with "q")'
348 echo ' [m] move current file to '${3}.${TIME}.old
349 echo ' [d] delete and replace the file with symbolic link'
350 echo ' [s] skip -- leave it as it is'
351 echo ' [q] abort setup.sh'
352 QUESTION='what to do? [S/d/m/s/q]:'
353 echo -en " ${QUESTION} "
354 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
356 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
357 until [ "${ANSWER}" = S ] \
358 || [ "${ANSWER}" = d ] \
359 || [ "${ANSWER}" = m ] \
360 || [ "${ANSWER}" = s ] \
361 || [ "${ANSWER}" = q ] ; do
362 echo -n " ${QUESTION} "
373 create_file "${1}" "${2}" "${3}"
377 mv -f ${3} ${3}.${TIME}.old || error ' unable to move file '${3}
380 rm -f ${3} || error ' unable to delete file '${3}
383 echo ' as you decide, we leave it as it is!'
387 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
389 echo ' script aborted by user input'
395 if [ "${DO}" = "1" ] ;then ln -s "${2}" "${3}" || error ' failed to create symbolic link '${3} ; fi
396 [ "${DO}" = "1" ] && echo \ \ ${OK}
399 if [ "${1}" = cp ] ;then
400 echo -n ' -> try to copy file '${3}
402 if [ -e "${3}" ] ; then
403 echo ' ... file already exists!'
404 diff "${2}" "${3}" >/dev/null
405 if [ "$?" = 0 ] ; then
406 echo ' files are equal, we leave it as it is!'
411 echo ' [D] show a diff between the new and current file'
412 echo ' [m] move current file to '${3}.${TIME}.old
413 echo ' [d] delete and replace with new file'
414 echo ' [s] skip -- leave it as it is'
415 echo ' [q] abort setup.sh'
416 QUESTION='what to do? [D/m/d/s/q]:'
417 echo -en " ${QUESTION} "
418 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
420 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
421 until [ "${ANSWER}" = D ] \
422 || [ "${ANSWER}" = d ] \
423 || [ "${ANSWER}" = m ] \
424 || [ "${ANSWER}" = s ] \
425 || [ "${ANSWER}" = q ] ; do
426 echo -n " ${QUESTION} "
434 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
435 echo '---------------------------------------'
436 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
437 diff -C 3 "${2}" "${3}"
438 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
439 echo '---------------------------------------'
440 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
443 create_file "${1}" "${2}" "${3}"
446 mv -f ${3} ${3}.${TIME}.old || error ' unable to move file '${3}
449 rm -f ${3} || error ' unable to delete file '${3}
452 echo ' as you decide, we leave it as it is!'
456 [ "${NO_COLOR}" = 1 ] || echo -ne "${UNMARK}"
458 echo ' script aborted by user input'
464 if [ "${DO}" = "1" ] ;then cp "${2}" "${3}" || error ' failed to copy '${3} ; fi
465 [ "${DO}" = "1" ] && echo \ \ ${OK}
470 function create_mydata {
474 NODATA=' did not get a value corresponding to your template dir'
477 SELECT regexp_replace( u1.cfg_value, E'\n' ,E'\\\\\\\\\\\\' || E'\n')
478 FROM auth.user_config u1, auth.user_config u2
479 WHERE u1.user_id = u2.user_id
480 AND u1.cfg_key = '"${DB}"'
481 AND u2.cfg_key = 'templates'
482 AND u2.cfg_value = 'templates/"${TEMP_DIR}"'
483 ORDER BY u1.cfg_value DESC
494 if [ ! `psql --pset tuples_only -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}"`"" ] ; then
496 SELECT regexp_replace( u1.cfg_value, E'\n' ,E'\\\\\\\\\\\\' || E'\n')
497 FROM auth.user_config u1, auth.user_config u2
498 WHERE u1.user_id = u2.user_id
499 AND u1.cfg_key = 'taxnumber'
500 AND u2.cfg_key = 'templates'
501 AND u2.cfg_value = 'templates/"${TEMP_DIR}"'
502 ORDER BY u1.cfg_value DESC
518 ANSWER=`psql --pset tuples_only -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}"` || error "unable to connect to auth db"
519 if [ ! "${VALUE}" ] ; then
520 echo ' please fix this later'
523 echo ' found: '${ANSWER}
526 if [ ! "${2}" ] && [ ${1} = "employeecountry" ] ; then
529 echo ' please fix this later'
534 echo -e "\0134"'newcommand{'"\0134"${VALUE}'}{'${PRE}${ANSWER}'}' >> mydata.tex
538 function read_db_conf {
540 perl -e 'use Config::Std;
541 read_config "'${DB_AUTH}'.default" => my %config_default;
542 my $val_default = $config_default{"authentication/database"}{'${1}'};
543 read_config "'${DB_AUTH}'" => %config;
544 my $val = $config{"authentication/database"}{'${1}'} if $config{"authentication/database"}{'${1}'};
557 # check for dependencies
558 echo -n ' -> search kpsewhich '
559 which kpsewhich >/dev/null
560 [ "$?" = 0 ] || error 'unable find programm "kpsewhich" -- is there a propper installed LaTeX? (on debian: aptitude install texlive-base-bin)'
563 if [ "${MODUL}" = "f-tex" ] ; then
564 echo ' -> search LaTeX documentclass scrlttr2'
566 if [ ! `kpsewhich scrlttr2.cls` ] ; then
568 echo " can't find documentclass scrlttr2"
569 echo " on debian systems you may install it by"
570 echo " aptitude install texlive-latex-recommended"
571 echo " on other systems, please refer to their documentation how to find"
572 echo " matching packages."
574 echo " If you are done, rerun this script"
575 echo " [unsatisfied dependencies]' ...... documentclass scrlttr2 ...... [terminate script]"
580 elif [ "${MODUL}" = "lp" ] ; then
581 echo ' -> search LaTeX package ticket and check vor needed version '
583 HOLD_TEXINPUTS=${TEXINPUTS}
585 if [ `kpsewhich ticket.sty` ] ; then
586 grep rowmode `kpsewhich ticket.sty` > /dev/null
587 if [ "$?" -gt "0" ] ;then
588 FILE_LIST_LP=${FILE_LIST_LP}" ticket.sty"
589 echo \ \ "your version of LaTeX Package ticket does not support rowmode - we use our own ticket.sty"
590 echo \ \ \ \ \ \ "ticket.sty supports option rowmode from version v0.4b"
591 echo \ \ \ \ \ \ ${OK}
594 FILE_LIST_LP=${FILE_LIST_LP}" ticket.sty"
595 echo \ \ "can't find LaTeX Package ticket, but we use our own ticket.sty because we need version => v0.4b"
596 echo \ \ \ \ \ \ "ticket.sty supports option rowmode from version v0.4b"
597 echo \ \ \ \ \ \ ${OK}
599 export TEXINPUTS=${HOLD_TEXINPUTS}
601 error "no valid install modul - is the install script inside ~/templates/f-tex or ~/templates/lp ?"
604 for PACK in `grep usepackage ${BASE_DIR}/*.tex ${BASE_DIR}/*.sty ${BASE_DIR}/*.lco |awk -F '{' '{print $2}'|awk -F '}' '{print $1}'| sort | uniq`; do
605 latex_pack_check ${PACK}
609 # decide the installation target (template directory)
610 echo -n ' -> cd to base directory: '${BASE_DIR}' '
612 cd ${BASE_DIR} || error "unable to change directory"
617 echo ' -> check if we are inside an lxo installation'
619 if [ ! -e ../../SL/Form.pm ] ; then
621 dpkg -l | grep lx-office-erp | egrep '^ii'
622 if [ "$?" = 0 ] ; then
623 echo ' seams like this is a Debian-package'
624 DB_AUTH='/etc/lx-office-erp/lx_office.conf'
627 /usr/lib/lx-office-erp/SL/Form.pm
628 /etc/lx-office-erp/lx_office.conf.default
629 /usr/share/doc/lx-office-erp/changelog
632 CHK_RAWNUMBER_PATCH='
633 /usr/lib/lx-office-erp/SL/DO.pm
634 /usr/lib/lx-office-erp/SL/IS.pm
635 /usr/lib/lx-office-erp/SL/OE.pm
642 for now in ${LXO_DETERMINE} ; do
643 [ -e ${now} ] || error 'missing '${now}', do not run this script outside an lx-office installation!. Is setup.sh located inside an lxo installation in templates/'${MODUL}'?'
647 if [ "${MODUL}" = "f-tex" ] ; then
648 echo ' -> search raw numbers patch '
649 RAW_NUM=`egrep -oh '\{[^{]*_nofmt\}' ${CHK_RAWNUMBER_PATCH} |wc -l`
651 if [ "${RAW_NUM}" -lt 20 ] ; then
652 echo ' did not find the raw_number values'
654 egrep -oh '\{[^{]*_nofmt\}' ${CHK_RAWNUMBER_PATCH}
655 echo ' seems like you added fancy LaTeX separate and needed raw_number values are missing'
656 echo ' this is already part of the dev-source code.'
657 echo ' please use this script in the environment you got it from'
658 error 'missing raw_number values'
664 if [ ${DATABASE} = 1 ] ; then
666 echo ' -> request Auth-DB '
667 [ -r ${DB_AUTH} ] || [ -r ${DB_AUTH}.default ] || error "unable to read ${DB_AUTH} or ${DB_AUTH}.default -- you must be able to read db credentials"
669 export PGDATABASE=`read_db_conf db`
670 check_accepted_names ${PGDATABASE} database_name
671 export PGPASSWORD=`read_db_conf password`
672 check_accepted_names ${PGPASSWORD} database_pw
673 export PGUSER=`read_db_conf user`
674 check_accepted_names ${PGUSER} database_user
675 export PGPORT=`read_db_conf port`
676 [ "${#PGPORT}" -lt 1 ] && PGPORT=5432
677 check_int ${PGPORT} database_port
678 export PGHOST=`read_db_conf host`
679 [ "${#PGHOST}" -lt 1 ] && PGHOST=localhost
680 check_accepted_names ${PGHOST} database_host
684 substring(cfg_value from E'[^/]*$') as template_dir
685 FROM auth.user_config
686 WHERE cfg_key = 'templates'
691 echo ' -> search active template dirs '
693 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
695 psql --pset tuples_only -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}" || error "unable to connect to auth db"
697 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
698 echo ' I found the above listed template directorys in '`mark '[lxo-home]/templates'`' by requesting your user configuration.'
699 echo ' in database '`mark "${PGDATABASE}"`'.'
702 echo ' Type in which template directory to use (by typing in a name)'
703 echo ' * if template_dir does not exist, it will be created'
704 echo ' * template_dir must also be configured in your user administration'
705 echo ' to make it active.'
707 echo -en ' type name of template dirctory: '
708 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
710 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
713 [ "${#TEMP_DIR}" -gt 0 ] || error 'no value for template dir provided '
716 if [ -d "../${TEMP_DIR}" ] ; then
717 MV_DIR=${TEMP_DIR}.${TIME}.old
719 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
720 ls -lah ../${TEMP_DIR}
721 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
723 echo ' the directory already exists and contains the above listed files'
725 echo -e ' - move the directory to '`mark "templates/${MV_DIR}"`' and create a empty one, or'
726 echo ' - install the templates in the existing directory by interactive overwriting existing files'
728 ask_yn ' move templates/'${TEMP_DIR}' to templates/'${MV_DIR}'? [y/n/q]: '
732 if [ "${ANSWER}" = y ] ; then
733 echo ' -> check for permission to move template directory '
734 mv -i ../${TEMP_DIR} ../${MV_DIR} || error "unable to move directory "
735 echo -n ' -> original directory moved to '${MV_DIR}
738 if [ "${ANSWER}" = n ] ; then
739 echo ' -> check for permission to write in template directory [lxo-home]/templates/'${TEMP_DIR}
740 [ -w ../${TEMP_DIR} ] || error "no permission to write directory "
747 if [ ! -d "../${TEMP_DIR}" ] ; then
748 echo -n ' -> check for permission to create new template directory '
749 mkdir "../"${TEMP_DIR} || error "unable to write to `echo ${PWD} | sed 's/\/'${MODUL}'$//'` -- you must be able to write in ~/templates "
751 echo -n ' -> '${TEMP_DIR}' created'
755 echo -n ' -> cd to template directory: '${TEMP_DIR}' '
757 cd ../${TEMP_DIR} || error "unable to change directory"
762 if [ -e mydata.tex ] ;then
763 echo ' -> check mydata.tex'
764 grep koma ./mydata.tex && FEEDBACK=${FEEDBACK}' # looks like a DEPRECATED mydata.tex -- please compare to f-tex/mydata.tex.example \n'
765 for now in ${MY_DATA} ; do
766 grep ${now} ./mydata.tex || FEEDBACK=${FEEDBACK}' # missing '${now}' in mydata.tex -- please compare to f-tex/mydata.tex.example \n'
769 echo -e \ \ "your current mydata.tex looks like"
770 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
772 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
775 if [ ${DATABASE} = 1 ] ; then
776 # mydata voodooo goes here
779 u1.cfg_value as company,
780 u2.cfg_value as address,
783 u5.cfg_value as texnumber,
784 u6.cfg_value as co_ustid
793 u1.user_id = u2.user_id and
794 u2.user_id = u3.user_id and
795 u3.user_id = u4.user_id and
796 u4.user_id = u5.user_id and
797 u5.user_id = u6.user_id and
798 u1.cfg_key = 'company' and
799 u2.cfg_key = 'address' and
800 u3.cfg_key = 'tel' and
801 u4.cfg_key = 'fax' and
802 u5.cfg_key = 'taxnumber' and
803 u6.cfg_key = 'co_ustid'
814 # [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
816 # psql -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}" || error "unable to connect to auth db"
818 # [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
819 echo ' There is no mydata.tex, we try to create it'
820 echo ' please answer the following questions'
821 echo -n ' - country your company is located eg:"Deutschland" : '
822 create_mydata employeecountry
823 echo ' - owner of the bankaccount for label print'
824 echo ' used for "pay on delivery (Nachnahme)"'
825 echo -n ' type ~ instead of blanks eg: "Herbert~Wichtig" : '
826 create_mydata labelcompanyname
827 echo ' - name of the bank for label print'
828 echo ' used for "pay on delivery (Nachnahme)"'
829 echo -n ' type ~ instad of blanks eg: "Ensifera~Bank" : '
830 create_mydata labelbankname
831 echo ' - bank account number for label print'
832 echo ' used for "pay on delivery (Nachnahme)"'
833 echo -n ' no blanks eg: "123456789" : '
834 create_mydata labelbankcode
835 echo ' - bank code (BLZ) for label print'
836 echo ' used for "pay on delivery (Nachnahme)'
837 echo -n ' no blanks eg: "10010010" : '
838 create_mydata labelbankaccount
839 echo ' - company name for dokuments'
840 echo ' used for invoice, sales_quotation, etc.'
841 echo -n ' eg: "Die globalen Problemlöser" : '
842 create_mydata MYfromname company
843 echo ' - company name second row for documents'
844 echo ' used for invoice, sales_quotation, etc.'
845 echo -n ' eg: "Gesellschaft für anderer Leute Sorgen mbH" : '
846 create_mydata MYaddrsecrow
847 echo ' - legal form for documents'
848 echo ' used for invoice, sales_quotation, etc.'
849 echo ' eg: "Handelsregister: HRA 123456789" : '
850 echo -n ' or: "Inhaber Herbert Wichtig" : '
851 create_mydata MYrechtsform
852 echo ' - company address for documents'
853 echo ' used for invoice, sales_quotation, etc.'
854 echo ' multirow, type \\ as row dilimiter '
855 echo -n ' eg: "Hauptstraße 5\\12345 Hier" : '
856 create_mydata MYfromaddress address
857 echo ' - tel for documents'
858 echo ' used for invoice, sales_quotation, etc.'
859 echo -n ' eg: "Tel: +49 (0)12 3456780" : '
860 create_mydata MYfromphone tel
861 echo ' - fax for documents'
862 echo ' used for invoice, sales_quotation, etc.'
863 echo -n ' eg: "Fax: +49 (0)12 3456781" : '
864 create_mydata MYfromfax fax
865 echo ' - email for documents'
866 echo ' used for invoice, sales_quotation, etc.'
867 echo -n ' eg: "mail@g-problemloeser.com" : '
868 create_mydata MYfromemail
869 echo ' - signatur for documents'
870 echo ' used for invoice, sales_quotation, etc.'
871 echo -n ' eg: "Herbert Wichtig - Geschäftsführer" : '
872 create_mydata MYsignature
873 echo ' - tax number for documents'
874 echo ' used for invoice, sales_quotation, etc.'
875 echo ' it is common to use ustid but if you have none'
876 echo ' type in your main tax number'
877 echo ' eg: "UstID: DE 123 456 789" : '
878 echo -n ' or: "StrNr: 12/345/6789" : '
879 create_mydata MYustid co_ustid
880 echo ' - bank account for documents'
881 echo ' used for invoice, sales_quotation, etc.'
882 echo ' multirow, type \\ as row delimiter '
883 echo -n ' eg: "Bankverbindung\\Ensifera Bank\\Kto 1234567800\\BLZ 123 456 78" : '
884 create_mydata MYfrombank
886 # damn escaping -- gnarf
887 perl -pi -e 's/([^\$\{])\\/$1\\\\/g' mydata.tex
888 perl -pi -e 's/([\&\%])/\\$1/g' mydata.tex
890 cp ../f-tex/mydata.tex.example mydata.tex
891 FEEDBACK=${FEEDBACK}' # I generate a mydata.tex please edit this file to match to your needs \n'
893 FEEDBACK=${FEEDBACK}' # I generate a mydata.tex please edit this file to match to your needs \n'
897 if [ "${MODUL}" = "f-tex" ] ; then
898 # search for installed languages
899 if [ ${DATABASE} = 1 ] ; then
902 u1.cfg_value || ';' ||
903 u2.cfg_value || ';' ||
904 u3.cfg_value || ';' ||
905 u4.cfg_value || ';' ||
914 u1.user_id = u2.user_id and
915 u2.user_id = u3.user_id and
916 u3.user_id = u4.user_id and
917 u4.user_id = u5.user_id and
918 u1.cfg_key = 'dbname' and
919 u2.cfg_key = 'dbhost' and
920 u3.cfg_key = 'dbport' and
921 u4.cfg_key = 'dbuser' and
922 u5.cfg_key = 'dbpasswd'
931 echo ' -> try to determine aktive languages ....'
932 echo ' -> search database '${PGDATABASE}' to find lxo-erp databases ....'
934 DBS=`psql --pset tuples_only -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}"` || error "unable to connect to auth db"
936 for db in ${DBS} ; do
938 PGDATABASE=`echo -n ${db} | awk -F ';' '{print $1}'`
939 echo -e ' -> prepare to request db '`mark ${PGDATABASE}`
940 check_accepted_names ${PGDATABASE} database_name
941 PGHOST=`echo -n ${db} | awk -F ';' '{print $2}'`
942 [ "${#PGHOST}" -lt 1 ] && PGHOST=localhost
943 check_accepted_names ${PGHOST} database_host
944 PGPORT=`echo -n ${db} | awk -F ';' '{print $3}'`
945 [ "${#PGPORT}" -lt 1 ] && PGPORT=5432
946 check_int ${PGPORT} database_port
947 PGUSER=`echo -n ${db} | awk -F ';' '{print $4}'`
948 check_accepted_names ${PGUSER} database_user
949 PGPASSWORD=`echo -n ${db} | awk -F ';' '{print $5}'`
950 check_accepted_names ${PGPASSWORD} database_pw
951 DELCHECK=`echo -n ${db} | awk -F ';' '{print $6}'`
952 [ "${#DELCHECK}" = 0 ] || error 'field delimiter conflict: there may be a ";" in one of your database definitions (db/host/port/user/pw)'
953 SQL="SELECT template_code FROM language ;"
955 RES=`psql --pset tuples_only -h "${PGHOST}" -U "${PGUSER}" "${PGDATABASE}" -c "${SQL}"` || error "unable to connect to db "${PGDATABASE}
956 echo -e ' -> found '`mark "${RES}"`
958 LANGS=${LANGS}' '${RES}
961 LANGS=`echo ${LANGS} | sed 's/\ /\n/g'|sort | uniq`
962 echo ' -> join language codes ...'
965 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
967 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
969 echo ' I found the above listed language template_codes (see: System -> Languages -> List Languages)'
970 echo ' - you may add more template_codes by type in a [space] seperated list (e.g.: ru it fr)'
971 echo ' - or you may replace it with your own values by type in a [space] seperated list (e.g.: ru it fr)'
972 ask_yn ' add template_codes? [y/n/q]: '
974 if [ "${ANSWER}" = y ] ; then
975 echo -n ' type [space] seperated template_code list to add to current values: '
976 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
978 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
979 echo -n ' list of template_codes is now: '
980 LANGS=${LANGS}' '${TMP_CO}
981 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
983 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
988 ask_yn ' replace the current template_codes? [y/n/q]: '
990 if [ "${ANSWER}" = y ] ; then
991 echo -n ' type [space] seperated template_code list to replace current values: '
992 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
994 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
995 echo -n ' list of template_codes is now: '
997 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
999 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
1004 echo -n ' type [space] seperated template_code list (see: System -> Languages -> List Languages eg: de en fr): '
1005 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
1007 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
1008 echo -n ' list of template_codes is now: '
1010 [ "${NO_COLOR}" = 1 ] || echo -ne ${MARK}
1012 [ "${NO_COLOR}" = 1 ] || echo -ne ${UNMARK}
1018 echo -e ' your current language template_codes are: '`mark "${LANGS}"`
1022 # copy files and create links
1026 for now in ${FILE_LIST_FTEX} ; do
1027 create_file cp ../f-tex/${now} ${now}
1030 for now in ${LANGS} ; do
1031 echo -n ' -> check if language code '${now}' is present in translations.tex'
1032 egrep '^[^%]*\\IfEndWith{\\docname}{_'${now}'}' translations.tex > /dev/null
1033 if [ "$?" -gt 0 ] ;then
1034 HINT=' edit '${TEMP_DIR}'/translations.tex -- no representation of template_code '${now}
1035 echo ' [warning] '${HINT}
1036 FEEDBACK=${FEEDBACK}' # '${HINT}'\n'
1042 for doc in ${DOC_TYPE_FTEX} ; do
1043 create_file ln ./letter.tex ./${doc}.tex
1044 for now in ${LANGS} ; do
1045 create_file ln ./letter.tex ./${doc}_${now}.tex
1049 create_file ln ./sample_head.pdf ./letter_head.pdf
1050 create_file ln ./sample.lco ./letter.lco
1056 if [ "${MODUL}" = "lp" ] ; then
1058 for now in ${FILE_LIST_LP} ; do
1059 create_file cp ../lp/${now} ${now}
1066 echo -en ' '${FEEDBACK}
1067 echo -e ' ################################'
1069 echo ' If there are warnings listed in the feedback box above'
1070 echo ' this is totally ok if you know what you do'
1072 echo ' done -> enjoy'
1073 echo ' ### please check "settings" in '`pwd`'letter.lco '