Skip to content

Instantly share code, notes, and snippets.

@scrathe
scrathe / Plex nvdec enable.sh
Created March 16, 2019 19:24 — forked from Xaero252/Moved.md
Enable nvdec support for plex dockers on unraid
#!/bin/bash
# This should always return the name of the docker container running plex - assuming a single plex docker on the system.
con="$(docker ps --format "{{.Names}}" | grep -i plex)"
echo -n "<b>Applying hardware decode patch... </b>"
# Check to see if Plex Transcoder2 Exists first.
exists=$(docker exec -i "$con" stat "/usr/lib/plexmediaserver/Plex Transcoder2" >/dev/null 2>&1; echo $?)
#!/bin/bash
# credit; https://forums.unraid.net/topic/69255-cant-access-host-from-docker-container-when-using-br0/?do=findComment&comment=635402
# note: the path to the script must be accessible from within the docker shell
# option 1) run from inside the docker shell (do this first to make sure it works)
# option 2) run-as unraid user-script scheduled on-first-array-start-only (run once in background to avoid unraid reboot)
# nohup docker events --filter "container=plex" | awk '/container start/ { system("docker exec -i plex /bin/bash -c '/media/scripts/docker-plexencode/script'") }' &
#!/bin/bash
# what is this? poll your UPS using "upsc" and store values using InfluxDB for use with Grafana
# unRAID UPS plugin; https://forums.unraid.net/topic/60217-plugin-nut-v2-network-ups-tools/
# unRAID CA User Scripts; plugin https://forums.unraid.net/topic/48286-plugin-ca-user-scripts/
# unRAID User Scripts; add script, custom schedule = */1 * * * *
command="upsc ups"
influxdb="ups,host=Tower"
#!/bin/sh
# what is this? identify movies that are named (movie title), THE (year) and rename to (THE movie title) (year)
OLDIFS="$IFS"
IFS=$'\n'
targetDirectories=$(find . -maxdepth 1 -type d -regextype "posix-extended" -regex '.*\,\s(The|the)\s.*' -print | cut -d/ -f 2)
for dir in $targetDirectories; do
#!/bin/bash
# what is this? query your Radarr library and make changes via the API.
# in this example we query all Radarr entries, identify movies that are named (movie title), THE (year) and update the .path and .folderName to (THE movie title) (year)
# after updating Radarr, rename the folders on the filesystem; https://gist.github.com/scrathe/0bedf625916df1a0d070c053c284017d
RADARR_API_KEY="1234567890"
RADARR_HOST="10.0.0.20"
RADARR_PORT="7878"
@scrathe
scrathe / plex-nvidia-patch.sh
Last active October 29, 2022 15:35
Removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
#!/bin/bash
# run from unraid shell. not inside plex docker.
# where do you want to store the script?
dst="/mnt/user/media/scripts/plex-nvidia-patch.sh"
# download patch source: https://github.com/keylase/nvidia-patch
wget https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh -O $dst
@scrathe
scrathe / pgl-allowlist.sh
Last active October 29, 2022 15:40
PeerGuardian Linux (pgl) allowlist cronjob
# cronjob to monitor domains for IP changes, and add them to PeerGuardian Linux (pgl) allowlist
# https://wiki.archlinux.org/index.php/PeerGuardian_Linux
# sudo crontab -e
# W="list of domains to be allowed"
*/30 * * * * W="site.one site.two site.three" ; for H in $W ; do for H_IP in `dig $H A +short | grep -P "^\d.*"` ; do echo "${H}:${H_IP}-255.255.255.255" | tee -a '/etc/pgl/allow.txt' ; done ; done && sort /etc/pgl/allow.txt | uniq > /etc/pgl/allow.p2p && service pgl reload
#!/bin/bash
# https://gist.github.com/scrathe
# https://www.reddit.com/r/PleX/comments/vcc95i/database_repair_script_for_common_plex_db_errors/
# what is this? performs the steps outlined in Plex's garbage instructions on how to "Manually Repair the Database" https://support.plex.tv/articles/repair-a-corrupted-database/
# notes
# although this script will backup your Plex DB, i would suggest making your own backup.
# this script assumes you are comfortable with copying/pasting/running random things from the internet.