Skip to content

Instantly share code, notes, and snippets.

@chrisfu
Last active September 19, 2023 11:01
Show Gist options
  • Save chrisfu/7a7a6a4229704b8b187eefd19185ff44 to your computer and use it in GitHub Desktop.
Save chrisfu/7a7a6a4229704b8b187eefd19185ff44 to your computer and use it in GitHub Desktop.
Jellyfin Modify Metadata for index.html to prevent site deceptive site warning in Google
#!/bin/bash
TMP_RELAPATH=index.html.tmp
DEST_RELAPATH=jellyfin/jellyfin-web/index.html
CONTAINER_NAME=jellyfin
USER=plex
GROUP=plex
# Copy source index.html from running Jellyfin instance
docker cp ${CONTAINER_NAME}:/jellyfin/jellyfin-web/index.html ./${TMP_RELAPATH}
# Generate a random string of 32 characters
RANDOM_STRING=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# Replace meta tag content with the random string in index.html
sed -i 's/\(<meta name="[^"]*"\s*content="\)[^"]*"/\1'"$RANDOM_STRING"'"/g; s/\(<meta property="[^"]*"\s*content="\)[^"]*"/\1'"$RANDOM_STRING"'"/g' ./${TMP_RELAPATH}
# Copy temporary index into destination and cleanup
cp ./${TMP_RELAPATH} ./${DEST_RELAPATH} && \
chown -R ${USER}:${GROUP} ./${DEST_RELAPATH} && \
rm -f ./${TMP_RELAPATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment