Skip to content

Commit

Permalink
v4.5.0 Bug fixes and new functionality
Browse files Browse the repository at this point in the history
1. Fixed bug introduced in Plex back end causing null data fields
2. Added command line option for modifying MinimumAge variable
3. Tweaked how TodaysDate variable is captured
4. Tweaked how long SrceFolder variables are displayed
  • Loading branch information
michealespinola authored Aug 21, 2024
1 parent 23f50ba commit 6f09d25
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions syno.plexupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exec > >(tee "$SrceFllPth.log") 2>"$SrceFllPth.debug"
set -x

# SCRIPT VERSION
SPUScrpVer=4.4.1
SPUScrpVer=4.5.0
MinDSMVers=7.0
# PRINT OUR GLORIOUS HEADER BECAUSE WE ARE FULL OF OURSELVES
printf "\n"
Expand Down Expand Up @@ -59,24 +59,28 @@ if [ -f "$SrceFolder/config.ini" ]; then
source "$SrceFolder/config.ini"
fi

# Allow an override of the timeout on the CLI
while getopts ":a:" arg; do
case $arg in
# OVERRIDE SETTINGS WITH CLI OPTIONS
while getopts ":a:" opt; do
case ${opt} in
a)
case $OPTARG in
'' | *[!0-9]*)
echo "The value for -a must be a number" >&2
;;
*) MinimumAge="$OPTARG" ;;
esac
# Check if the value is numerical only
if [[ $OPTARG =~ ^[0-9]+$ ]]; then
MinimumAge=$OPTARG
else
printf '%16s %s\n\n' "Invalid Option:" "-a option requires a numerical value"
exit 1
fi
;;
\?)
printf '%16s %s\n\n' "Invalid Option:" "-$OPTARG"
exit 1
;;
*)
echo "Missing a required argument for -${OPTARG}" >&2
:)
printf '%16s %s\n\n' "Invalid Option:" "-$OPTARG requires an argument"
exit 1
;;
esac
done
shift $(expr $OPTIND - 1)

# CHECK IF SCRIPT IS ARCHIVED
if [ ! -d "$SrceFolder/Archive/Scripts" ]; then
Expand All @@ -92,7 +96,7 @@ else
fi

# GET EPOCH TIMESTAMP FOR AGE CHECKS
TodaysDate=$(date --date "now" +'%s')
TodaysDate=$(date +%s)

# SCRAPE GITHUB WEBSITE FOR LATEST INFO
GitHubRepo=michealespinola/syno.plexupdate
Expand Down Expand Up @@ -125,7 +129,7 @@ fi

# PRINT SCRIPT STATUS/DEBUG INFO
printf '%16s %s\n' "Script:" "$SrceFileNm"
printf '%16s %s\n' "Script Dir:" "$SrceFolder"
printf '%16s %s\n' "Script Dir:" "$(echo "$SrceFolder" | fold -w 60 -s | sed '2,$s/^/ /')"
printf '%16s %s\n' "Running Ver:" "$SPUScrpVer"
if [ "$SPUSNewVer" = "null" ]; then
printf "%16s %s\n" "GitHub API Msg:" "$(echo "$SPUSAPIMsg" | fold -w 60 -s | sed '2,$s/^/ /')"
Expand Down Expand Up @@ -266,11 +270,11 @@ fi
# SCRAPE PLEX WEBSITE FOR UPDATE INFO
DistroJson=$(curl -m "$NetTimeout" -Ls "$ChannelUrl")
if [ "$?" -eq "0" ]; then
NewVersion=$(echo "$DistroJson" | jq -r '.nas.Synology.version')
NewVersion=$(echo "$DistroJson" | jq -r '.nas."Synology (DSM 7)".version')
NewVersion=$(echo "$NewVersion" | grep -oP '^.+?(?=\-)')
NewVerDate=$(echo "$DistroJson" | jq -r '.nas.Synology.release_date')
NewVerAddd=$(echo "$DistroJson" | jq -r '.nas.Synology.items_added')
NewVerFixd=$(echo "$DistroJson" | jq -r '.nas.Synology.items_fixed')
NewVerDate=$(echo "$DistroJson" | jq -r '.nas."Synology (DSM 7)".release_date')
NewVerAddd=$(echo "$DistroJson" | jq -r '.nas."Synology (DSM 7)".items_added')
NewVerFixd=$(echo "$DistroJson" | jq -r '.nas."Synology (DSM 7)".items_fixed')
NewDwnlUrl=$(echo "$DistroJson" | jq --arg ArchFamily "$ArchFamily" -r '.nas."Synology (DSM 7)".releases[] | select(.build == "linux-"+$ArchFamily) | .url'); NewPackage="${NewDwnlUrl##*/}"
# CALCULATE NEW PACKAGE AGE FROM RELEASE DATE
PackageAge=$(((TodaysDate-NewVerDate)/86400))
Expand Down Expand Up @@ -309,7 +313,7 @@ rm "$SrceFolder/Archive/Packages/changelog.new" "$SrceFolder/Archive/Packages/ch

# PRINT PLEX STATUS/DEBUG INFO
printf '%16s %s\n' "Synology:" "$SynoHModel ($ArchFamily), DSM $DSMVersion"
printf '%16s %s\n' "Plex Dir:" "$PlexFolder"
printf '%16s %s\n' "Plex Dir:" "$(echo "$PlexFolder" | fold -w 60 -s | sed '2,$s/^/ /')"
printf '%16s %s\n' "Running Ver:" "$RunVersion"
if [ "$NewVersion" != "" ]; then
printf '%16s %s\n' "Online Ver:" "$NewVersion ($ChannlName Channel)"
Expand Down

0 comments on commit 6f09d25

Please sign in to comment.