Files
simplexmq/scripts/docker/entrypoint-smp-server
tcely ba2a93bad9 docker entrypoint: use an unambiguous date format
Present a leading zero before the month:
YYYY-0MM-DD

Both YYYY-MM-DD and YYYY-DD-MM are used by people and can be confusing in the beginning of the month.
2023-05-13 17:14:56 +00:00

42 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
confd="/etc/opt/simplex"
logd="/var/opt/simplex/"
# Check if server has been initialized
if [ ! -f "$confd/smp-server.ini" ]; then
# If not, determine ip or domain
case "$ADDR" in
'') printf "Please specify \$ADDR environment variable.\n"; exit 1 ;;
*[a-zA-Z]*)
case "$ADDR" in
*:*) set -- --ip "$ADDR" ;;
*) set -- -n "$ADDR" ;;
esac
;;
*) set -- --ip "$ADDR" ;;
esac
# Optionally, set password
case "$PASS" in
'') set -- "$@" --no-password ;;
*) set -- "$@" --password "$PASS" ;;
esac
# And init certificates and configs
smp-server init -y -l "$@"
fi
# Backup store log just in case
_file="${logd}/smp-server-store.log"
if [ -f "${_file}" ]; then
_backup_extension="$(date --universal '+%04Y-%03m-%02dT%T')"
cp -v -p "${_file}" "${_file}.${_backup_extension:-date-failed}"
unset -v _backup_extension
fi
unset -v _file
# Finally, run smp-sever. Notice that "exec" here is important:
# smp-server replaces our helper script, so that it can catch INT signal
exec smp-server start +RTS -N -RTS