tandoor refactor
This commit is contained in:
parent
c99bb7ca6c
commit
d3ebd8b64d
61
ct/tandoor.sh
Normal file
61
ct/tandoor.sh
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2025 tteck
|
||||||
|
# Author: MickLesk (Canbiz)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://tandoor.dev/
|
||||||
|
|
||||||
|
APP="Tandoor"
|
||||||
|
var_tags="${var_tags:-recipes}"
|
||||||
|
var_cpu="${var_cpu:-4}"
|
||||||
|
var_ram="${var_ram:-4096}"
|
||||||
|
var_disk="${var_disk:-10}"
|
||||||
|
var_os="${var_os:-debian}"
|
||||||
|
var_version="${var_version:-12}"
|
||||||
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
check_container_storage
|
||||||
|
check_container_resources
|
||||||
|
if [[ ! -d /opt/tandoor ]]; then
|
||||||
|
msg_error "No ${APP} Installation Found!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
#if ! [[ $(dpkg -s python3-xmlsec 2>/dev/null) ]]; then
|
||||||
|
#$STD apt-get update
|
||||||
|
#$STD apt-get install -y python3-xmlsec
|
||||||
|
#fi
|
||||||
|
#if cd /opt/tandoor && git pull | grep -q 'Already up to date'; then
|
||||||
|
msg_ok "There is currently no update available."
|
||||||
|
#else
|
||||||
|
#msg_info "Updating ${APP} (Patience)"
|
||||||
|
#export $(cat /opt/tandoor/.env | grep "^[^#]" | xargs)
|
||||||
|
#cd /opt/tandoor/
|
||||||
|
#$STD pip3 install -r requirements.txt
|
||||||
|
#$STD /usr/bin/python3 /opt/tandoor/manage.py migrate
|
||||||
|
#$STD /usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input
|
||||||
|
#$STD /usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse
|
||||||
|
#cd /opt/tandoor/vue
|
||||||
|
#$STD yarn install
|
||||||
|
#$STD yarn build
|
||||||
|
#cd /opt/tandoor
|
||||||
|
#$STD python3 version.py
|
||||||
|
#systemctl restart gunicorn_tandoor
|
||||||
|
#msg_ok "Updated ${APP}"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8002${CL}"
|
142
install/tandoor-install.sh
Normal file
142
install/tandoor-install.sh
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2025 tteck
|
||||||
|
# Author: tteck
|
||||||
|
# Co-Author: MickLesk (Canbiz)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://tandoor.dev/
|
||||||
|
|
||||||
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies (Patience)"
|
||||||
|
$STD apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
libpq-dev \
|
||||||
|
libmagic-dev \
|
||||||
|
libzbar0 \
|
||||||
|
nginx \
|
||||||
|
libsasl2-dev \
|
||||||
|
libldap2-dev \
|
||||||
|
libssl-dev \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
libxmlsec1-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libxmlsec1-openssl
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Setup Python3"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
python3 \
|
||||||
|
python3-dev \
|
||||||
|
python3-setuptools \
|
||||||
|
python3-pip \
|
||||||
|
python3-xmlsec
|
||||||
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
|
msg_ok "Setup Python3"
|
||||||
|
|
||||||
|
NODE_VERSION="20" NODE_MODULE="yarn@latest" setup_nodejs
|
||||||
|
fetch_and_deploy_gh_release "tandoor" "TandoorRecipes/recipes" "tarball" "latest" "/opt/tandoor"
|
||||||
|
PG_VERSION="16" setup_postgresql
|
||||||
|
|
||||||
|
msg_info "Set up PostgreSQL Database"
|
||||||
|
DB_NAME=db_recipes
|
||||||
|
DB_USER=tandoor
|
||||||
|
SECRET_KEY=$(openssl rand -base64 45 | sed 's/\//\\\//g')
|
||||||
|
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
|
||||||
|
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
|
||||||
|
$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 client_encoding TO 'utf8';"
|
||||||
|
$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 'UTC'"
|
||||||
|
{
|
||||||
|
echo "Tandoor-Credentials"
|
||||||
|
echo "Tandoor Database Name: $DB_NAME"
|
||||||
|
echo "Tandoor Database User: $DB_USER"
|
||||||
|
echo "Tandoor Database Password: $DB_PASS"
|
||||||
|
} >>~/tandoor.creds
|
||||||
|
msg_ok "Set up PostgreSQL Database"
|
||||||
|
|
||||||
|
msg_info "Setup Tandoor"
|
||||||
|
mkdir -p /opt/tandoor/{config,api,mediafiles,staticfiles}
|
||||||
|
cd /opt/tandoor
|
||||||
|
uv venv .venv --python=python3
|
||||||
|
.venv/bin/uv pip install -r requirements.txt
|
||||||
|
cd /opt/tandoor/vue3
|
||||||
|
$STD yarn install
|
||||||
|
$STD yarn build
|
||||||
|
cat <<EOF >/opt/tandoor/.env
|
||||||
|
SECRET_KEY=$SECRET_KEY
|
||||||
|
TZ=Europe/Berlin
|
||||||
|
|
||||||
|
DB_ENGINE=django.db.backends.postgresql
|
||||||
|
POSTGRES_HOST=localhost
|
||||||
|
POSTGRES_DB=$DB_NAME
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
POSTGRES_USER=$DB_USER
|
||||||
|
POSTGRES_PASSWORD=$DB_PASS
|
||||||
|
EOF
|
||||||
|
.venv/bin/python version.py
|
||||||
|
export $(cat /opt/tandoor/.env | grep "^[^#]" | xargs)
|
||||||
|
.venv/bin/python manage.py migrate
|
||||||
|
.venv/bin/python manage.py collectstatic --no-input
|
||||||
|
.venv/bin/python manage.py collectstatic_js_reverse
|
||||||
|
msg_ok "Installed Tandoor"
|
||||||
|
|
||||||
|
msg_info "Creating Services"
|
||||||
|
cat <<EOF >/etc/systemd/system/gunicorn_tandoor.service
|
||||||
|
[Unit]
|
||||||
|
Description=gunicorn daemon for tandoor
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
WorkingDirectory=/opt/tandoor
|
||||||
|
EnvironmentFile=/opt/tandoor/.env
|
||||||
|
ExecStart=/usr/local/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind unix:/opt/tandoor/tandoor.sock recipes.wsgi:application
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<'EOF' >/etc/nginx/conf.d/tandoor.conf
|
||||||
|
server {
|
||||||
|
listen 8002;
|
||||||
|
#access_log /var/log/nginx/access.log;
|
||||||
|
#error_log /var/log/nginx/error.log;
|
||||||
|
client_max_body_size 128M;
|
||||||
|
# serve media files
|
||||||
|
location /static/ {
|
||||||
|
alias /opt/tandoor/staticfiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /opt/tandoor/mediafiles/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_pass http://unix:/opt/tandoor/tandoor.sock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
systemctl reload nginx
|
||||||
|
systemctl enable -q --now gunicorn_tandoor
|
||||||
|
msg_ok "Created Services"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
Loading…
x
Reference in New Issue
Block a user