Dispatcharr install files

This commit is contained in:
Frederik Botha 2025-07-21 17:16:08 +01:00 committed by Push From Github
parent b1a3b4d3cf
commit 4db639458d
3 changed files with 429 additions and 0 deletions

120
ct/dispatcharr.sh Normal file
View File

@ -0,0 +1,120 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/ekke85/ProxmoxVED/refs/heads/dispatcharr/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: ekke85
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/Dispatcharr/Dispatcharr
APP="Dispatcharr"
APP_NAME=${APP,,}
var_tags="${var_tags:-media;arr}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-1024}"
var_disk="${var_disk:-8}"
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/dispatcharr" ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/Dispatcharr/Dispatcharr/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_ok "Starting update"
APP_DIR="/opt/dispatcharr"
APP_USER="dispatcharr"
APP_GROUP="dispatcharr"
msg_info "Stopping $APP"
systemctl stop dispatcharr-celery
systemctl stop dispatcharr-celerybeat
systemctl stop dispatcharr-daphne
systemctl stop dispatcharr
msg_ok "Stopped $APP"
msg_info "Creating Backup"
BACKUP_FILE="/opt/dispatcharr_$(date +%F).tar.gz"
msg_info "Source and Database backup"
set -o allexport
source /etc/$APP_NAME/$APP_NAME.env
set +o allexport
PGPASSWORD=$POSTGRES_PASSWORD pg_dump -U $POSTGRES_USER -h $POSTGRES_HOST $POSTGRES_DB > /opt/$POSTGRES_DB-`date +%F`.sql
$STD tar -czf "$BACKUP_FILE" /opt/dispatcharr /opt/Dispatcharr_version.txt /opt/$POSTGRES_DB-`date +%F`.sql &>/dev/null
msg_ok "Backup Created"
msg_info "Updating $APP to v${RELEASE}"
rm -rf /opt/dispatcharr
fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr"
chown -R "$APP_USER:$APP_GROUP" "$APP_DIR"
sed -i 's/program\[\x27channel_id\x27\]/program["channel_id"]/g' "${APP_DIR}/apps/output/views.py"
msg_ok "Dispatcharr Updated to $RELEASE"
msg_info "Creating Python Virtual Environment"
cd $APP_DIR
python3 -m venv env
source env/bin/activate
$STD pip install --upgrade pip
$STD pip install -r requirements.txt
$STD pip install gunicorn
ln -sf /usr/bin/ffmpeg $APP_DIR/env/bin/ffmpeg
msg_ok "Python Environment Setup"
msg_info "Building Frontend"
cd $APP_DIR/frontend
$STD npm install --legacy-peer-deps
$STD npm run build
msg_ok "Built Frontend"
msg_info "Running Django Migrations"
cd $APP_DIR
source env/bin/activate
set -o allexport
source /etc/$APP_NAME/$APP_NAME.env
set +o allexport
$STD python manage.py migrate --noinput
$STD python manage.py collectstatic --noinput
msg_ok "Migrations Complete"
msg_info "Starting $APP"
systemctl start dispatcharr-celery
systemctl start dispatcharr-celerybeat
systemctl start dispatcharr-daphne
systemctl start dispatcharr
msg_ok "Started $APP"
echo "${RELEASE}" > "/opt/${APP}_version.txt"
msg_info "Cleaning Up"
rm -rf /opt/$POSTGRES_DB-`date +%F`.sql
msg_ok "Cleanup Completed"
msg_ok "Update Successful, Backup saved to $BACKUP_FILE"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
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}:9191${CL}"

View File

@ -0,0 +1,34 @@
{
"name": "Dispatcharr",
"slug": "dispatcharr",
"categories": [
14
],
"date_created": "2025-07-01",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 9191,
"documentation": "https://dispatcharr.github.io/Dispatcharr-Docs/",
"website": "https://dispatcharr.github.io/Dispatcharr-Docs/",
"logo": "https://raw.githubusercontent.com/Dispatcharr/Dispatcharr/refs/heads/main/frontend/src/images/logo.png",
"description": "Dispatcharr is an open-source powerhouse for managing IPTV streams and EPG data with elegance and control. Born from necessity and built with passion, it started as a personal project by OkinawaBoss and evolved with contributions from legends like dekzter, SergeantPanda and Bucatini.",
"install_methods": [
{
"type": "default",
"script": "ct/dispatcharr.sh",
"resources": {
"cpu": 1,
"ram": 1024,
"hdd": 8,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": []

View File

@ -0,0 +1,275 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: ekke85
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/Dispatcharr/Dispatcharr
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
APPLICATION="Dispatcharr"
APP_NAME="dispatcharr"
APP_USER="dispatcharr"
APP_GROUP="dispatcharr"
APP_DIR="/opt/dispatcharr"
GUNICORN_RUNTIME_DIR="dispatcharr"
GUNICORN_PORT="5656"
NGINX_HTTP_PORT="9191"
WEBSOCKET_PORT="8001"
msg_info "Creating ${APP_USER} user"
groupadd -f $APP_GROUP
useradd -M -s /usr/sbin/nologin -g $APP_GROUP $APP_USER || true
msg_ok "Created ${APP_USER} user"
setup_uv
NODE_VERSION="22" setup_nodejs
PG_VERSION="16" setup_postgresql
msg_info "Installing Dependencies"
$STD apt-get install -y \
git \
curl \
wget \
build-essential \
gcc \
libpcre3-dev \
libpq-dev \
python3-dev \
python3-venv \
python3-pip \
nginx \
redis-server \
ffmpeg \
procps \
streamlink
msg_ok "Installed Dependencies"
msg_info "Configuring PostgreSQL"
POSTGRES_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
{
echo "POSTGRES_DB=dispatcharr"
echo "POSTGRES_USER=dispatch"
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD"
echo "POSTGRES_HOST=localhost"
} >> ~/.$APP_NAME.creds
source ~/.$APP_NAME.creds
su - postgres -c "psql -tc \"SELECT 1 FROM pg_roles WHERE rolname='${POSTGRES_USER}'\"" | grep -q 1 || \
su - postgres -c "psql -c \"CREATE USER ${POSTGRES_USER} WITH PASSWORD '${POSTGRES_PASSWORD}';\""
su - postgres -c "psql -tc \"SELECT 1 FROM pg_database WHERE datname='${POSTGRES_DB}'\"" | grep -q 1 || \
su - postgres -c "psql -c \"CREATE DATABASE ${POSTGRES_DB} OWNER ${POSTGRES_USER};\""
su - postgres -c "psql -d ${POSTGRES_DB} -c \"ALTER SCHEMA public OWNER TO ${POSTGRES_USER};\""
msg_ok "Configured PostgreSQL"
msg_info "Fetching latest Dispatcharr release version"
LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/Dispatcharr/Dispatcharr/releases/latest | grep '"tag_name":' | cut -d '"' -f4)
if [[ -z "$LATEST_VERSION" ]]; then
msg_error "Failed to fetch latest release version from GitHub."
exit 1
fi
msg_info "Downloading Dispatcharr $LATEST_VERSION"
fetch_and_deploy_gh_release "dispatcharr" "Dispatcharr/Dispatcharr"
echo "$LATEST_VERSION" > "/opt/${APPLICATION}_version.txt"
mkdir -p /data/{db,epgs,logos,m3us,recordings,uploads}
mkdir -p /etc/$APP_NAME
cp ~/.$APP_NAME.creds /etc/$APP_NAME/$APP_NAME.env
chown -R "$APP_USER:$APP_GROUP" {/etc/$APP_NAME,$APP_DIR,/data}
sed -i 's/program\[\x27channel_id\x27\]/program["channel_id"]/g' "${APP_DIR}/apps/output/views.py"
msg_ok "Downloaded Dispatcharr $LATEST_VERSION"
msg_info "Install Python Requirements"
cd $APP_DIR
python3 -m venv env
source env/bin/activate
$STD pip install --upgrade pip
$STD pip install -r requirements.txt
$STD pip install gunicorn
ln -sf /usr/bin/ffmpeg $APP_DIR/env/bin/ffmpeg
msg_ok "Python Requirements Installed"
msg_info "Building Frontend"
cd $APP_DIR/frontend
$STD npm install --legacy-peer-deps
$STD npm run build
msg_ok "Built Frontend"
msg_info "Running Django Migrations"
cd $APP_DIR
source env/bin/activate
set -o allexport
source /etc/$APP_NAME/$APP_NAME.env
set +o allexport
$STD python manage.py migrate --noinput
$STD python manage.py collectstatic --noinput
msg_ok "Migrations Complete"
msg_info "Configuring Nginx"
cat <<EOF >/etc/nginx/sites-available/dispatcharr.conf
server {
listen $NGINX_HTTP_PORT;
location / {
include proxy_params;
proxy_pass http://127.0.0.1:$GUNICORN_PORT;
}
location /static/ {
alias $APP_DIR/static/;
}
location /assets/ {
alias $APP_DIR/frontend/dist/assets/;
}
location /media/ {
alias $APP_DIR/media/;
}
location /ws/ {
proxy_pass http://127.0.0.1:$WEBSOCKET_PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host \$host;
}
}
EOF
ln -sf /etc/nginx/sites-available/dispatcharr.conf /etc/nginx/sites-enabled/dispatcharr.conf
rm -f /etc/nginx/sites-enabled/default
nginx -t
systemctl restart nginx
systemctl enable nginx
msg_ok "Configured Nginx"
msg_info "Creating systemd services"
cat <<EOF >/etc/systemd/system/dispatcharr.service
[Unit]
Description=Gunicorn for Dispatcharr
After=network.target postgresql.service redis-server.service
[Service]
User=$APP_USER
Group=$APP_GROUP
WorkingDirectory=$APP_DIR
RuntimeDirectory=$GUNICORN_RUNTIME_DIR
RuntimeDirectoryMode=0775
Environment="PATH=$APP_DIR/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
EnvironmentFile=/etc/$APP_NAME/$APP_NAME.env
ExecStart=$APP_DIR/env/bin/gunicorn \\
--workers=4 \\
--worker-class=gevent \\
--timeout=300 \\
--bind 0.0.0.0:$GUNICORN_PORT \
dispatcharr.wsgi:application
Restart=always
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/dispatcharr-celery.service
[Unit]
Description=Celery Worker for Dispatcharr
After=network.target redis-server.service
Requires=dispatcharr.service
[Service]
User=$APP_USER
Group=$APP_GROUP
WorkingDirectory=$APP_DIR
Environment="PATH=$APP_DIR/env/bin"
EnvironmentFile=/etc/$APP_NAME/$APP_NAME.env
Environment="CELERY_BROKER_URL=redis://localhost:6379/0"
ExecStart=$APP_DIR/env/bin/celery -A dispatcharr worker -l info -c 4
Restart=always
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/dispatcharr-celerybeat.service
[Unit]
Description=Celery Beat Scheduler for Dispatcharr
After=network.target redis-server.service
Requires=dispatcharr.service
[Service]
User=$APP_USER
Group=$APP_GROUP
WorkingDirectory=$APP_DIR
Environment="PATH=$APP_DIR/env/bin"
EnvironmentFile=/etc/$APP_NAME/$APP_NAME.env
Environment="CELERY_BROKER_URL=redis://localhost:6379/0"
ExecStart=$APP_DIR/env/bin/celery -A dispatcharr beat -l info
Restart=always
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/dispatcharr-daphne.service
[Unit]
Description=Daphne for Dispatcharr (ASGI)
After=network.target
Requires=dispatcharr.service
[Service]
User=$APP_USER
Group=$APP_GROUP
WorkingDirectory=$APP_DIR
Environment="PATH=$APP_DIR/env/bin"
EnvironmentFile=/etc/$APP_NAME/$APP_NAME.env
ExecStart=$APP_DIR/env/bin/daphne -b 0.0.0.0 -p $WEBSOCKET_PORT dispatcharr.asgi:application
Restart=always
KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF
msg_ok "Created systemd services"
msg_info "Starting Dispatcharr Services"
systemctl daemon-reexec
systemctl daemon-reload
systemctl enable dispatcharr dispatcharr-celery dispatcharr-celerybeat dispatcharr-daphne
systemctl restart dispatcharr dispatcharr-celery dispatcharr-celerybeat dispatcharr-daphne
msg_ok "Started Dispatcharr Services"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"