Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dhayab
Created March 24, 2018 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhayab/bc683293a8740d5e595f31f7bc72c89c to your computer and use it in GitHub Desktop.
Save dhayab/bc683293a8740d5e595f31f7bc72c89c to your computer and use it in GitHub Desktop.
Collection of miscellaneous scripts and files used in my old Netgear ReadyNAS Duo V2 NAS.
##
# Display colored FTP access and transfer log
##
#!/bin/bash
PATTERN="User (.*): Login successful|/home/ftp/([a-z0-9\/._-\&\(\)]{1,})|FTP session closed"
sudo tail -n 100 -f /var/log/proftpd.log | egrep -i "$PATTERN" --color=auto
##
# Burn a subtitle file in a movie's mkv container
##
#!/bin/bash
if [ -z "$1" ]
then
echo ----- mkv3dsubs -----
echo Usage: mkv3dsubs MOVIE.mkv SUBTITLES.srt
exit 1
fi
movie_file=$1
merge_file=${movie_file%.*}.merged.mkv
subs_file=$2
mkvmerge -o "$merge_file" "$movie_file" --language "0:eng" --track-name "0:English" -s 0 -D -A "$subs_file"
##
# Fetches a subtitle from Addic7ed and apply the correct rights
##
#!/bin/bash
if [ -z "$1" ]
then
echo ----- subs ----
echo Usage: subs ADDIC7ED_SUBTITLES_URL VIDEO_FILE_PATH
exit 1
fi
subs_url=$1
video_file=$2
subs_file=${video_file%.*}.en.srt
subs_login=http://www.addic7ed.com/dologin.php
subs_cookie=.subs-auth
echo "+ Fetching subtitles for" $(basename "$video_file") "..."
wget -q --save-cookies $subs_cookie --keep-session-cookies --post-data "url=&Submit=Log+in&username=#USERNAME#&password=#PASSWORD#" --delete-after $subs_login > /dev/null
wget -q --load-cookies $subs_cookie $subs_url -O "$subs_file"
echo "+ Applying correct permissions to" $(basename "$subs_file")
chown service:users "$subs_file" && chmod 666 "$subs_file"
rm $subs_cookie
##
# Toggle from Sonarr to Radarr, and vice-versa
# (the ReadyNAS Duo V2 only has 256MB of RAM)
##
#!/bin/bash
NZBDRONE_STATUS=`/etc/init.d/nzbdrone status`
if [[ $NZBDRONE_STATUS == *"failed"* ]]; then
/etc/init.d/radarr stop
/etc/init.d/nzbdrone start
else
/etc/init.d/nzbdrone stop
/etc/init.d/radarr start
fi
##
# Reverse proxy for mediacenter web applications
##
#vers=2
<VirtualHost _default_:80>
SSLEngine off
RewriteEngine on
RewriteCond %{REQUEST_URI} !(nzbget|tv|films|torrent|transmission)
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]
RewriteRule ^(cgi-bin) - [L]
<Location /nzbget>
ProxyPass http://localhost:8080/nzbget
ProxyPassReverse http://localhost:8080/nzbget
</Location>
<Location /tv>
ProxyPass http://localhost:8081/tv
ProxyPassReverse http://localhost:8081/tv
</Location>
<Location /films>
ProxyPass http://localhost:8082/films
ProxyPassReverse http://localhost:8082/films
</Location>
<Location /transmission>
ProxyPass http://localhost:8083/transmission
ProxyPassReverse http://localhost:8083/transmission
</Location>
<Proxy *>
Order Deny,Allow
Deny from all
Allow from 192.168.0.0/24 # LOCAL NETWORK
Allow from X.Y.Z.T # TARDIS
Allow from X.Y.Z.T # NZBS.IN
</Proxy>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment