55 lines
2.1 KiB
Bash
55 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# Core and UI share one supervised container. Only the validated snapshot is
|
|
# handed to Core; the operator's persistent settings are never rewritten.
|
|
set -eu
|
|
cd /qortal
|
|
umask 077
|
|
runtime_dir=$(mktemp -d /tmp/qortal-runtime.XXXXXXXX)
|
|
runtime_jar="$runtime_dir/qortal.jar"
|
|
runtime_receipt="$runtime_dir/qortal-overlay-receipt.json"
|
|
core_pid=
|
|
ui_pid=
|
|
cleanup() {
|
|
trap '' TERM INT
|
|
for pid in "$core_pid" "$ui_pid"; do
|
|
[ -z "$pid" ] || kill -TERM "$pid" 2>/dev/null || true
|
|
done
|
|
[ -z "$core_pid" ] || wait "$core_pid" 2>/dev/null || true
|
|
[ -z "$ui_pid" ] || wait "$ui_pid" 2>/dev/null || true
|
|
if [ -f "$runtime_jar" ] && [ -f "$runtime_receipt" ]; then
|
|
python3 /usr/local/bin/qortal-prepare-runtime-jar.py rollback \
|
|
/usr/local/qortal/qortal.jar "$runtime_jar" "$runtime_receipt" || true
|
|
fi
|
|
rm -rf -- "$runtime_dir"
|
|
}
|
|
trap cleanup EXIT
|
|
trap 'exit 143' TERM
|
|
trap 'exit 130' INT
|
|
|
|
# The package intentionally ships no replacement class while upstream provenance
|
|
# is pending. Missing bytes or a pending/drifted contract refuse before settings,
|
|
# credentials, nginx, or Core are touched.
|
|
python3 "/usr/local/bin/qortal-prepare-runtime-jar.py" prepare \
|
|
/usr/local/qortal/qortal.jar \
|
|
/usr/local/qortal/empty-cache/ArbitraryDataCacheManager.class \
|
|
/usr/local/qortal/empty-cache-overlay-contract.json \
|
|
"$runtime_jar" "$runtime_receipt"
|
|
python3 /usr/local/bin/qortal-check-settings /qortal/settings.json \
|
|
"$runtime_dir/settings.json" /qortal/apikey.txt
|
|
# Neither UI nor Core needs the original environment secret after materialization.
|
|
unset QORTAL_API_KEY
|
|
mkdir -p /tmp/nginx
|
|
nginx -c /etc/qortal-ui/nginx.conf -e stderr -g 'daemon off;' &
|
|
ui_pid=$!
|
|
# Keep the upstream JVM tuning override, with glob expansion disabled.
|
|
set -f
|
|
read -r -a jvm_args <<< "${QORTAL_JVM_ARGS:--XX:MaxRAMPercentage=50 -XX:+UseG1GC -Xss1024k}"
|
|
java "${jvm_args[@]}" -Djava.net.preferIPv4Stack=false \
|
|
-Dlog4j.configurationFile=/usr/local/qortal/log4j2.properties \
|
|
-jar "$runtime_jar" "$runtime_dir/settings.json" &
|
|
core_pid=$!
|
|
set +e
|
|
wait -n "$core_pid" "$ui_pid"
|
|
status=$?
|
|
exit "$status"
|