Skip to content

Commit f66a60e

Browse files
MediaManager (#7238)
1 parent b4e74b2 commit f66a60e

File tree

4 files changed

+248
-0
lines changed

4 files changed

+248
-0
lines changed

ct/headers/mediamanager

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__ ___ ___ __ ___
2+
/ |/ /__ ____/ (_)___ _/ |/ /___ _____ ____ _____ ____ _____
3+
/ /|_/ / _ \/ __ / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/
4+
/ / / / __/ /_/ / / /_/ / / / / /_/ / / / / /_/ / /_/ / __/ /
5+
/_/ /_/\___/\__,_/_/\__,_/_/ /_/\__,_/_/ /_/\__,_/\__, /\___/_/
6+
/____/

ct/mediamanager.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: vhsdream
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/maxdorninger/MediaManager
7+
8+
APP="MediaManager"
9+
var_tags="${var_tags:-arr}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-3072}"
12+
var_disk="${var_disk:-4}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-12}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/mediamanager ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
31+
setup_uv
32+
33+
RELEASE=$(curl -fsSL https://api.github.com/repos/maxdorninger/MediaManager/releases/latest | jq '.tag_name' | sed 's/^v//')
34+
if [[ "${RELEASE}" != "$(cat ~/.mediamanager 2>/dev/null)" ]] || [[ ! -f ~/.mediamanager ]]; then
35+
msg_info "Stopping Service"
36+
systemctl stop mediamanager
37+
msg_ok "Stopped Service"
38+
39+
fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
40+
msg_info "Updating ${APP}"
41+
MM_DIR="/opt/mm"
42+
export CONFIG_DIR="${MM_DIR}/config"
43+
export FRONTEND_FILES_DIR="${MM_DIR}/web/build"
44+
export BASE_PATH=""
45+
export PUBLIC_VERSION=""
46+
export PUBLIC_API_URL="${BASE_PATH}/api/v1"
47+
export BASE_PATH="${BASE_PATH}/web"
48+
cd /opt/mediamanager/web
49+
$STD npm ci
50+
$STD npm run build
51+
rm -rf "$FRONTEND_FILES_DIR"/build
52+
cp -r build "$FRONTEND_FILES_DIR"
53+
export BASE_PATH=""
54+
export VIRTUAL_ENV="/opt/${MM_DIR}/venv"
55+
cd /opt/mediamanager
56+
rm -rf "$MM_DIR"/{media_manager,alembic*}
57+
cp -r {media_manager,alembic*} "$MM_DIR"
58+
$STD /usr/local/bin/uv sync --locked --active
59+
msg_ok "Updated $APP"
60+
61+
msg_info "Starting Service"
62+
systemctl start mediamanager
63+
msg_ok "Started Service"
64+
65+
msg_ok "Updated Successfully"
66+
else
67+
msg_ok "Already up to date"
68+
fi
69+
exit
70+
}
71+
72+
start
73+
build_container
74+
description
75+
76+
msg_ok "Completed Successfully!\n"
77+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
78+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
79+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8000${CL}"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "MediaManager",
3+
"slug": "mediamanager",
4+
"categories": [
5+
14,
6+
13
7+
],
8+
"date_created": "2025-07-22",
9+
"type": "ct",
10+
"updateable": true,
11+
"privileged": false,
12+
"interface_port": 8000,
13+
"documentation": "https://maxdorninger.github.io/MediaManager/introduction.html",
14+
"config_path": "/opt/mm_data/config.toml",
15+
"website": "https://github.com/maxdorninger/MediaManager",
16+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/mediamanager.webp",
17+
"description": "A modern selfhosted media management system for your media library",
18+
"install_methods": [
19+
{
20+
"type": "default",
21+
"script": "ct/mediamanager.sh",
22+
"resources": {
23+
"cpu": 2,
24+
"ram": 3072,
25+
"hdd": 4,
26+
"os": "Debian",
27+
"version": "12"
28+
}
29+
}
30+
],
31+
"default_credentials": {
32+
"username": "<email address>",
33+
"password": "admin"
34+
},
35+
"notes": [
36+
{
37+
"text": "During the installation, provide the email address of the first admin user",
38+
"type": "info"
39+
},
40+
{
41+
"text": "You're probably going to want to use a bind mount for the media directories",
42+
"type": "info"
43+
}
44+
]
45+
}

install/mediamanager-install.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2025 Community Scripts ORG
4+
# Author: vhsdream
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/maxdorninger/MediaManager
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
read -r -p "${TAB3}Enter the email address of your first admin user: " admin_email
17+
if [[ "$admin_email" ]]; then
18+
EMAIL="$admin_email"
19+
fi
20+
21+
setup_yq
22+
NODE_VERSION="24" setup_nodejs
23+
setup_uv
24+
PG_VERSION="17" setup_postgresql
25+
26+
msg_info "Setting up PostgreSQL"
27+
DB_NAME="mm_db"
28+
DB_USER="mm_user"
29+
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
30+
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
31+
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;"
32+
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
33+
{
34+
echo "MediaManager Credentials"
35+
echo "MediaManager Database User: $DB_USER"
36+
echo "MediaManager Database Password: $DB_PASS"
37+
echo "MediaManager Database Name: $DB_NAME"
38+
} >>~/mediamanager.creds
39+
msg_ok "Set up PostgreSQL"
40+
41+
fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
42+
43+
msg_info "Configuring MediaManager"
44+
MM_DIR="/opt/mm"
45+
MEDIA_DIR="${MM_DIR}/media"
46+
export CONFIG_DIR="${MM_DIR}/config"
47+
export FRONTEND_FILES_DIR="${MM_DIR}/web/build"
48+
export BASE_PATH=""
49+
export PUBLIC_VERSION=""
50+
export PUBLIC_API_URL="${BASE_PATH}/api/v1"
51+
export BASE_PATH="${BASE_PATH}/web"
52+
cd /opt/mediamanager/web
53+
$STD npm ci
54+
$STD npm run build
55+
mkdir -p {"$MM_DIR"/web,"$MEDIA_DIR","$CONFIG_DIR"}
56+
cp -r build "$FRONTEND_FILES_DIR"
57+
export BASE_PATH=""
58+
export VIRTUAL_ENV="${MM_DIR}/venv"
59+
cd /opt/mediamanager
60+
cp -r {media_manager,alembic*} "$MM_DIR"
61+
$STD /usr/local/bin/uv venv "$VIRTUAL_ENV"
62+
$STD /usr/local/bin/uv sync --locked --active
63+
msg_ok "Configured MediaManager"
64+
65+
msg_info "Creating config and start script"
66+
LOCAL_IP="$(hostname -I | awk '{print $1}')"
67+
SECRET="$(openssl rand -hex 32)"
68+
sed -e "s/localhost:8/$LOCAL_IP:8/g" \
69+
-e "s|/data/|$MEDIA_DIR/|g" \
70+
-e 's/"db"/"localhost"/' \
71+
-e "s/user = \"MediaManager\"/user = \"$DB_USER\"/" \
72+
-e "s/password = \"MediaManager\"/password = \"$DB_PASS\"/" \
73+
-e "s/dbname = \"MediaManager\"/dbname = \"$DB_NAME\"/" \
74+
-e "/^token_secret/s/=.*/= \"$SECRET\"/" \
75+
-e "s/[email protected]/$EMAIL/" \
76+
-e '/^admin_emails/s/, .*/]/' \
77+
/opt/mediamanager/config.example.toml >"$CONFIG_DIR"/config.toml
78+
79+
mkdir -p "$MEDIA_DIR"/{images,tv,movies,torrents}
80+
81+
cat <<EOF >"$MM_DIR"/start.sh
82+
#!/usr/bin/env bash
83+
84+
export CONFIG_DIR="$CONFIG_DIR"
85+
export FRONTEND_FILES_DIR="$FRONTEND_FILES_DIR"
86+
export BASE_PATH=""
87+
cd "$MM_DIR"
88+
source ./venv/bin/activate
89+
/usr/local/bin/uv run alembic upgrade head
90+
/usr/local/bin/uv run fastapi run ./media_manager/main.py --port 8000
91+
EOF
92+
chmod +x "$MM_DIR"/start.sh
93+
msg_ok "Created config and start script"
94+
95+
msg_info "Creating service"
96+
cat <<EOF >/etc/systemd/system/mediamanager.service
97+
[Unit]
98+
Description=MediaManager Backend Service
99+
After=network.target
100+
101+
[Service]
102+
Type=simple
103+
WorkingDirectory=${MM_DIR}
104+
ExecStart=/usr/bin/bash start.sh
105+
106+
[Install]
107+
WantedBy=multi-user.target
108+
EOF
109+
systemctl enable -q --now mediamanager
110+
msg_ok "Created service"
111+
112+
motd_ssh
113+
customize
114+
115+
msg_info "Cleaning up"
116+
$STD apt-get -y autoremove
117+
$STD apt-get -y autoclean
118+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)