feat: add Postiz app, fix silent() for || fallbacks

This commit is contained in:
MickLesk 2026-02-22 17:46:38 +01:00
parent 286b148911
commit 155c0a00e4
6 changed files with 332 additions and 52 deletions

82
ct/postiz.sh Normal file
View File

@ -0,0 +1,82 @@
#!/usr/bin/env bash
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main}"
source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://github.com/gitroomhq/postiz-app
APP="Postiz"
var_tags="${var_tags:-social-media;scheduling;automation}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-8192}"
var_disk="${var_disk:-20}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
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/postiz ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "postiz" "gitroomhq/postiz-app"; then
msg_info "Stopping Services"
systemctl stop postiz-orchestrator postiz-frontend postiz-backend
msg_ok "Stopped Services"
msg_info "Backing up Data"
cp /opt/postiz/.env /opt/postiz_env.bak
cp -r /opt/postiz/uploads /opt/postiz_uploads.bak 2>/dev/null || true
msg_ok "Backed up Data"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "postiz" "gitroomhq/postiz-app" "tarball"
msg_info "Building Application"
cd /opt/postiz
cp /opt/postiz_env.bak /opt/postiz/.env
set -a && source /opt/postiz/.env && set +a
export NODE_OPTIONS="--max-old-space-size=4096"
$STD pnpm install
$STD pnpm run build
unset NODE_OPTIONS
msg_ok "Built Application"
msg_info "Running Database Migrations"
cd /opt/postiz
$STD pnpm run prisma-db-push
msg_ok "Ran Database Migrations"
msg_info "Restoring Data"
mkdir -p /opt/postiz/uploads
cp -r /opt/postiz_uploads.bak/. /opt/postiz/uploads 2>/dev/null || true
rm -f /opt/postiz_env.bak
rm -rf /opt/postiz_uploads.bak
msg_ok "Restored Data"
msg_info "Starting Services"
systemctl start postiz-backend postiz-frontend postiz-orchestrator
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
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}${CL}"

View File

@ -0,0 +1,44 @@
{
"name": "Postiz",
"slug": "postiz",
"categories": [
19
],
"date_created": "2026-02-22",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 80,
"documentation": "https://docs.postiz.com/",
"website": "https://postiz.com/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/postiz.webp",
"config_path": "/opt/postiz/.env",
"description": "Postiz is an AI-powered social media scheduling tool for managing posts, building audiences, and growing your business across platforms like X, LinkedIn, Instagram, TikTok, Reddit, and more.",
"install_methods": [
{
"type": "default",
"script": "ct/postiz.sh",
"resources": {
"cpu": 4,
"ram": 8192,
"hdd": 20,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "The build process requires significant RAM (4GB+). Do not reduce container RAM below 4GB.",
"type": "warning"
},
{
"text": "NEXT_PUBLIC_* variables are baked at build time. If you change the IP/URL, rebuild with: cd /opt/postiz && pnpm run build",
"type": "info"
}
]
}

197
install/postiz-install.sh Normal file
View File

@ -0,0 +1,197 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://github.com/gitroomhq/postiz-app
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential \
python3 \
redis-server \
nginx
msg_ok "Installed Dependencies"
PG_VERSION="17" setup_postgresql
PG_DB_NAME="postiz" PG_DB_USER="postiz" setup_postgresql_db
NODE_VERSION="22" setup_nodejs
msg_info "Installing pnpm"
$STD npm install -g pnpm@10.6.1
msg_ok "Installed pnpm"
fetch_and_deploy_gh_release "temporal" "temporalio/cli" "prebuild" "latest" "/opt/temporal" "temporal_cli_*_linux_amd64.tar.gz"
chmod +x /opt/temporal/temporal
fetch_and_deploy_gh_release "postiz" "gitroomhq/postiz-app" "tarball"
msg_info "Configuring Application"
JWT_SECRET=$(openssl rand -base64 32)
mkdir -p /opt/postiz/uploads
cat <<EOF >/opt/postiz/.env
DATABASE_URL=postgresql://${PG_DB_USER}:${PG_DB_PASS}@localhost:5432/${PG_DB_NAME}
REDIS_URL=redis://localhost:6379
JWT_SECRET=${JWT_SECRET}
MAIN_URL=http://${LOCAL_IP}
FRONTEND_URL=http://${LOCAL_IP}
NEXT_PUBLIC_BACKEND_URL=http://${LOCAL_IP}/api
BACKEND_INTERNAL_URL=http://localhost:3000
TEMPORAL_ADDRESS=localhost:7233
IS_GENERAL=true
STORAGE_PROVIDER=local
UPLOAD_DIRECTORY=/opt/postiz/uploads
NEXT_PUBLIC_UPLOAD_DIRECTORY=/uploads
NX_ADD_PLUGINS=false
EOF
msg_ok "Configured Application"
msg_info "Building Application"
cd /opt/postiz
set -a && source /opt/postiz/.env && set +a
export NODE_OPTIONS="--max-old-space-size=4096"
$STD pnpm install
$STD pnpm run build
unset NODE_OPTIONS
msg_ok "Built Application"
msg_info "Running Database Migrations"
cd /opt/postiz
set -a && source /opt/postiz/.env && set +a
$STD pnpm run prisma-db-push
msg_ok "Ran Database Migrations"
msg_info "Creating Services"
PNPM_BIN="$(command -v pnpm)"
cat <<EOF >/etc/systemd/system/postiz-temporal.service
[Unit]
Description=Temporal Dev Server (Postiz)
After=network.target
[Service]
Type=simple
User=root
ExecStart=/opt/temporal/temporal server start-dev --db-filename /opt/temporal/temporal.db --log-format json --log-level warn
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/postiz-backend.service
[Unit]
Description=Postiz Backend
After=network.target postgresql.service redis-server.service postiz-temporal.service
Requires=postgresql.service redis-server.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/postiz
EnvironmentFile=/opt/postiz/.env
ExecStart=${PNPM_BIN} run start:prod:backend
Environment=NODE_OPTIONS=--max-old-space-size=512
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/postiz-frontend.service
[Unit]
Description=Postiz Frontend
After=network.target postiz-backend.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/postiz
EnvironmentFile=/opt/postiz/.env
Environment=PORT=4200
ExecStart=${PNPM_BIN} run start:prod:frontend
Environment=NODE_OPTIONS=--max-old-space-size=512
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/postiz-orchestrator.service
[Unit]
Description=Postiz Orchestrator
After=network.target postiz-temporal.service postiz-backend.service
Requires=postiz-temporal.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/postiz
EnvironmentFile=/opt/postiz/.env
ExecStart=${PNPM_BIN} run start:prod:orchestrator
Environment=NODE_OPTIONS=--max-old-space-size=384
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now redis-server postiz-temporal postiz-backend postiz-frontend postiz-orchestrator
msg_ok "Created Services"
msg_info "Configuring Nginx"
cat <<EOF >/etc/nginx/sites-available/postiz
server {
listen 80 default_server;
server_name _;
client_max_body_size 100M;
location /api/ {
proxy_pass http://127.0.0.1:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /uploads {
alias /opt/postiz/uploads;
}
location / {
proxy_pass http://127.0.0.1:4200;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF
ln -sf /etc/nginx/sites-available/postiz /etc/nginx/sites-enabled/postiz
rm -f /etc/nginx/sites-enabled/default
$STD nginx -t
$STD systemctl enable --now nginx
msg_ok "Configured Nginx"
motd_ssh
customize
cleanup_lxc

View File

@ -14,14 +14,15 @@ network_check
update_os update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt install -y \
build-essential \ build-essential \
python3-dev \ python3-dev \
libffi-dev \ libffi-dev \
libssl-dev libssl-dev
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
UV_VERSION="0.7.19" PYTHON_VERSION="3.12" setup_uv #UV_VERSION="0.7.19"
PYTHON_VERSION="3.12" setup_uv
NODE_VERSION="22" setup_nodejs NODE_VERSION="22" setup_nodejs
msg_info "Creating directories" msg_info "Creating directories"

View File

@ -53,23 +53,6 @@ NODE_ENV=production
EOF EOF
msg_ok "Configured Application" msg_ok "Configured Application"
msg_info "Tuning Services"
# Redis: cap memory at 64MB with LRU eviction
cat <<EOF >>/etc/redis/redis.conf
maxmemory 64mb
maxmemory-policy noeviction
EOF
systemctl restart redis-server
# PostgreSQL: optimize for low-memory LXC
PG_CONF="/etc/postgresql/16/main/postgresql.conf"
sed -i "s/^shared_buffers.*/shared_buffers = 128MB/" "$PG_CONF"
sed -i "s/^#work_mem.*/work_mem = 4MB/" "$PG_CONF"
sed -i "s/^#effective_cache_size.*/effective_cache_size = 256MB/" "$PG_CONF"
sed -i "s/^#maintenance_work_mem.*/maintenance_work_mem = 64MB/" "$PG_CONF"
systemctl restart postgresql
msg_ok "Tuned Services"
msg_info "Running Database Migrations" msg_info "Running Database Migrations"
cd /opt/twenty/packages/twenty-server cd /opt/twenty/packages/twenty-server
set -a && source /opt/twenty/.env && set +a set -a && source /opt/twenty/.env && set +a

View File

@ -480,21 +480,20 @@ log_section() {
# silent() # silent()
# #
# - Executes command with output redirected to active log file # - Executes command with output redirected to active log file
# - On error: displays last 10 lines of log and exits with original exit code # - On error: returns the exit code (does NOT exit) so || fallbacks work
# - When no || fallback is present, set -e / ERR trap (error_handler) will
# catch the non-zero return and handle error reporting + script termination
# - Temporarily disables error trap to capture exit code correctly # - Temporarily disables error trap to capture exit code correctly
# - Sources explain_exit_code() for detailed error messages
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
silent() { silent() {
local cmd="$*"
local caller_line="${BASH_LINENO[0]:-unknown}"
local logfile="$(get_active_logfile)" local logfile="$(get_active_logfile)"
# Dryrun mode: Show command without executing # Dryrun mode: Show command without executing
if [[ "${DEV_MODE_DRYRUN:-false}" == "true" ]]; then if [[ "${DEV_MODE_DRYRUN:-false}" == "true" ]]; then
if declare -f msg_custom >/dev/null 2>&1; then if declare -f msg_custom >/dev/null 2>&1; then
msg_custom "🔍" "${BL}" "[DRYRUN] $cmd" msg_custom "🔍" "${BL}" "[DRYRUN] $*"
else else
echo "[DRYRUN] $cmd" >&2 echo "[DRYRUN] $*" >&2
fi fi
return 0 return 0
fi fi
@ -508,33 +507,7 @@ silent() {
set -Eeuo pipefail set -Eeuo pipefail
trap 'error_handler' ERR trap 'error_handler' ERR
if [[ $rc -ne 0 ]]; then return "$rc"
# Source explain_exit_code if needed
if ! declare -f explain_exit_code >/dev/null 2>&1; then
source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/error_handler.func")
fi
local explanation
explanation="$(explain_exit_code "$rc")"
printf "\e[?25h"
msg_error "in line ${caller_line}: exit code ${rc} (${explanation})"
msg_custom "→" "${YWB}" "${cmd}"
if [[ -s "$logfile" ]]; then
local log_lines=$(wc -l <"$logfile")
echo "--- Last 10 lines of silent log ---"
tail -n 10 "$logfile"
echo "-----------------------------------"
# Show how to view full log if there are more lines
if [[ $log_lines -gt 10 ]]; then
msg_custom "📋" "${YW}" "View full log (${log_lines} lines): ${logfile}"
fi
fi
exit "$rc"
fi
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------