tiddlywiki-docker/init-and-run-wiki
Chris B 1d356df701
Makes it possible to set empty password
Wraps user and password into double quotes to avoid variables with spaces to mess with the command line.
Also removes the colon from the password substitution to allow for empty passwords.
Only done for password, as empty user would possibly mess heavily with TiddlyWiki, as it uses the username to sign entries.
2019-08-11 16:02:46 +02:00

35 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
set -e
tiddlywiki_script=$(readlink -f $(which tiddlywiki))
if [ -n "$NODE_MEM" ]; then
# Based on rule of thumb from:
# http://fiznool.com/blog/2016/10/01/running-a-node-dot-js-app-in-a-low-memory-environment/
mem_node_old_space=$((($NODE_MEM*4)/5))
NODEJS_V8_ARGS="--max_old_space_size=$mem_node_old_space $NODEJS_V8_ARGS"
fi
if [ ! -d /var/lib/tiddlywiki/mywiki ]; then
/usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --init server
mkdir /var/lib/tiddlywiki/mywiki/tiddlers
fi
# Configure the tiddlywiki to be served on a path if it is given
WEBHOST_TID=/var/lib/tiddlywiki/mywiki/tiddlers/\$__config_tiddlyweb_host.tid
if [ -n "${SERVE_URI}" ]; then
cp /tiddlyweb_host_template ${WEBHOST_TID}
echo '$protocol$//$host$'${SERVE_URI}"/" >> ${WEBHOST_TID}
echo "tiddlywiki will be served at ${SERVE_URI}"
else
if [ -e ${WEBHOST_TID} ]; then
rm ${WEBHOST_TID}
fi
fi
# Start the tiddlywiki server
exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --server 8080 $:/core/save/all text/plain text/html "${USERNAME:-user}" "${PASSWORD-wiki}" 0.0.0.0 ${SERVE_URI}