summaryrefslogtreecommitdiff
path: root/archive/bin/ma_org_publish
blob: 2faab6f97be004a6294b542ac9b059d0a3e41477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

. $HOME/.shenv

set -e

lisp=$(cat <<EOF
(progn
    (org-batch-store-agenda-views)
    (org-publish-project "spw-wiki")
    (org-publish-project "philos")
    (org-publish-project "spw-org")
    (org-publish-project "spw-static")
    (org-publish-project "blog"))
EOF
    )

webdav_dir ()
{
    local dir=$1
    cd "$dir"
    local files="./*"
    cadaver https://myfiles.messagingengine.com/ <<EOF
cd "$dir"
mput $files
EOF
}

# assume throughout we're on the MetaArray
[ "$(hostname -f)" = "ma.sdf.org" ] \
    || ( echo >&2 "run this script only on MetaArray"; exit 1 )

# 1. git update

# Thanks to `set -e' above, any failure to fast-forward will mean I
# get an e-mail from crond telling me to resolve the merge.
for dir in "$HOME/doc $HOME/doc/www $HOME/doc/www/blog"; do
    cd $dir
    git pull --ff-only
done

# 2. prepare publishing destinations

# this is why this script cannot be executed locally!
mkdir -p $HOME/lib/fm/{,dionysus/Agenda}
# [ "$(ls -A $HOME/lib/fm)" ] \
#     && echo >&2 "target dir not empty!" && exit 1

# 3. have Org publish

emacs -batch \
      -l $HOME/.emacs.d/init.el \
      -l $HOME/.emacs.d/init-org.el \
      -eval "$lisp"

# 4. cleanup

cd $HOME/lib/fm
webdav_dir "Philos notes"
cd $HOME/lib/fm
webdav_dir "dionysus/Agenda"
rm -r $HOME/lib/fm/*

rdate.py-dir $HOME/html/blog/entries