summaryrefslogtreecommitdiff
path: root/usr/local/sbin/update_conversejs.sh
blob: 971d98019cc0c8b316ac2a38fdca92b53a6b8b3c (plain) (blame)
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
#!/bin/sh
TEMPDIR="$(mktemp -d)"
LOG=/var/log/update_conversejs.log
WWWDIR='/var/www/chat.exemple.fr'
WWWUSER='www-data' # this value will differ on the
                   # distro you're using: it'll be 'http' on 
                   # Arch Linux nginx for example.

mkdir -p $WWWDIR/dist
cd $TEMPDIR
printf "\n\n$(date) - INFO - Starting updating conversejs..." | tee -a $LOG
CURL_ERR=$(curl -s \ # let's grab latest release tarball of converse.js
                https://api.github.com/repos/conversejs/converse.js/releases/latest | \
                grep -o "https://.*\.tgz" | \
                grep converse\.js- | \
                xargs curl -fsOJL) || \
                (printf "\n$(date) - ERR - Updating conversejs failed." | tee -a $LOG && exit)

# we download the OMEMO library to use it in converse
if test -e "$WWWDIR/dist/libsignal-protocol.min.js"; then
    printf "\n$(date) - TOK - Libsignal already installed, skipping." | tee -a $LOG
else
    curl -fsOJL \
    https://cdn.conversejs.org/3rdparty/libsignal-protocol.min.js || \
    (printf "\n$(date) - ERR - Updating libsignal-protocol-javascript failed." | \
            tee -a $LOG)
    cp libsignal*.js $WWWDIR/dist/
fi

tar xzf *.tgz
cp -rf package/dist  $WWWDIR/
sed "s/fullscreen\.html/index\.html/g" package/manifest.json > $WWWDIR/manifest.json
chown $WWWUSER:$WWWUSER -R $WWWDIR/
chmod 755 -R $WWWDIR/
rm -rf $TEMPDIR
printf "\n$(date) - TOK - Done." | tee -a $LOG