Files
ChuSQL/docker/entrypoint.sh
T
ChuNa7a 6996e19694
build / build (push) Blocked by required conditions
tests / build (push) Waiting to run
tests / tests (push) Waiting to run
修bug,完善功能
2026-10-16 23:52:12 +08:00

36 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -eu
# 通过既有引导程序初始化目录,随后以当前非特权用户启动单个服务。
case "${1:-server}" in
server)
if [ "$#" -gt 0 ]; then shift; fi
config=${CHUSQL_CONFIG:-/etc/chusql/server.toml}
password_file=${CHUSQL_ADMIN_PASSWORD_FILE:-/run/secrets/admin_password}
if [ ! -r "$password_file" ]; then
echo "Cannot read administrator password file: $password_file" >&2
exit 1
fi
password=$(head -n 1 "$password_file")
case "$password" in
*[![:space:]]*) ;;
*)
echo "Administrator password file must start with a non-blank password." >&2
exit 1
;;
esac
printf '%s\n' "$password" | csql-bootstrap --config "$config" \
--user "${CHUSQL_ADMIN_USER:-root}" --password-stdin
unset password
exec chusql-server --config "$config" --user "${CHUSQL_ADMIN_USER:-root}" "$@"
;;
web)
shift
exec chusql-web --config "${CHUSQL_CONFIG:-/etc/chusql/web.toml}" \
--user "${CHUSQL_ADMIN_USER:-root}" "$@"
;;
*)
exec "$@"
;;
esac