Welcome to Sock Darning! Have a sock with a thinning heel or a toe hole you want to fix? Share your damage maps, yarn blend questions, and stitch experiments with other darning-minded visitors. Reading along is welcome too, so pull up a chair and join the conversation.

Plex Reclaim Server

  • Thread starter Thread starter Austin Songer, CISSP
  • Start date Start date
A

Austin Songer, CISSP

Guest
reclaim.sh

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Show hidden characters

#!/bin/bash
prefFile="$(readlink -f "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml")"
echo "Please go to https://plex.tv/claim in order to obtain a new claim-code, then type it below"
echo -n "Claim Code: "
read PLEX_CLAIM
clientId=$(sed -n 's/.*ProcessedMachineIdentifier="\(\S*\)".*/\1/p' "${prefFile}")
loginInfo="$(curl -X POST \
-H "X-Plex-Client-Identifier: ${clientId}" \
-H "X-Plex-Product: Plex Media Server" \
-H "X-Plex-Version: 1.1" \
-H "X-Plex-Provides: server" \
-H "X-Plex-Platform: Linux" \
-H "X-Plex-Platform-Version: 1.0" \
-H "X-Plex-Device-Name: PlexMediaServer" \
-H "X-Plex-Device: Linux" \
"https://plex.tv/api/claim/exchange?token=${PLEX_CLAIM}")"
token=$(echo "$loginInfo" | sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p')
if [ "$token" ]; then
echo "Token obtained successfully"
sed -i "s|PlexOnlineToken=\"[^\"]*\"|PlexOnlineToken=\"${token}\"|" "${prefFile}"
echo "Plex claim token installed successfully."
# Restart Plex Media Server
echo "Restarting Plex Media Server..."
sudo systemctl restart plexmediaserver
if [ $? -eq 0 ]; then
echo "Plex Media Server restarted successfully."
else
echo "Failed to restart Plex Media Server."
fi
else
echo "Failed to obtain token. Please check the claim code and try again."
fi
 
Top