summaryrefslogtreecommitdiff
path: root/usr/local/sbin/update_conversejs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local/sbin/update_conversejs.sh')
-rwxr-xr-xusr/local/sbin/update_conversejs.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/usr/local/sbin/update_conversejs.sh b/usr/local/sbin/update_conversejs.sh
new file mode 100755
index 0000000..971d980
--- /dev/null
+++ b/usr/local/sbin/update_conversejs.sh
@@ -0,0 +1,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