make TinodeWeb optional

This commit is contained in:
or-else
2020-02-13 14:32:18 +03:00
parent 8fa0217d13
commit f9af0695fc

View File

@ -1,7 +1,15 @@
#!/bin/bash
# Cross-compiling script using https://github.com/mitchellh/gox
# I use this to compile the Linux version of the server on my Mac.
# This scripts build and archives binaries and supporting files.
# If directory ./server/static exists, it's asumed to contain
# TinodeWeb and then it's also copied and archived.
# Check if gox is installed. Abort otherwise.
command -v gox >/dev/null 2>&1 || {
echo >&2 "This script requires https://github.com/mitchellh/gox. Please install it before running."; exit 1;
}
# Supported OSs: darwin windows linux
goplat=( darwin windows linux )
@ -60,31 +68,39 @@ do
# Tar on Mac is inflexible about directories. Let's just copy release files to
# one directory.
rm -fR ./releases/tmp
mkdir -p ./releases/tmp/static/img
mkdir ./releases/tmp/static/css
mkdir ./releases/tmp/static/audio
mkdir ./releases/tmp/static/src
mkdir ./releases/tmp/static/umd
mkdir ./releases/tmp/templ
mkdir -p ./releases/tmp/templ
# Copy templates and database initialization files
cp ./server/tinode.conf ./releases/tmp
cp ./server/templ/*.templ ./releases/tmp/templ
cp ./server/static/img/*.png ./releases/tmp/static/img
cp ./server/static/img/*.svg ./releases/tmp/static/img
cp ./server/static/audio/*.mp3 ./releases/tmp/static/audio
cp ./server/static/css/*.css ./releases/tmp/static/css
cp ./server/static/index.html ./releases/tmp/static
cp ./server/static/index-dev.html ./releases/tmp/static
cp ./server/static/umd/*.js ./releases/tmp/static/umd
cp ./server/static/manifest.json ./releases/tmp/static
cp ./server/static/service-worker.js ./releases/tmp/static
# Create empty FCM client-side config.
echo > ./releases/tmp/static/firebase-init.js
cp ./tinode-db/data.json ./releases/tmp
cp ./tinode-db/*.jpg ./releases/tmp
cp ./tinode-db/credentials.sh ./releases/tmp
# Create directories for and copy TinodeWeb files.
if [[ -d ./server/static ]]
then
mkdir -p ./releases/tmp/static/img
mkdir ./releases/tmp/static/css
mkdir ./releases/tmp/static/audio
mkdir ./releases/tmp/static/src
mkdir ./releases/tmp/static/umd
cp ./server/static/img/*.png ./releases/tmp/static/img
cp ./server/static/img/*.svg ./releases/tmp/static/img
cp ./server/static/audio/*.mp3 ./releases/tmp/static/audio
cp ./server/static/css/*.css ./releases/tmp/static/css
cp ./server/static/index.html ./releases/tmp/static
cp ./server/static/index-dev.html ./releases/tmp/static
cp ./server/static/umd/*.js ./releases/tmp/static/umd
cp ./server/static/manifest.json ./releases/tmp/static
cp ./server/static/service-worker.js ./releases/tmp/static
# Create empty FCM client-side config.
echo > ./releases/tmp/static/firebase-init.js
else
echo "TinodeWeb not found, skipping"
fi
# Build archive. All platforms but Windows use tar for archiving. Windows uses zip.
if [ "$plat" = "windows" ]; then
# Copy binaries
@ -130,7 +146,6 @@ rm -f $GOPATH/bin/init-db
~/go/bin/gox -osarch=linux/amd64 \
-tags rethinkdb -output $GOPATH/bin/init-db ./tinode-db > /dev/null
# Build chatbot release
echo "Building python code..."