Page MenuHome GnuPG

No OneTemporary

diff --git a/tools/append-to-donors.sh b/tools/append-to-donors.sh
index 6ce4e6b..cd87f43 100755
--- a/tools/append-to-donors.sh
+++ b/tools/append-to-donors.sh
@@ -1,188 +1,192 @@
#!/bin/sh
# append-to-donors.sh
# Append new names from the payproc journal to the donors file
# and send a Thank You mail.
pgm="append-to-donors.sh"
set -e
# We temporary need the next line due to an libgpg-error update
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
PATH=/usr/local/bin:$PATH
SENDMAIL="/usr/sbin/sendmail"
LC_ALL=C
LC_CTYPE=C
RFCDATE="$(date -R)"
SIGDELIM="-- "
htdocs="/var/www/www/www.gnupg.org/htdocs"
donors="$htdocs/donate/donors.dat"
donations="$htdocs/donate/donations.dat"
journal_dir="/var/log/payproc"
LOCKFILE="$donors.lock"
if [ ! -f "$donors" ]; then
echo "$pgm: '$donors' not found" >&2;
exit 1
fi
if [ x"$(idn --quiet wk@gnupg.org)" != x"wk@gnupg.org" ]; then
echo "$pgm: idn(1) tool not installed or not working"
exit 1
fi
if [ x"$(mu-tool 2047 -c utf-8 '<wk@gnupg.org>')" \
!= x"=?utf-8?Q?<wk@gnupg.org>?=" ]; then
echo "$pgm: mu-tool(1) tool not installed or not working"
exit 1
fi
if ! lockfile -l 7200 -r 2 $LOCKFILE; then
echo "$pgm: another instance is still running"
exit 0
fi
trap "rm -f $LOCKFILE $donors.tmp $donors.stamp" 0
# Send a thank you mail
# Uses these variables:
# amount - The amount of the donation
# currency - The currency for the amount
# euro - The amount cinvertet to Euro
# xmail - The mailbox
# name - The name or empty for an anonymous donation
# message - The message to us or empty
# Used scratch variables:
# upcurrency
# ineuro
# xamount
#
# FIXME: Clean message and name and use an appropriate encoding.
# The second mail should actually be encrypted. In fact
# we would better try to encrypt also the first mail. Add a
# pubkey field to the donation page?
#
send_thanks () {
upcurrency=$(echo $currency | tr [a-z] [A-Z])
if [ "$upcurrency" = EUR ]; then
ineuro=
else
ineuro=" (about $(echo $euro| awk '{print int($0 + 0.5)}') EUR)"
fi
xamount="$(echo $amount| awk '{print int($0 + 0.5)}')"
if [ -n "$xmail" ]; then
xidnmail=$(CHARSET=UTF-8 idn --no-tld --quiet "$xmail")
else
xidnmail=""
fi
- xqpmail=$(mu-tool 2047 -c utf-8 "$xmail")
+ if [ x"$xidnmail" = x"$xmail" ]; then
+ xqpmail="$xmail"
+ else
+ xqpmail=$(mu-tool 2047 -c utf-8 "$xmail")
+ fi
( cat <<EOF
From: donations@gnupg.org
To: $xqpmail
Subject: Thank you for supporting GnuPG
Date: $RFCDATE
Mime-Version: 1.0
Content-Type: text/plain
X-Loop: gnupg-donations-thanks.gnupg.org
Dear ${name:-Anonymous},
we received $xamount $upcurrency$ineuro as a donation to the GnuPG project.
Your donation helps us to develop and maintain GnuPG and related software.
Thank you.
Werner
$SIGDELIM
GnuPG - helping to keep private data private
EOF
) | $SENDMAIL -oi donations@gnupg.org "$xidnmail"
if [ -n "$message" ]; then
( cat <<EOF
From: donations@gnupg.org
To: donations@gnupg.org
Reply-To: $xqpmail
Subject: Message from GnuPG donor
Date: $RFCDATE
Mime-Version: 1.0
Content-Type: text/plain
X-Loop: gnupg-donations-thanks.gnupg.org
Name ..: ${name:-Anonymous}
Amount : $amount $upcurrency $ineuro
Message: $message
EOF
) | $SENDMAIL -oi donations@gnupg.org
fi
}
# Find the last entry in donors which we have put in.
tmp=$(awk -F: <$donors '
/^(#.*)?$/ {next}
$5!="" { date=$2;lineno=$5 }
END {gsub(/-/,"",date)
print date ":" lineno}
')
lastdate=$(echo $tmp | cut -d: -f1 | sed 's/T.*//')
lastline=$(echo $tmp | cut -d: -f2)
[ -z "$lastdate" ] && lastdate=19700101
[ -z "$lastline" ] && lastline=0
[ -f "$donors".stamp ] && rm "$donors".stamp
cat "$donors" > "$donors.tmp"
find $journal_dir -type f -name 'journal-????????.log' -print \
| sort | while read fname; do
fname=$(basename "$fname")
jdate=${fname%.log}
jdate=${jdate#journal-}
jyear=$(echo $jdate |sed 's/\(....\).*/\1/')
if [ "$jdate" -ge "$lastdate" ]; then
[ "$jdate" -gt "$lastdate" ] && lastline=0
payproc-jrnl -F_lnr -Fdate -F'[name]' -F'[message]' \
-Fmail -Famount -Fcurrency -Feuro\
-S "_lnr > $lastline" -Stype=C -Saccount==1 \
--html --print "$journal_dir/journal-$jdate.log" \
| while IFS=: read lnr datestr name message \
xmail amount currency euro rest; do
name=$(echo "$name" | tr \`\$: ...)
message=$(echo "$message" | tr \`\$ ..)
xmail=$(echo "$xmail" | tr \`\$ .. | sed 's/\.$//')
# Note that we removed colons from $name
echo "$jyear:$datestr:$name::$lnr:" >> "$donors.tmp"
touch "$donors".stamp
send_thanks
done
fi
done
# If we have any new records update the files.
if [ -f "$donors".stamp ]; then
if ! mv "$donors.tmp" "$donors"; then
echo "$pgm: error updating $donors" >&2
exit 1
fi
if [ -f "$donations" ]; then
payproc-stat -u "$donations" -- > "$donations".tmp \
$(find /var/log/payproc -type f -name 'journal-????????.log' -print|sort)
if ! mv "$donations".tmp "$donations"; then
echo "$pgm: error updating $donations" >&2
exit 1
fi
else
payproc-stat -u "$donations" -- > "$donations" \
$(find /var/log/payproc -type f -name 'journal-????????.log' -print|sort)
fi
fi
diff --git a/tools/build-website.sh b/tools/build-website.sh
index e738491..d4a5330 100755
--- a/tools/build-website.sh
+++ b/tools/build-website.sh
@@ -1,243 +1,244 @@
#!/bin/sh
# Build the gnupg.org website from a git working directory.
#
# This script requires two users
#
# webbuilder - the user to run this script
# webbuild-x - the user used by this script to run emacs
#
# A certain directory layout is required with permissions setup
# so that the webbuild-x has only write access to the stage area
# and to its own home directory. The script checks the permissions.
#
# The trigger-website-build scripts is expected to be installed
# as git post-merge hook.
#
# These cronjobs are required for user webbuilder:
# --8<---------------cut here---------------start------------->8---
# # Pull the master branch of the web pages
# */20 * * * * cd /home/webbuilder/gnupg-doc && git pull -q origin master
#
# # In case of race conditions we try to build every few ours again.
# 35 */7 * * * /home/webbuilder/bin/build-website.sh --cron
# --8<---------------cut here---------------end--------------->8---
#
# /etc/sudoers needs this:
# --8<---------------cut here---------------start------------->8---
# # Let webbuilder run any command as user webbuild-x
# webbuilder ALL = (webbuild-x) NOPASSWD: ALL
# --8<---------------cut here---------------end--------------->8---
#
set -e
pgm=build-website.sh
mainuser=webbuilder
workuser=webbuild-x
# We use a fixed HOME so that this script can be run here from other
# accounts.
HOME=$(awk </etc/passwd -F: '$1=="'$mainuser'" {print $6;exit}')
if [ ! -d "$HOME" ]; then
echo "$pgm: directory '${HOME}' missing" >&2;
exit 1
fi
reponame=gnupg-doc
htdocs_web="/var/www/www/www.gnupg.org/htdocs"
htdocs_blog="/var/www/www/www.gnupg.org/misc/blog"
workuser_dir=$HOME/${workuser}
log_dir="$HOME/log"
root_dir="$HOME/${reponame}"
stage_dir="$HOME/${reponame}-stage"
LOCKFILE="${log_dir}/${reponame}.lock"
if [ x"$1" = x"--git" ]; then
shift
exec >>${log_dir}/"$reponame".log 2>&1
echo "$(date -u -Iseconds) gpgweb site build was git triggered"
elif [ x"$1" = x"--cron" ]; then
shift
exec >>${log_dir}/"$reponame".log 2>&1
echo "$(date -u -Iseconds) gpgweb site build was cron triggered"
fi
if ! id $workuser >/dev/null 2>&1 ; then
echo "$pgm: sudo user '${workuser}' not available" >&2;
exit 1
fi
# Check directories
for f in "${workuser_dir}" "${root_dir}" "${stage_dir}"; do
if [ ! -d "$f" ]; then
echo "$pgm: directory '$f' missing" >&2;
exit 1
fi
done
want="2775:${workuser}:${mainuser}"
for f in "${workuser_dir}" "${stage_dir}"; do
x=$(stat -c '%a:%U:%G' "$f")
if [ x"$x" != x"$want" ]; then
echo "$pgm: directory '$f' has wrong permissions" >&2
echo "$pgm: want: $want" >&2
echo "$pgm: have: $x" >&2
exit 1
fi
done
cd "${root_dir}"
#
# Take a lock so that only one instacne of this script runs.
#
if ! lockfile -l 7200 -r 2 $LOCKFILE; then
echo "$pgm: another instance is still running" >&2
exit 0
fi
trap "rm -f $LOCKFILE" 0
# These flags are set to the stage directory iof a sync is required
sync_web=
sync_blog=
#
# Build main part
#
subdir=web
revlastfile="${log_dir}/${reponame}.$(echo $subdir | tr / _).revlast"
buildlog="${log_dir}/${reponame}.$(echo $subdir | tr / _).log"
rev="$(git rev-parse --verify HEAD:$subdir)"
if [ -z "$rev" ]; then
echo "$pgm: No git revision found" >&2;
exit 1
fi
revlast="$(head -1 ${revlastfile} 2>/dev/null || true)"
if [ x"$rev" = x"$revlast" ]; then
echo "$pgm: No need to build $subdir" >&2;
else
echo "$(date -u -Iseconds) build started for $subdir" | tee ${buildlog}
if [ ! -d ${stage_dir}/${subdir} ]; then
sudo -u webbuild-x mkdir ${stage_dir}/${subdir}
fi
sudo 2>>${buildlog} -u webbuild-x emacs24 -q --batch \
--eval "(require 'assoc)" \
--eval "(require 'org)" \
--eval "(setq make-backup-files nil)" \
--eval "(setq gpgweb-root-dir \"${root_dir}/${subdir}/\")" \
--eval "(setq gpgweb-stage-dir \"${stage_dir}/${subdir}/\")" \
--eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
--eval "(setq org-publish-use-timestamps-flag nil)" \
--eval "(setq org-export-html-toplevel-hlevel 1)" \
--eval "(setq org-export-html-coding-system 'utf-8)" \
--eval "(gpgweb-setup-project)" \
--eval "(org-publish-initialize-cache \"gpgweb\")" \
--eval "(message \"root=(%s)\" gpgweb-root-dir)" \
--eval "(org-publish \"gpgweb\" t nil)"
echo "$rev" > ${revlastfile}
sync_web=${stage_dir}/${subdir}
echo "$(date -u -Iseconds) build finished for $subdir" | tee -a ${buildlog}
fi
#
# Build blogs
#
subdir=misc/blog.gnupg.org
revlastfile="${log_dir}/${reponame}.$(echo $subdir | tr / _).revlast"
buildlog="${log_dir}/${reponame}.$(echo $subdir | tr / _).log"
rev="$(git rev-parse --verify HEAD:$subdir)"
if [ -z "$rev" ]; then
echo "$pgm: No git revision found" >&2;
exit 1
fi
revlast="$(head -1 ${revlastfile} 2>/dev/null || true)"
if [ x"$rev" = x"$revlast" ]; then
echo "$pgm: No need to build $subdir" >&2;
else
echo "$(date -u -Iseconds) build started for $subdir" | tee ${buildlog}
if [ ! -d ${stage_dir}/${subdir} ]; then
sudo -u webbuild-x mkdir -p ${stage_dir}/${subdir}
fi
cd ${stage_dir}/${subdir}
# We need to initialize that org cache to use our own publish function
# despite that we do not use any org-publish feature
echo "$pgm: Rendering blogs" >&2
sudo 2>>${buildlog} -u webbuild-x emacs24 -q --batch \
--eval "(require 'assoc)" \
--eval "(require 'org)" \
--eval "(setq gpgweb-root-dir \"${root_dir}/web/\")" \
--eval "(setq gpgweb-blog-dir \"${root_dir}/${subdir}/\")" \
--eval "(setq gpgweb-stage-dir \"${stage_dir}/${subdir}/\")" \
--eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
--eval "(setq org-publish-use-timestamps-flag nil)" \
--eval "(setq org-export-html-toplevel-hlevel 1)" \
--eval "(setq org-export-html-coding-system 'utf-8)" \
--eval "(gpgweb-setup-project)" \
--eval "(org-publish-initialize-cache \"gpgweb\")" \
--eval "(message \"root=(%s)\" gpgweb-root-dir)" \
--eval "(gpgweb-publish-blogs)"
echo "$pgm: Updating blog index" >&2
indexcreator="${root_dir}/${subdir}/update-index.sh"
if [ ! -f $indexcreator ]; then
echo "$pgm: $indexcreator not found" >&2
exit 1
fi
sudo -u webbuild-x ${indexcreator}
echo "$rev" > ${revlastfile}
sync_blog=${stage_dir}/${subdir}
echo "$(date -u -Iseconds) build finished for $subdir" | tee -a ${buildlog}
fi
#
# Sync to the webspace
#
cd "${root_dir}"
any_sync=
if [ -n "$sync_web" ]; then
cd "$sync_web"
rsync -rlt --exclude '*~' --exclude '*.tmp' \
. ${htdocs_web}/
touch ${htdocs_web}/donate/donors.dat
any_sync=yes
fi
if [ -n "$sync_blog" ]; then
cd "$sync_blog"
- rsync -vr --links --exclude '*~' --exclude '*.sh' \
+ rsync -rt --links --exclude '*~' --exclude '*.sh' \
--exclude '*tmp' --exclude '*.org' --exclude headlines.txt \
. ${htdocs_blog}/
any_sync=yes
fi
if [ "$any_sync" = yes ]; then
$HOME/bin/mkkudos.sh --verbose --force
fi
#
# Print warnings when the scripts are out of date
# (For security reasons the scripts need to be installed manually.)
#
-for f in trigger-website-build build-website.sh mkkudos.sh ; do
+for f in trigger-website-build build-website.sh mkkudos.sh \
+ append-to-donors.sh ; do
if ! cmp -s ${HOME}/bin/$f tools/$f ; then
echo "$pgm: Warning: A newer version of $f is available" >&2;
fi
done
exit 0

File Metadata

Mime Type
text/x-diff
Expires
Thu, Feb 26, 6:45 PM (16 h, 7 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b1/63/c631f663e777fafc5b663b455f51

Event Timeline