MediaManager: tweaks to paths etc

This commit is contained in:
vhsdream 2025-07-27 13:26:42 -04:00
parent 75d00ca6e3
commit 7570643413
2 changed files with 34 additions and 19 deletions

View File

@ -29,14 +29,32 @@ function update_script() {
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/maxdorninger/MediaManager/releases/latest | yq '.tag_name' | sed 's/^v//') RELEASE=$(curl -fsSL https://api.github.com/repos/maxdorninger/MediaManager/releases/latest | yq '.tag_name' | sed 's/^v//')
if [[ "${RELEASE}" != "$(cat ~/.mediamanager 2>/dev/null)" ]] || [[ ! -f ~/.tududi ]]; then if [[ "${RELEASE}" != "$(cat ~/.mediamanager 2>/dev/null)" ]] || [[ ! -f ~/.mediamanager ]]; then
msg_info "Stopping Service" msg_info "Stopping Service"
systemctl stop mediamanager systemctl stop mediamanager
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "latest" "tarball" "/opt/mediamanager" fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
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_ok "Updated $APP"
msg_info "Starting Service" msg_info "Starting Service"

View File

@ -38,8 +38,10 @@ msg_ok "Set up PostgreSQL"
fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager" fetch_and_deploy_gh_release "MediaManager" "maxdorninger/MediaManager" "tarball" "latest" "/opt/mediamanager"
msg_info "Configuring MediaManager" msg_info "Configuring MediaManager"
export CONFIG_DIR="/opt/mm_data/" MM_DIR="/opt/mm"
export FRONTEND_FILES_DIR="/opt/mm_data/web/build" MEDIA_DIR="${MM_DIR}/media"
export CONFIG_DIR="${MM_DIR}/config"
export FRONTEND_FILES_DIR="${MM_DIR}/web/build"
export BASE_PATH="" export BASE_PATH=""
export PUBLIC_VERSION="" export PUBLIC_VERSION=""
export PUBLIC_API_URL="${BASE_PATH}/api/v1" export PUBLIC_API_URL="${BASE_PATH}/api/v1"
@ -47,14 +49,13 @@ export BASE_PATH="${BASE_PATH}/web"
cd /opt/mediamanager/web cd /opt/mediamanager/web
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
mkdir -p "$CONFIG_DIR"/web mkdir -p {"$MM_DIR"/web,"$MEDIA_DIR","$CONFIG_DIR"}
cp -r build "$FRONTEND_FILES_DIR" cp -r build "$FRONTEND_FILES_DIR"
export BASE_PATH="" export BASE_PATH=""
export VIRTUAL_ENV="/opt/mm_data/venv" export VIRTUAL_ENV="${MM_DIR}/venv"
cd /opt/mediamanager cd /opt/mediamanager
cp -r media_manager "$CONFIG_DIR" cp -r {media_manager,alembic*} "$MM_DIR"
cp -r alembic* "$CONFIG_DIR"
$STD /usr/local/bin/uv venv "$VIRTUAL_ENV" $STD /usr/local/bin/uv venv "$VIRTUAL_ENV"
$STD /usr/local/bin/uv sync --locked --active $STD /usr/local/bin/uv sync --locked --active
msg_ok "Configured MediaManager" msg_ok "Configured MediaManager"
@ -67,12 +68,8 @@ fi
msg_info "Creating config and start script" msg_info "Creating config and start script"
LOCAL_IP="$(hostname -I | awk '{print $1}')" LOCAL_IP="$(hostname -I | awk '{print $1}')"
SECRET="$(openssl rand -hex 32)" SECRET="$(openssl rand -hex 32)"
config_file="config.example.toml"
if [[ ! -f /opt/mediamanager/"$config_file" ]]; then
config_file="config.toml"
fi
sed -e "s/localhost:8/$LOCAL_IP:8/g" \ sed -e "s/localhost:8/$LOCAL_IP:8/g" \
-e "s|/data/|$CONFIG_DIR|g" \ -e "s|/data/|$MEDIA_DIR|g" \
-e 's/"db"/"localhost"/' \ -e 's/"db"/"localhost"/' \
-e "s/user = \"MediaManager\"/user = \"$DB_USER\"/" \ -e "s/user = \"MediaManager\"/user = \"$DB_USER\"/" \
-e "s/password = \"MediaManager\"/password = \"$DB_PASS\"/" \ -e "s/password = \"MediaManager\"/password = \"$DB_PASS\"/" \
@ -80,23 +77,23 @@ sed -e "s/localhost:8/$LOCAL_IP:8/g" \
-e "/^token_secret/s/=.*/= \"$SECRET\"/" \ -e "/^token_secret/s/=.*/= \"$SECRET\"/" \
-e "s/admin@example.com/$EMAIL/" \ -e "s/admin@example.com/$EMAIL/" \
-e '/^admin_emails/s/, .*/]/' \ -e '/^admin_emails/s/, .*/]/' \
/opt/mediamanager/"$config_file" >/opt/mm_data/config.toml /opt/mediamanager/config.example.toml >/opt/"$CONFIG_DIR"/config.toml
mkdir -p "$CONFIG_DIR"/{images,tv,movies,torrents} mkdir -p "$MEDIA_DIR"/{images,tv,movies,torrents}
cat <<EOF >/opt/mm_data/start.sh cat <<EOF >/opt/"$MM_DIR"/start.sh
#!/usr/bin/env bash #!/usr/bin/env bash
export CONFIG_DIR="$CONFIG_DIR" export CONFIG_DIR="$CONFIG_DIR"
export FRONTEND_FILES_DIR="$FRONTEND_FILES_DIR" export FRONTEND_FILES_DIR="$FRONTEND_FILES_DIR"
export BASE_PATH="" export BASE_PATH=""
cd /opt/mm_data cd /opt/"$MM_DIR"
source ./venv/bin/activate source ./venv/bin/activate
/usr/local/bin/uv run alembic upgrade head /usr/local/bin/uv run alembic upgrade head
/usr/local/bin/uv run fastapi run ./media_manager/main.py --port 8000 /usr/local/bin/uv run fastapi run ./media_manager/main.py --port 8000
EOF EOF
chmod +x /opt/mm_data/start.sh chmod +x /opt/"$MM_DIR"/start.sh
msg_ok "Created config and start script" msg_ok "Created config and start script"
msg_info "Creating service" msg_info "Creating service"
@ -107,7 +104,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
WorkingDirectory=/opt/mm_data WorkingDirectory=/opt/"$MM_DIR"
ExecStart=/usr/bin/bash start.sh ExecStart=/usr/bin/bash start.sh
[Install] [Install]