mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	MediaManager (#7238)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							b4e74b2a17
						
					
				
				
					commit
					f66a60ee47
				
			
							
								
								
									
										6
									
								
								ct/headers/mediamanager
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								ct/headers/mediamanager
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
    __  ___         ___       __  ___                                 
 | 
			
		||||
   /  |/  /__  ____/ (_)___ _/  |/  /___ _____  ____ _____ ____  _____
 | 
			
		||||
  / /|_/ / _ \/ __  / / __ `/ /|_/ / __ `/ __ \/ __ `/ __ `/ _ \/ ___/
 | 
			
		||||
 / /  / /  __/ /_/ / / /_/ / /  / / /_/ / / / / /_/ / /_/ /  __/ /    
 | 
			
		||||
/_/  /_/\___/\__,_/_/\__,_/_/  /_/\__,_/_/ /_/\__,_/\__, /\___/_/     
 | 
			
		||||
                                                   /____/             
 | 
			
		||||
							
								
								
									
										79
									
								
								ct/mediamanager.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								ct/mediamanager.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
			
		||||
# Copyright (c) 2021-2025 community-scripts ORG
 | 
			
		||||
# Author: vhsdream
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
# Source: https://github.com/maxdorninger/MediaManager
 | 
			
		||||
 | 
			
		||||
APP="MediaManager"
 | 
			
		||||
var_tags="${var_tags:-arr}"
 | 
			
		||||
var_cpu="${var_cpu:-2}"
 | 
			
		||||
var_ram="${var_ram:-3072}"
 | 
			
		||||
var_disk="${var_disk:-4}"
 | 
			
		||||
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/mediamanager ]]; then
 | 
			
		||||
    msg_error "No ${APP} Installation Found!"
 | 
			
		||||
    exit
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  setup_uv
 | 
			
		||||
 | 
			
		||||
  RELEASE=$(curl -fsSL https://api.github.com/repos/maxdorninger/MediaManager/releases/latest | jq '.tag_name' | sed 's/^v//')
 | 
			
		||||
  if [[ "${RELEASE}" != "$(cat ~/.mediamanager 2>/dev/null)" ]] || [[ ! -f ~/.mediamanager ]]; then
 | 
			
		||||
    msg_info "Stopping Service"
 | 
			
		||||
    systemctl stop mediamanager
 | 
			
		||||
    msg_ok "Stopped Service"
 | 
			
		||||
 | 
			
		||||
    fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
 | 
			
		||||
    msg_info "Updating ${APP}"
 | 
			
		||||
    MM_DIR="/opt/mm"
 | 
			
		||||
    export CONFIG_DIR="${MM_DIR}/config"
 | 
			
		||||
    export FRONTEND_FILES_DIR="${MM_DIR}/web/build"
 | 
			
		||||
    export BASE_PATH=""
 | 
			
		||||
    export PUBLIC_VERSION=""
 | 
			
		||||
    export PUBLIC_API_URL="${BASE_PATH}/api/v1"
 | 
			
		||||
    export BASE_PATH="${BASE_PATH}/web"
 | 
			
		||||
    cd /opt/mediamanager/web
 | 
			
		||||
    $STD npm ci
 | 
			
		||||
    $STD npm run build
 | 
			
		||||
    rm -rf "$FRONTEND_FILES_DIR"/build
 | 
			
		||||
    cp -r build "$FRONTEND_FILES_DIR"
 | 
			
		||||
    export BASE_PATH=""
 | 
			
		||||
    export VIRTUAL_ENV="/opt/${MM_DIR}/venv"
 | 
			
		||||
    cd /opt/mediamanager
 | 
			
		||||
    rm -rf "$MM_DIR"/{media_manager,alembic*}
 | 
			
		||||
    cp -r {media_manager,alembic*} "$MM_DIR"
 | 
			
		||||
    $STD /usr/local/bin/uv sync --locked --active
 | 
			
		||||
    msg_ok "Updated $APP"
 | 
			
		||||
 | 
			
		||||
    msg_info "Starting Service"
 | 
			
		||||
    systemctl start mediamanager
 | 
			
		||||
    msg_ok "Started Service"
 | 
			
		||||
 | 
			
		||||
    msg_ok "Updated Successfully"
 | 
			
		||||
  else
 | 
			
		||||
    msg_ok "Already up to date"
 | 
			
		||||
  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}:8000${CL}"
 | 
			
		||||
							
								
								
									
										45
									
								
								frontend/public/json/mediamanager.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								frontend/public/json/mediamanager.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "MediaManager",
 | 
			
		||||
  "slug": "mediamanager",
 | 
			
		||||
  "categories": [
 | 
			
		||||
    14,
 | 
			
		||||
    13
 | 
			
		||||
  ],
 | 
			
		||||
  "date_created": "2025-07-22",
 | 
			
		||||
  "type": "ct",
 | 
			
		||||
  "updateable": true,
 | 
			
		||||
  "privileged": false,
 | 
			
		||||
  "interface_port": 8000,
 | 
			
		||||
  "documentation": "https://maxdorninger.github.io/MediaManager/introduction.html",
 | 
			
		||||
  "config_path": "/opt/mm_data/config.toml",
 | 
			
		||||
  "website": "https://github.com/maxdorninger/MediaManager",
 | 
			
		||||
  "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/mediamanager.webp",
 | 
			
		||||
  "description": "A modern selfhosted media management system for your media library",
 | 
			
		||||
  "install_methods": [
 | 
			
		||||
    {
 | 
			
		||||
      "type": "default",
 | 
			
		||||
      "script": "ct/mediamanager.sh",
 | 
			
		||||
      "resources": {
 | 
			
		||||
        "cpu": 2,
 | 
			
		||||
        "ram": 3072,
 | 
			
		||||
        "hdd": 4,
 | 
			
		||||
        "os": "Debian",
 | 
			
		||||
        "version": "12"
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "default_credentials": {
 | 
			
		||||
    "username": "<email address>",
 | 
			
		||||
    "password": "admin"
 | 
			
		||||
  },
 | 
			
		||||
  "notes": [
 | 
			
		||||
    {
 | 
			
		||||
      "text": "During the installation, provide the email address of the first admin user",
 | 
			
		||||
      "type": "info"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "text": "You're probably going to want to use a bind mount for the media directories",
 | 
			
		||||
      "type": "info"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										118
									
								
								install/mediamanager-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								install/mediamanager-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
# Copyright (c) 2025 Community Scripts ORG
 | 
			
		||||
# Author: vhsdream
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
# Source: https://github.com/maxdorninger/MediaManager
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
 | 
			
		||||
color
 | 
			
		||||
verb_ip6
 | 
			
		||||
catch_errors
 | 
			
		||||
setting_up_container
 | 
			
		||||
network_check
 | 
			
		||||
update_os
 | 
			
		||||
 | 
			
		||||
read -r -p "${TAB3}Enter the email address of your first admin user: " admin_email
 | 
			
		||||
if [[ "$admin_email" ]]; then
 | 
			
		||||
  EMAIL="$admin_email"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
setup_yq
 | 
			
		||||
NODE_VERSION="24" setup_nodejs
 | 
			
		||||
setup_uv
 | 
			
		||||
PG_VERSION="17" setup_postgresql
 | 
			
		||||
 | 
			
		||||
msg_info "Setting up PostgreSQL"
 | 
			
		||||
DB_NAME="mm_db"
 | 
			
		||||
DB_USER="mm_user"
 | 
			
		||||
DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | 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';"
 | 
			
		||||
{
 | 
			
		||||
  echo "MediaManager Credentials"
 | 
			
		||||
  echo "MediaManager Database User: $DB_USER"
 | 
			
		||||
  echo "MediaManager Database Password: $DB_PASS"
 | 
			
		||||
  echo "MediaManager Database Name: $DB_NAME"
 | 
			
		||||
} >>~/mediamanager.creds
 | 
			
		||||
msg_ok "Set up PostgreSQL"
 | 
			
		||||
 | 
			
		||||
fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
 | 
			
		||||
 | 
			
		||||
msg_info "Configuring MediaManager"
 | 
			
		||||
MM_DIR="/opt/mm"
 | 
			
		||||
MEDIA_DIR="${MM_DIR}/media"
 | 
			
		||||
export CONFIG_DIR="${MM_DIR}/config"
 | 
			
		||||
export FRONTEND_FILES_DIR="${MM_DIR}/web/build"
 | 
			
		||||
export BASE_PATH=""
 | 
			
		||||
export PUBLIC_VERSION=""
 | 
			
		||||
export PUBLIC_API_URL="${BASE_PATH}/api/v1"
 | 
			
		||||
export BASE_PATH="${BASE_PATH}/web"
 | 
			
		||||
cd /opt/mediamanager/web
 | 
			
		||||
$STD npm ci
 | 
			
		||||
$STD npm run build
 | 
			
		||||
mkdir -p {"$MM_DIR"/web,"$MEDIA_DIR","$CONFIG_DIR"}
 | 
			
		||||
cp -r build "$FRONTEND_FILES_DIR"
 | 
			
		||||
export BASE_PATH=""
 | 
			
		||||
export VIRTUAL_ENV="${MM_DIR}/venv"
 | 
			
		||||
cd /opt/mediamanager
 | 
			
		||||
cp -r {media_manager,alembic*} "$MM_DIR"
 | 
			
		||||
$STD /usr/local/bin/uv venv "$VIRTUAL_ENV"
 | 
			
		||||
$STD /usr/local/bin/uv sync --locked --active
 | 
			
		||||
msg_ok "Configured MediaManager"
 | 
			
		||||
 | 
			
		||||
msg_info "Creating config and start script"
 | 
			
		||||
LOCAL_IP="$(hostname -I | awk '{print $1}')"
 | 
			
		||||
SECRET="$(openssl rand -hex 32)"
 | 
			
		||||
sed -e "s/localhost:8/$LOCAL_IP:8/g" \
 | 
			
		||||
  -e "s|/data/|$MEDIA_DIR/|g" \
 | 
			
		||||
  -e 's/"db"/"localhost"/' \
 | 
			
		||||
  -e "s/user = \"MediaManager\"/user = \"$DB_USER\"/" \
 | 
			
		||||
  -e "s/password = \"MediaManager\"/password = \"$DB_PASS\"/" \
 | 
			
		||||
  -e "s/dbname = \"MediaManager\"/dbname = \"$DB_NAME\"/" \
 | 
			
		||||
  -e "/^token_secret/s/=.*/= \"$SECRET\"/" \
 | 
			
		||||
  -e "s/admin@example.com/$EMAIL/" \
 | 
			
		||||
  -e '/^admin_emails/s/, .*/]/' \
 | 
			
		||||
  /opt/mediamanager/config.example.toml >"$CONFIG_DIR"/config.toml
 | 
			
		||||
 | 
			
		||||
mkdir -p "$MEDIA_DIR"/{images,tv,movies,torrents}
 | 
			
		||||
 | 
			
		||||
cat <<EOF >"$MM_DIR"/start.sh
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
export CONFIG_DIR="$CONFIG_DIR"
 | 
			
		||||
export FRONTEND_FILES_DIR="$FRONTEND_FILES_DIR"
 | 
			
		||||
export BASE_PATH=""
 | 
			
		||||
cd "$MM_DIR"
 | 
			
		||||
source ./venv/bin/activate
 | 
			
		||||
/usr/local/bin/uv run alembic upgrade head
 | 
			
		||||
/usr/local/bin/uv run fastapi run ./media_manager/main.py --port 8000
 | 
			
		||||
EOF
 | 
			
		||||
chmod +x "$MM_DIR"/start.sh
 | 
			
		||||
msg_ok "Created config and start script"
 | 
			
		||||
 | 
			
		||||
msg_info "Creating service"
 | 
			
		||||
cat <<EOF >/etc/systemd/system/mediamanager.service
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=MediaManager Backend Service
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
WorkingDirectory=${MM_DIR}
 | 
			
		||||
ExecStart=/usr/bin/bash start.sh
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
EOF
 | 
			
		||||
systemctl enable -q --now mediamanager
 | 
			
		||||
msg_ok "Created service"
 | 
			
		||||
 | 
			
		||||
motd_ssh
 | 
			
		||||
customize
 | 
			
		||||
 | 
			
		||||
msg_info "Cleaning up"
 | 
			
		||||
$STD apt-get -y autoremove
 | 
			
		||||
$STD apt-get -y autoclean
 | 
			
		||||
msg_ok "Cleaned"
 | 
			
		||||
		Reference in New Issue
	
	Block a user