mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-29 10:10:06 +00:00
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.
42 lines
1.1 KiB
Bash
Executable File
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
|
|
|