Add script to automatically open plex tunnel

This commit is contained in:
Jean Froment 2017-12-08 16:18:26 +01:00
parent 97aa842dac
commit 8b2d20e257
4 changed files with 41 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
/config
tunnel-options.sh

View File

@ -93,7 +93,7 @@ http {
server_name ~^(webtools)(\.\w+)+$;
location / {
set $webtools http://plex:33443;
set $webtools http://plex:33442;
proxy_pass $webtools;
}
}

22
open-tunnel.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
source tunnel-options.sh
if [[ -z $username ]]; then
username=$USER
fi
echo "[$0] Connecting and fetching IP..."
echo "[$0] Username: $username"
echo "[$0] Host: $hostname"
ip=$(ssh -t ${username}@${hostname} "docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${container}")
echo "[$0] IP found: $ip"
echo "[$0] Openning tunnel..."
open http://localhost:$port && ssh -L $port:$ip:$port ${username}@${hostname}
echo "[$0] Tunnel closed."
exit 0

17
tunnel-options.sh.sample Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
##################################################################
# Use : Rename me into "tunnel-options.sh" and change parameters #
##################################################################
# SSH Host to open tunnel on
hostname="example.com"
# "UNIX username for SSH access"
username="bob"
# Plex container name for WebTools IP fetching
container="seedbox_plex_1"
# Port for WebTools on the container
port=33442