#!/bin/bash version=2.01 myname=$(basename $0) <<'DOC' = lug - create and edit TeX Local User Group web pages = Synopsis lug [options] [lug-code] lug can be used to maintain the TeX Local User Group web pages, currently located at www.ntg.nl/lug. Without options, reads key=value pairs, possibly embedded in the body of a mail as sent by a web form like U{www.ntg.nl/lug/nl.html}{here}. You can feed the complete email (after saving it) to lug, or you can paste its content to standard input. For testing, you may want to make a copy and run it from there: $ cp -a /var/www/html/lug /var/www/html/lugtest $ cd /var/www/html/lugtest $ ./lug --help $ (more lug calls) Finally look at the results in http://www.ntg.nl/lugtest Options: -h,--help Print this help and exit -H,--Help Print full documentation via less and exit -V,--version Print version and exit -f,--full Re-create all files -e,--extras=STR Re-create STR, where STR can be: labels.pdf lugs.pdf lugs.html index.html links.inc pagehead.inc pagetail1.inc pagetail2.inc -s,--sync[=STR] Synchronize the lug page at |www.ntg.nl/STR| with the current directory The default for |STR| is |lug| -c,--clean Remove all files that can be re-created = Description lug can be used to to (re-)create the web pages of the LUG database. This script must be executed in its own directory. After the script has been executed, this directory will contain the web site for the Electronic LUG Database, currently: U{www.ntg.nl/lug}{www.ntg.nl/lug}. Before execution, the directory must contain at least" - the script (as said) - a subdirectory containing one text file for each LUG When people send new data by using the forms of the site, they do so by submitting the form, which causes an email with raw data to be sent to the administrator(s). An administrator should verify the password reported in the email and then cd to this directory, or to a copy of it on his own computer, and he should then run: $ ./lug lug waits for data, which it can be given by cut (from the email) and paste (to standard input). By ending the input with |^D|, lug corrects the data in the directory `lugs' It is of course also possible to save the contents of the email into a file and then run: $ ./lug &2; exit 1; } Warn() { echo -e "$myname: $War$@$Nor" 1>&2; } warn() { $verbose && Warn $@; } help() { sed -n '/^= Synopsis/,/^= /p' $0|sed '1s/.*/Usage:/;/^= /d'; exit; } helpall() { sed -n '/^<<.DOC.$/,/^DOC$/p' $0|sed -n '1d;$d;p'|less; exit; } version() { echo $version; exit; } install() { which instscript>&/dev/null && instscript --zip --pdf --markdown $myname; exit; } Nor='\e[0m' # reset color ] Err='\e[31;1m' # light red ] War='\e[35;1m' # light magenta ] <<'DOC' #------ function setkeys ----------------------------------------------- = setkeys parameters: 1: country code description: Set the |keys| hash to the values taken from the file |lugs/$1|. globals set: keys globals used: - returns: 0 DOC #------------------------------------------------------------------------------- setkeys() { # code semicolonreplacement ampersandreplacement local k v while IFS=$'\t' read -r k v; do [[ $k = '' || $k =~ ^# ]] && continue [[ $k =~ addr$ ]] && v=${v//;/$2} keys["$k"]="${v//&/$3}" done Makefile BASEFILES = $(for i in ${db[@]}; do echo -n lugs/$i' '; done) .SUFFIXES: .tex .pdf .tex.pdf: PDFLATEX='xelatex -recorder -interaction=batchmode' texi2dvi -p -q \$< 2>/tmp/\$\$ || cat /tmp/\$\$ PDFLATEX='xelatex -interaction=batchmode' texi2dvi -p -q --mostly-clean \$< 2>/tmp/\$\$ || cat /tmp/\$\$ all: $(echo -n ${db[@]} |sed 's/ /.html /g').html \ utf82html index.html lugs.html \ links.inc pagetail1.inc pagetail2.inc pagehead.inc \ lugs.pdf labels.pdf $(for i in ${db[@]}; do echo "$i.html: lugs/$i utf82html; ./lug $i"; done) labels.pdf: \$(BASEFILES) ./lug --extras=labels.pdf lugs.pdf: \$(BASEFILES) ./lug --extras=lugs.pdf lugs.html: \$(BASEFILES) ./lug --extras=lugs.html index.html: \$(BASEFILES) ./lug --extras=index.html links.inc: \$(BASEFILES) ./lug --extras=links.inc pagehead.inc: ./lug --extras=pagehead.inc pagetail1.inc: ./lug --extras=pagetail1.inc pagetail2.inc: ./lug --extras=pagetail2.inc clean: rm -rf *.html labels.* lugs.* links.inc pagehead.inc pagetail1.inc pagetail2.inc utf82html Makefile utf82html: utf82html.c cc -o utf82html utf82html.c EOF } <<'DOC' #------ function makepagehead.inc -------------------------------------- = makepagehead.inc parameters: - description: Create the file |pagehead.inc| globals set: - globals used: - returns: 0 DOC #------------------------------------------------------------------------------- makepagehead.inc() { cat <<-'EOF' >pagehead.inc De Nederlandstalige TeX Gebruikersgroep

TeX user groups around the world

EOF } <<'DOC' #------ function makepagetail1.inc -------------------------------------- = makepagetail1.inc parameters: - description: Create the file |pagetail1.inc| globals set: - globals used: - returns: 0 DOC #------------------------------------------------------------------------------- makepagetail1.inc() { cat <<-'EOF' >pagetail1.inc
EOF } <<'DOC' #------ function makeutf82html.c -------------------------------------- = makeutf82html.c parameters: - description: Create the file |utf82html.c|; it will be compiled /via/ |Makefile| globals set: - globals used: - returns: 0 DOC #------------------------------------------------------------------------------- makeutf82html.c() { cat <<-'EOF' >utf82html.c // utf82html.c: convert UTF-8 byte sequences to numeric html entities // Written in 2004 by Peter Samuelson // Copyright abandoned by the author #include #include #include void from_utf8 (FILE *in, FILE *out) { char buf[4096 + 17]; size_t len = 0; while (!feof(in)) { size_t usable, i; len += fread(buf+len, 1, 4096, in); buf[len] = 0; if (feof(in) || len < 16) usable = len; else usable = len - 16; for (i=0; i 255) ? "&#x%04x;" : "&#x%02x;", ch); continue; invalid: fprintf(stderr, "illegal UTF-8 sequence\n"); fprintf(out, "�"); /* "REPLACEMENT CHARACTER" */ } if (i < len) memcpy(buf, buf+i, len-i); len -= i; } } int main (int argc, char *argv[]) { if (argc == 1) { from_utf8(stdin, stdout); return 0; } while (argc > 1) { FILE *fp = fopen(argv[1], "r"); if (fp) from_utf8(fp, stdout); else perror("fopen"); fclose(fp); argc--; argv++; } return 0; } EOF } <<'DOC' #------ function makelinks.inc ----------------------------------------- = makelinks.inc parameters: - description: Create the file |links.inc| globals set: - globals used: - returns: 0 DOC #------------------------------------------------------------------------------- makelinks.inc() { local i for i in lugs/*; do i=${i#lugs/} echo "$i" done echo 'home' } >links.inc <<'DOC' #------ function makexx.html ------------------------------------------- = makexx.html parameters: 1: country code description: Create the file |lugs/$1| globals set: (/via/ setkeys): |keys| globals used: db keys adminemail returns: DOC #------------------------------------------------------------------------------- makexx.html() { [[ -n ${db[$1]} ]] || die "Unknown country code $1" setkeys $1 "\n" '&' local www [[ -n ${keys[www]} ]] && www='(Here is this lug'"'"'s website)' cat <<-EOF |./utf82html >$1.html

${keys[full]}

  • Changes won't be instant, but are mailed to the maintainer
  • Use either TeX notation or accented characters for accents.
  • Enter phone numbers starting with +, then the country code et cetera,
    no whitespace, hyphens or other punctuation.
Links to other User Group correction forms:

${keys[code]} - ${keys[country]} $www
full name periodical
short name editor
language(s) editor email
members
email bank
web site bank account
mailing list swift code
subscribe at routing no/BIC
address bank address
contact addresses
  policy matters general matters finance / member admin
position
name
address
email
phone
fax
download data
submission of corrected data; enter your email address and password first!
password obtain from wybo@xs4all.nl
your email address needed in case we have questions

Links to other User Group correction forms:

by $adminemail EOF } <<'DOC' #------ function makeindex.html ---------------------------------------- = makeindex.html parameters: - description: Create the file |index.html| globals set: - globals used: db fullname adminemail returns: 0 DOC #------------------------------------------------------------------------------- makeindex.html() { local content=$(for i in ${db[@]}; do echo "$i${fullname[$i]}"; done) cat <<-EOF |./utf82html >index.html
This page presents electronic information about TeX User Groups around the world, with an automated mechanism for updating this information and a download facility with which the primary database can be extracted.

The data for each user group is generated in a separate table. To access it, simply click on the name of the country.

A user group representative (the secretary, usually) can send a corrected version of his group data by editing the data on-line and then hitting the Send button. This will mail the changed data to the maintainer of this page.

New user groups can request an entry by sending an email to wybodekker at xs4all.nl

  • Please enter ASCII characters (decimal 32-126) only
  • use TeX for accents
  • Enter phone numbers starting with +, then the country code et cetera, no whitespace, hyphens or other punctuation.
Anybody can obtain user group information by downloading the data from the green cell in a table. This will generate a key=value line for each cell in the table, starting with a key for that cell, followed by the contents of the cell.

How to obtain information about all lugs at once:
Obtain a LaTeX file presenting all lug information for publication in two-column format: LaTeX source
PDF
HTML
Obtain a LaTeX file containing labels with addresses of all lugs, where you can send your publication: LaTeX source PDF

$content
by $adminemail EOF } <<'DOC' #------ function makelugs.html ----------------------------------------- = makelugs.html parameters: - description: Create the file |lugs.html| globals set: (/via/ setkeys) |keys| globals used: db keys fullname returns: 0 DOC #------------------------------------------------------------------------------- makelugs.html() { local linkline=$(for l in ${db[@]}; do echo "$l"; done) local i l lug www { cat <<-EOF All TeX User Groups

TeX user groups around the world

The TeX Users Group (contact info below) serves as the local user group (LUG) of TeX users in North America and any other area or language not appearing in the following list. TUG is always interested in fostering the formation of local TeX users groups; please contact the TUG board (board at tug.org) for assistance, such as forwarding information about others who might be interested, publicity, arranging joint memberships and so on.

See also:

This information comes from the Electronic LUG Database: you can correct or add information there.
The following links bring you straight to the individual user group correction forms:

EOF for i in ${db[@]}; do echo " $i" done cat <<-EOF

Below, a similar line of links just above every LUG header can be used to wander between the LUG info records in this document.


EOF for lug in ${db[@]}; do setkeys $lug '
' '&' www=${keys[www]} [[ -n $www ]] && www="$www" cat <<-EOF EOF done echo "

$linkline
  $lug - ${fullname[$lug]}
short name: ${keys[short]}
full name: ${keys[full]}
language: ${keys[lang]}
members: ${keys[members]}
email: ${keys[email]}
web site: $www
discussion list:${keys[list]}
subscribe at: ${keys[subscr]}
address:${keys[addr]}

Periodical

title: ${keys[publ]}
editor: ${keys[editor]}
editor email: ${keys[eemail]}

Banking

name: ${keys[bank]}
account: ${keys[bacc]}
(swift) code: ${keys[bcode]}
routing no.: ${keys[brout]}
address:${keys[baddr]}

${keys[ppos]:-President}

name: ${keys[pname]}
address:${keys[paddr]}
email: ${keys[pemail]}
phone: ${keys[pphone]}
fax: ${keys[pfax]}

${keys[gpos]:-Secretary}

name: ${keys[gname]}
address:${keys[gaddr]}
email: ${keys[gemail]}
phone: ${keys[gphone]}
fax: ${keys[gfax]}

${keys[fpos]:-Treasurer}

name: ${keys[fname]}
address:${keys[faddr]}
email: ${keys[femail]}
phone: ${keys[fphone]}
fax: ${keys[ffax]}
" } | sed '/^$/d;/<\/td><\/td><\/tr>$/d' | tac | # reverse and go looking for

headers with no content while read -r l; do if [[ $l =~ :\ *\ ]]; then # content line? keep=true # yes, keep

header elif [[ $l =~ \\\ ]]; then #

header? $keep || continue # keep it if keep was set true, skip otherwise keep=false # not a content line, so set keep false else keep=false # not a content line, so set keep false fi echo "$l" done | tac | utf82html >lugs.html } <<'DOC' #------ function makelugs.pdf ------------------------------------------ = makelugs.pdf parameters: - description: Create the files |lug.tex| and |lugs.pdf| globals set: (/via/ setkeys) |keys| globals used: keys db fullname returns: 0 DOC #------------------------------------------------------------------------------- makelugs.pdf() { local l lug { cat <<-'EOF' %!xelatex \documentclass[10pt]{article} \usepackage[a4paper,margin=25mm]{geometry} \usepackage{textcomp} \usepackage{fontspec} \usepackage{url} \setcounter{secnumdepth}{0} \renewcommand{\-}{\discretionary{}{}{}} \newenvironment{mylist}{% \begin{list}{}{% \itemsep0ex\parsep0pt\leftmargin25mm\labelwidth25mm \renewcommand{\makelabel}[1]{\hfill\emph{##1:}} }}{\end{list} } \def\head#1#2{\vfill\item[\bfseries\large\upshape #1] {\Large\bfseries\upshape #2}\nopagebreak} \def\subhead#1{\\{\bfseries\upshape #1:}} \begin{document}\fontspec{FreeSans} EOF for lug in ${db[@]}; do setkeys $lug '\\' '\&' cat <<-EOF \begin{mylist} \head{$lug}{${fullname[$lug]}} \item[short name] ${keys[short]} \item[full name] ${keys[full]} \item[language] ${keys[lang]} \item[members] ${keys[members]} \item[email] ${keys[email]:+$(echo "\\url{${keys[email]}}")} \item[web site] ${keys[www]:+$(echo "\\url{${keys[www]}}")} \item[discussion list]${keys[list]} \item[subscribe at] ${keys[subscr]} \item[address] ${keys[addr]:+$(echo "\\begin{minipage}[t]{\\hsize}${keys[addr]//;/\\\\}\\strut\\end{minipage}")} \subhead{Periodical} \item[title] ${keys[publ]} \item[editor] ${keys[editor]} \item[editor email] ${keys[eemail]:+$(echo "\\url{${keys[eemail]}}")} \subhead{Banking} \item[name] ${keys[bank]} \item[account] ${keys[bacc]} \item[(swift) code] ${keys[bcode]} \item[routing no.] ${keys[brout]} \item[address] ${keys[baddr]:+$(echo "\\begin{minipage}[t]{\\hsize}${keys[baddr]//;/\\\\}\\strut\\end{minipage}")} \subhead{${keys[ppos]:-President}} \item[name] ${keys[pname]} \item[address] ${keys[paddr]:+$(echo "\\begin{minipage}[t]{\\hsize}${keys[paddr]//;/\\\\}\\strut\\end{minipage}")} \item[email] ${keys[pemail]:+$(echo "\\url{${keys[pemail]}}")} \item[phone] ${keys[pphone]} \item[fax] ${keys[pfax]} \subhead{${keys[gpos]:-Secretary}} \item[name] ${keys[gname]} \item[address] ${keys[gaddr]:+$(echo "\\begin{minipage}[t]{\\hsize}${keys[gaddr]//;/\\\\}\\strut\\end{minipage}")} \item[email] ${keys[gemail]:+$(echo "\\url{${keys[gemail]}}")} \item[phone] ${keys[gphone]} \item[fax] ${keys[gfax]} \subhead{${keys[fpos]:-Treasurer}} \item[name] ${keys[fname]} \item[address] ${keys[faddr]:+$(echo "\\begin{minipage}[t]{\\hsize}${keys[faddr]//;/\\\\}\\strut\\end{minipage}")} \item[email] ${keys[femail]:+$(echo "\\url{${keys[femail]}}")} \item[phone] ${keys[fphone]} \item[fax] ${keys[ffax]} \end{mylist} EOF done echo '\end{document}' } | sed '/^\\item\[.*\] *$/d;/^$/d' | tac | # reverse and go looking for \subhead headers with no content while read -r l; do if [[ $l =~ ^\\item ]]; then # content line? keep=true # yes, keep

header elif [[ $l =~ ^\\subhead ]]; then # \subhead header? $keep || continue # keep it if keep was set true, skip otherwise keep=false # not a content line, so set keep false else keep=false # not a content line, so set keep false fi echo "$l" done | tac >lugs.tex mk --noprint --noview lugs.tex && mk -c lugs.tex || die "Problems compiling lugs.tex" } <<'DOC' #------ function makelabels.pdf ---------------------------------------- = makelabels.pdf parameters: - description: Create the file |labels.tex| and |labels.pdf| globals set: (/via/ setkeys) |keys| globals used: keys db returns: 0 DOC #------------------------------------------------------------------------------- makelabels.pdf() { local a i lug { cat <<-'EOF' %!xelatex \documentclass{article} \usepackage{labels,fontspec} \LabelRows=8\LabelCols=3 \TopBorder=0mm\BottomBorder=0mm \LeftBorder=7mm\RightBorder=7mm \begin{document}\fontspec{FreeSans}\begin{labels} EOF for lug in ${db[@]}; do setkeys $lug "\n" '\&' a= for i in addr gaddr paddr faddr; do if [[ -n ${keys[$i]} ]]; then a=${keys[$i]} break fi done [[ -n $a ]] || continue echo -e "${keys[short]:-${keys[full]}}\n$a\n" done echo '\end{labels}\end{document}' } >labels.tex mk --noprint --noview labels.tex && mk -c labels.tex || die "Problems compiling labels.tex" } <<'DOC' #----------- fullname ----------------------------- = fullname (hash) Links the country codes to the full name of countries. Also used to test the validity of country codes. DOC #---------------------------------------------------------- declare -A fullname=( [ad]='Andorra' [ky]='Cayman Islands' [ae]='United Arab Emirates' [kz]='Kazakhstan' [af]='Afghanistan' [la]='Laos' [ag]='Antigua and Barbuda' [lb]='Lebanon' [ai]='Anguilla' [li]='Liechtenstein' [al]='Albania' [lk]='Sri Lanka' [am]='Armenia' [lr]='Liberia' [an]='Netherlands Antilles' [ls]='Lesotho' [ao]='Angola' [lt]='Lithuania' [ar]='Argentina' [lu]='Luxembourg' [as]='American Samoa' [lv]='Latvia' [at]='Austria' [ly]='Libya' [au]='Australia' [ma]='Morocco' [aw]='Aruba' [mc]='Monaco' [az]='Azerbaijan' [md]='Moldova' [ba]='Bosnia and Herzegovina' [mg]='Madagascar' [bb]='Barbados' [mh]='Marshall Islands' [bd]='Bangladesh' [mk]='Macedonia' [be]='Belgium' [ml]='Mali' [bf]='Burkina Faso' [mm]='Myanmar' [bg]='Bulgaria' [mn]='Mongolia' [bh]='Bahrain' [mo]='Macau' [bi]='Burundi' [mp]='Northern Marianas Islands' [bj]='Benin' [mq]='Martinique' [bm]='Bermuda' [mr]='Mauritania' [bn]='Brunei' [ms]='Montserrat' [bo]='Bolivia' [mt]='Malta' [br]='Brazil' [mu]='Mauritius' [bs]='Bahamas' [mv]='Maldives' [bt]='Bhutan' [mw]='Malawi' [bw]='Botswana' [mx]='Mexico' [by]='Belarus' [my]='Malaysia' [bz]='Belize' [mz]='Mozambique' [ca]='Canada' [na]='Namibia' [cf]='Central African Republic' [nc]='New Caledonia' [cg]='Congo' [ne]='Niger' [ch]='Switzerland' [nf]='Norfolk Island' [ci]='Ivory Coast' [ng]='Nigeria' [ck]='Cook Islands' [ni]='Nicaragua' [cl]='Chile' [nl]='Netherlands' [cm]='Cameroon' [no]='Norway' [cn]='China' [nr]='Nauru' [co]='Colombia' [nu]='Niue' [cr]='Costa Rica' [nz]='New Zealand' [cu]='Cuba' [om]='Oman' [cv]='Cape Verde Islands' [pa]='Panama' [cy]='Cyprus' [pe]='Peru' [cz]='Czech Republic' [pf]='French Polynesia' [de]='Germany' [pg]='Papua New Guinea' [dj]='Djibouti' [ph]='Philippines' [dk]='Denmark' [pk]='Pakistan' [dm]='Dominica' [pl]='Poland' [do]='Dominican Republic' [pm]='St Pierre and Miquelon' [dz]='Algeria' [pr]='Puerto Rico' [ec]='Ecuador' [pt]='Portugal' [ee]='Estonia' [pw]='Palau' [eg]='Egypt' [py]='Paraguay' [eh]='Western Samoa' [qa]='Qatar' [er]='Eritrea' [re]='Reunion' [es]='Spain' [ro]='Romania' [esc]='Spain (Catalan)' [ru]='Russia' [et]='Ethiopia' [rw]='Rwanda' [fi]='Finland' [sa]='Saudi Arabia' [fj]='Fiji Islands' [sb]='Solomon Islands' [fk]='Falkland Islands' [sc]='Seychelles Islands' [fm]='Micronesia' [sd]='Sudan' [fo]='Faroe Islands' [se]='Sweden' [fr]='France' [sg]='Singapore' [ga]='Gabon' [si]='Slovenia' [gb]='United Kingdom' [sk]='Slovak Republic' [gd]='Grenada' [sl]='Sierra Leone' [ge]='Georgia' [sm]='San Marino' [gf]='French Guiana' [sn]='Senegal' [gh]='Ghana' [so]='Somalia' [gi]='Gibraltar' [sr]='Suriname' [gl]='Greenland' [sv]='El Salvador' [gm]='Gambia' [sy]='Syria' [gn]='Guinea' [sz]='Swaziland' [gp]='Guadeloupe' [tc]='Turks and Caicos Islands' [gq]='Equatorial Guinea' [td]='Chad' [gr]='Greece' [tg]='Togo' [gt]='Guatemala' [th]='Thailand' [gu]='Guam' [tj]='Tajikistan' [gw]='Guinea-Bissau' [tk]='Tokelau' [gy]='Guyana' [tm]='Turkmenistan' [hk]='Hong Kong' [tn]='Tunisia' [hn]='Honduras' [to]='Tonga Islands' [hr]='Croatia' [tp]='East Timor' [ht]='Haiti' [tr]='Turkey' [hu]='Hungary' [tt]='Trinidad and Tobago' [id]='Indonesia' [tv]='Tuvalu' [ie]='Ireland' [tw]='Taiwan' [il]='Israel' [tz]='Tanzania' [in]='India' [ua]='Ukraine' [iq]='Iraq' [ug]='Uganda' [ir]='Iran' [us]='TeX User Group (International)' [is]='Iceland' [uy]='Uruguay' [it]='Italy' [uz]='Uzbekistan' [jm]='Jamaica' [ve]='Venezuela' [jo]='Jordan' [vg]='Virgin Islands (GB)' [jp]='Japan' [vi]='Virgin Islands (US)' [ke]='Kenya' [vn]='Vietnam' [kg]='Kyrgyzstan' [vu]='Vanuatu' [kh]='Cambodia' [wf]='Wallis and Futuna Islands' [ki]='Kiribati' [ye]='Yemen' [km]='Comoros' [yt]='Mayotte Island' [kn]='St Kitts and Nevis' [yu]='Yugoslavia' [kp]='Korea (North)' [za]='South Africa' [kr]='Korea (South)' [zm]='Zambia' [kw]='Kuwait' [zw]='Zimbabwe' ) <<'DOC' #----------- keys, inp ---------------------------- = keys, inp (hashes) Depending on which lug is handled, |keys| will contain the key and values defined in the files in |lugs/|. In an edit operation, |inp| will be filled with similar keys and values that will replace those in keys. DOC #---------------------------------------------------------- declare -A keys inp <<'DOC' #------------- db --------------------------------- = db (string) Contains the space-separated country codes for which data are available in the |lugs/| directory. DOC #---------------------------------------------------------- db=$(test -d lugs && cd lugs && ls | tr "\n" " ") <<'DOC' #------------- admin ------------------------------ = admin (string) Contains the user name of the lug administrator at www.ntg.nl DOC #---------------------------------------------------------- admin=wybo <<'DOC' #------------- adminemail ------------------------- = adminemail (string) Contains the email address that should receive corrections from the web site. DOC #---------------------------------------------------------- adminemail=wybo@dekkerdocumenten.nl # =============== Program starts here ============= source=$(readlink $0 || echo ./lug) cd ${source%/lug} test -d lugs -a -e lug || die "The lug script is part of a directory containing all LUG data;\n" \ " You must run (an exact copy of) it in that directory,\n" \ " or you must make a link to the lug script in your PATH" diff ./lug $0 >/dev/null || die "You are running a copy of the lug script that differs from its source" if ! options=$(getopt \ -n $myname \ -o hHVIcfe:s:: \ -l help,Help,version,clean,full,extras:,sync:: \ -- "$@" ); then exit 1; fi eval set -- "$options" while [ $# -gt 0 ]; do case $1 in (-h|--help) help;; (-H|--Help) helpall;; (-V|--version) version;; (-I) install;; (-c|--clean) Clean exit;; (-f|--full) Clean makeutf82html.c makeMakefile make --quiet clean exit;; (-e|--extras) eval "make$2" exit;; (-s|--sync) i=${2:-lug} n=$(ls -R|wc -l) test $n -lt 70 && die "Only $n files here, can't sync" echo syncing with www.ntg.nl/$i rsync -ia --delete --exclude='.hg*' ./ $admin@www.ntg.nl:html/$i/ exit;; (--) shift; break;; (*) break;; esac done if [ -n "$1" ]; then for i in "$@"; do makexx.html $i done exit fi in=false echo waiting for input... while IFS='' read line; do [[ -z $line ]] && continue # skip empty lines if [[ $line =~ ^code= ]]; then # we get here only with manual input in=true # of a few lines; those must start with code= inp[code]=${line#*=} fi [[ $line == 'password=kjwb' ]] && { in=true; continue; } $in || continue # look only after "password=kjwb" [[ $line =~ =$ ]] && continue if [[ $line =~ = ]]; then IFS='=' read k v <<<$line inp[$k]="$v" else inp[$k]+=";$line" fi done code=${inp[code]} [[ -n $code ]] || die "No code was specified" [[ $(echo ${db[@]}) =~ $code ]] || die "Unrecognized code: $code" setkeys $code ';' '&' # make copy of old data in keys for i in ${!inp[@]}; do keys[$i]=${inp[$i]}; done # overwrite with new data cat <<-EOF >new # General: code ${keys[code]} short ${keys[short]} full ${keys[full]} lang ${keys[lang]} members ${keys[members]} email ${keys[email]} www ${keys[www]} list ${keys[list]} subscr ${keys[subscr]} addr ${keys[addr]} # Periodical: publ ${keys[publ]} editor ${keys[editor]} eemail ${keys[eemail]} # Banking: bank ${keys[bank]} bacc ${keys[bacc]} bcode ${keys[bcode]} brout ${keys[brout]} baddr ${keys[baddr]} # Policy matters: ppos ${keys[ppos]} pname ${keys[pname]} paddr ${keys[paddr]} pemail ${keys[pemail]} pphone ${keys[pphone]} pfax ${keys[pfax]} # General matters: gpos ${keys[gpos]} gname ${keys[gname]} gaddr ${keys[gaddr]} gemail ${keys[gemail]} gphone ${keys[gphone]} gfax ${keys[gfax]} # Finance matters: fpos ${keys[fpos]} fname ${keys[fname]} faddr ${keys[faddr]} femail ${keys[femail]} fphone ${keys[fphone]} ffax ${keys[ffax]} EOF diff -y --left-column --report-identical-files lugs/$code new && die "No changes" while true; do echo -n "Save [Yn]? " read r case $r in ([yY]|'') mv -f new lugs/$code && Warn Saved || die "Could not save" exit ;; (n|N) die "Not saved, result left in file new" ;; esac done