-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·26 lines (22 loc) · 877 Bytes
/
init.sh
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
#!/bin/bash
set -euo pipefail
# Initialize the TiddlyWiki data directory if it's empty
if [ -z "$(ls -A /var/lib/tiddlywiki)" ]; then
echo "Initializing TiddlyWiki data directory..."
npx -s tiddlywiki /var/lib/tiddlywiki --init server
fi
# Set the default username and password if they're not set
listen_params="host=0.0.0.0 port=8080"
if [ -n "${USERNAME-}" ]; then
listen_params="$listen_params username=$USERNAME"
listen_params="$listen_params password=${PASSWORD-}"
elif [ -n "${ANON_USERNAME-}" ]; then
listen_params="$listen_params anon-username=$ANON_USERNAME"
fi
if [ -n "${EXTRA_PARAMS-}" ]; then
listen_params="$listen_params $EXTRA_PARAMS"
fi
# Start the TiddlyWiki server with the specified username and password
echo "Starting TiddlyWiki server..."
# shellcheck disable=SC2086
exec npx -s tiddlywiki /var/lib/tiddlywiki --listen $listen_params