sync build tree from private myoffice

This commit is contained in:
myoffice-sync
2026-08-05 12:34:26 +00:00
parent 985d115a3f
commit e9534034ee
+24 -8
View File
@@ -20,9 +20,22 @@ SKIP_FETCH="${SKIP_FETCH:-0}"
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
export API_DIR export API_DIR
# Avoid perl locale warnings in minimal LXC (host may export unsupported LC_*).
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
unset LANGUAGE LC_TIME LC_MESSAGES 2>/dev/null || true
msg() { echo -e " ==> $*"; } msg() { echo -e " ==> $*"; }
as_postgres() {
# Script runs as root in CT; sudo is not installed.
if command -v runuser >/dev/null 2>&1; then
runuser -u postgres -- "$@"
else
su -s /bin/bash postgres -c "$*"
fi
}
detect_public_url() { detect_public_url() {
if [[ -n "$PUBLIC_URL" ]]; then if [[ -n "$PUBLIC_URL" ]]; then
PUBLIC_URL=$(echo "$PUBLIC_URL" | sed 's:/*$::') PUBLIC_URL=$(echo "$PUBLIC_URL" | sed 's:/*$::')
@@ -43,7 +56,10 @@ detect_public_url() {
install_base() { install_base() {
msg "Installing base packages" msg "Installing base packages"
apt-get update -y apt-get update -y
apt-get install -y ca-certificates curl gnupg postgresql postgresql-contrib apt-get install -y ca-certificates curl gnupg locales postgresql postgresql-contrib
sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen 2>/dev/null || true
locale-gen en_US.UTF-8 >/dev/null 2>&1 || true
update-locale LANG=en_US.UTF-8 >/dev/null 2>&1 || true
} }
install_aspnet_runtime() { install_aspnet_runtime() {
@@ -61,16 +77,16 @@ install_aspnet_runtime() {
setup_postgres() { setup_postgres() {
msg "Configuring PostgreSQL" msg "Configuring PostgreSQL"
systemctl enable --now postgresql systemctl enable --now postgresql
if ! sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${PG_USER}'" | grep -q 1; then if ! as_postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='${PG_USER}'" | grep -q 1; then
sudo -u postgres psql -c "CREATE USER ${PG_USER} WITH PASSWORD '${PG_PASS}';" as_postgres psql -c "CREATE USER ${PG_USER} WITH PASSWORD '${PG_PASS}';"
else else
sudo -u postgres psql -c "ALTER USER ${PG_USER} WITH PASSWORD '${PG_PASS}';" as_postgres psql -c "ALTER USER ${PG_USER} WITH PASSWORD '${PG_PASS}';"
fi fi
if ! sudo -u postgres psql -tAc "SELECT 1 FROM pg_database WHERE datname='${PG_DB}'" | grep -q 1; then if ! as_postgres psql -tAc "SELECT 1 FROM pg_database WHERE datname='${PG_DB}'" | grep -q 1; then
sudo -u postgres psql -c "CREATE DATABASE ${PG_DB} OWNER ${PG_USER};" as_postgres psql -c "CREATE DATABASE ${PG_DB} OWNER ${PG_USER};"
fi fi
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ${PG_DB} TO ${PG_USER};" as_postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ${PG_DB} TO ${PG_USER};"
sudo -u postgres psql -d "$PG_DB" -c "GRANT ALL ON SCHEMA public TO ${PG_USER};" || true as_postgres psql -d "$PG_DB" -c "GRANT ALL ON SCHEMA public TO ${PG_USER};" || true
msg "PostgreSQL ready (db/user/pass=${PG_DB})" msg "PostgreSQL ready (db/user/pass=${PG_DB})"
} }