Enable vector and load .env in installers
Discourse install: add PG_DB_EXTENSIONS="vector" to setup_postgresql_db and remove the separate CREATE EXTENSION psql call; also remove curl and git from the apt install list and drop the automatic admin bootstrap messaging. SimpleLogin install: source /opt/simplelogin/.env before running migrations and add EnvironmentFile=/opt/simplelogin/.env to the systemd unit files (gunicorn, email_handler, job_runner) so services inherit environment variables.
This commit is contained in:
@@ -20,8 +20,6 @@ $STD apt install -y \
|
|||||||
libreadline-dev \
|
libreadline-dev \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
libyaml-dev \
|
libyaml-dev \
|
||||||
curl \
|
|
||||||
git \
|
|
||||||
imagemagick \
|
imagemagick \
|
||||||
gsfonts \
|
gsfonts \
|
||||||
brotli \
|
brotli \
|
||||||
@@ -38,7 +36,7 @@ DISCOURSE_DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
|||||||
PG_HBA=$(find /etc/postgresql -name pg_hba.conf 2>/dev/null | head -n1)
|
PG_HBA=$(find /etc/postgresql -name pg_hba.conf 2>/dev/null | head -n1)
|
||||||
sed -i 's/^local\s\+all\s\+all\s\+peer$/local all all md5/' "$PG_HBA"
|
sed -i 's/^local\s\+all\s\+all\s\+peer$/local all all md5/' "$PG_HBA"
|
||||||
$STD systemctl restart postgresql
|
$STD systemctl restart postgresql
|
||||||
PG_DB_NAME="discourse" PG_DB_USER="discourse" PG_DB_PASS="$DISCOURSE_DB_PASS" setup_postgresql_db
|
PG_DB_NAME="discourse" PG_DB_USER="discourse" PG_DB_PASS="$DISCOURSE_DB_PASS" PG_DB_EXTENSIONS="vector" setup_postgresql_db
|
||||||
msg_ok "Configured PostgreSQL for Discourse"
|
msg_ok "Configured PostgreSQL for Discourse"
|
||||||
|
|
||||||
msg_info "Configuring Discourse"
|
msg_info "Configuring Discourse"
|
||||||
@@ -90,7 +88,6 @@ export RAILS_ENV=production
|
|||||||
set -a
|
set -a
|
||||||
source /opt/discourse/.env
|
source /opt/discourse/.env
|
||||||
set +a
|
set +a
|
||||||
$STD runuser -u postgres -- psql -d discourse -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
||||||
$STD bundle exec rails db:migrate
|
$STD bundle exec rails db:migrate
|
||||||
msg_ok "Set Up Database"
|
msg_ok "Set Up Database"
|
||||||
|
|
||||||
@@ -105,9 +102,6 @@ set +a
|
|||||||
$STD bundle exec rails assets:precompile
|
$STD bundle exec rails assets:precompile
|
||||||
msg_ok "Built Discourse Assets"
|
msg_ok "Built Discourse Assets"
|
||||||
|
|
||||||
msg_info "Preparing Admin Onboarding"
|
|
||||||
msg_ok "Automatic admin bootstrap skipped (use first signup in UI with admin@local)"
|
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
cat <<EOF >/etc/systemd/system/discourse.service
|
cat <<EOF >/etc/systemd/system/discourse.service
|
||||||
[Unit]
|
[Unit]
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ OPENID_PUBLIC_KEY_PATH=/opt/simplelogin/openid-rsa.pub
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd /opt/simplelogin
|
cd /opt/simplelogin
|
||||||
|
set -a
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source /opt/simplelogin/.env
|
||||||
|
set +a
|
||||||
$STD .venv/bin/flask db upgrade
|
$STD .venv/bin/flask db upgrade
|
||||||
$STD .venv/bin/python init_app.py
|
$STD .venv/bin/python init_app.py
|
||||||
msg_ok "Configured SimpleLogin"
|
msg_ok "Configured SimpleLogin"
|
||||||
@@ -137,6 +141,7 @@ Requires=postgresql.service redis-server.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/simplelogin
|
WorkingDirectory=/opt/simplelogin
|
||||||
|
EnvironmentFile=/opt/simplelogin/.env
|
||||||
ExecStart=/opt/simplelogin/.venv/bin/gunicorn wsgi:app -b 127.0.0.1:7777 -w 2 --timeout 120
|
ExecStart=/opt/simplelogin/.venv/bin/gunicorn wsgi:app -b 127.0.0.1:7777 -w 2 --timeout 120
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
@@ -154,6 +159,7 @@ Requires=postgresql.service redis-server.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/simplelogin
|
WorkingDirectory=/opt/simplelogin
|
||||||
|
EnvironmentFile=/opt/simplelogin/.env
|
||||||
ExecStart=/opt/simplelogin/.venv/bin/python email_handler.py
|
ExecStart=/opt/simplelogin/.venv/bin/python email_handler.py
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
@@ -171,6 +177,7 @@ Requires=postgresql.service redis-server.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/simplelogin
|
WorkingDirectory=/opt/simplelogin
|
||||||
|
EnvironmentFile=/opt/simplelogin/.env
|
||||||
ExecStart=/opt/simplelogin/.venv/bin/python job_runner.py
|
ExecStart=/opt/simplelogin/.venv/bin/python job_runner.py
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|||||||
Reference in New Issue
Block a user