Compare commits

..

No commits in common. "526b5e7b54290c6705c0270a5604f2a06d51549c" and "6dc6d3cb14f2f5d51acbead405b5421d3b00b563" have entirely different histories.

1 changed files with 15 additions and 12 deletions

View File

@ -16,6 +16,7 @@ update_os
msg_info "Installing Dependencies (Patience)" msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y --no-install-recommends \ $STD apt-get install -y --no-install-recommends \
postgresql \
build-essential \ build-essential \
libpq-dev \ libpq-dev \
libmagic-dev \ libmagic-dev \
@ -60,27 +61,29 @@ cd /opt/tandoor/vue
$STD yarn install $STD yarn install
$STD yarn build $STD yarn build
wget -q https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O /opt/tandoor/.env wget -q https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O /opt/tandoor/.env
DB_NAME=db_recipes DB_NAME=djangodb
DB_USER=tandoor DB_USER=djangouser
DB_ENCODING=utf8 DB_ENCODING=utf8
DB_TIMEZONE=UTC DB_TIMEZONE=UTC
secret_key=$(openssl rand -base64 45 | sed 's/\//\\\//g') secret_key=$(openssl rand -base64 45 | sed 's/\//\\\//g')
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
sed -i -e "s|SECRET_KEY=.*|SECRET_KEY=$secret_key|g" \ sed -i -e "s|SECRET_KEY=.*|SECRET_KEY=$secret_key|g" \
-e "s|POSTGRES_HOST=.*|POSTGRES_HOST=localhost|g" \ -e "s|POSTGRES_HOST=.*|POSTGRES_HOST=127.0.0.1|g" \
-e "s|POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$DB_PASS|g" \ -e "s|POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$DB_PASS|g" \
-e "s|POSTGRES_DB=.*|POSTGRES_DB=$DB_NAME|g" \ -e "s|POSTGRES_DB=.*|POSTGRES_DB=$DB_NAME|g" \
-e "s|POSTGRES_USER=.*|POSTGRES_USER=$DB_USER|g" \ -e "s|POSTGRES_USER=.*|POSTGRES_USER=$DB_USER|g" \
-e "\$a\STATIC_URL=/staticfiles/" /opt/tandoor/.env -e "\$a\STATIC_URL=/staticfiles\\nMEDIA_URL=/mediafiles" /opt/tandoor/.env
msg_ok "Installed Tandoor" msg_ok "Installed Tandoor"
msg_info "Install/Set up PostgreSQL Database" msg_info "Setting up PostgreSQL database"
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list $STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
$STD apt-get update $STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
$STD apt-get install -y postgresql-16 $STD sudo -u postgres psql -c "ALTER DATABASE $DB_NAME OWNER TO $DB_USER;"
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO $DB_ENCODING;"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO $DB_TIMEZONE;"
$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;"
echo "" >>~/tandoor.creds echo "" >>~/tandoor.creds
echo -e "Tandoor Database Name: \e[32m$DB_NAME\e[0m" >>~/tandoor.creds echo -e "Tandoor Database Name: \e[32m$DB_NAME\e[0m" >>~/tandoor.creds
echo -e "Tandoor Database User: \e[32m$DB_USER\e[0m" >>~/tandoor.creds echo -e "Tandoor Database User: \e[32m$DB_USER\e[0m" >>~/tandoor.creds
@ -89,7 +92,7 @@ export $(cat /opt/tandoor/.env |grep "^[^#]" | xargs)
/usr/bin/python3 /opt/tandoor/manage.py migrate >/dev/null 2>&1 /usr/bin/python3 /opt/tandoor/manage.py migrate >/dev/null 2>&1
/usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input >/dev/null 2>&1 /usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input >/dev/null 2>&1
/usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse >/dev/null 2>&1 /usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse >/dev/null 2>&1
msg_ok "Set up PostgreSQL Database" msg_ok "Set up PostgreSQL database"
msg_info "Creating Services" msg_info "Creating Services"
cat <<EOF >/etc/systemd/system/gunicorn_tandoor.service cat <<EOF >/etc/systemd/system/gunicorn_tandoor.service