From 21ad38ab24483595452daa03766e98eb2f86fbb3 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 9 Nov 2018 00:58:15 -0600 Subject: [PATCH 1/5] fixed duplication bug; swapped 'for' for 'while' --- tab-sorcery.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tab-sorcery.sh b/tab-sorcery.sh index 1b0b508..0dcc42b 100644 --- a/tab-sorcery.sh +++ b/tab-sorcery.sh @@ -14,7 +14,7 @@ get_hostip () { } zone_xfer=`dig $scan_domain @$scan_ns AXFR | egrep -v 'SOA|NS|MX|DiG' | grep $scan_domain | awk '{print $1,$4,$5}'` -for host in `echo $zone_xfer | awk '{print $1}'`; do +while read host <&3; do user_name=$3 connect_cmd="ssh -t" host_short=`echo ${host} | awk -F. '{print $1}'` @@ -36,7 +36,7 @@ for host in `echo $zone_xfer | awk '{print $1}'`; do get_hostip ${host} alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}" fi >/dev/null -done +done 3< <(echo $zone_xfer | awk '{print $1}' | uniq) unset -f get_hostip return 0 From 01c08eeef44f72c0dc25680c52785e6d8732cafe Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 9 Nov 2018 01:37:54 -0600 Subject: [PATCH 2/5] Added configurable rdp geometry --- README.md | 13 +++++++------ tab-sorcery.sh | 8 +++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a8dc1ca..ff70d1d 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,13 @@ Default username (bob.user) Once done, all hostnames in the DNS zone should be available for SSH/Telnet/RDP by a tab-completable alias of just the hostname (in new shell sessions). #### Can I change the window geometry for rdesktop? -No. Not yet. You get 1600x900. See the bottom of this ReadMe for details. - +Yes! You simply need to export a variable *before* calling the tab-sorcery.sh script. The variable to export is called **SORC_GEOM_RDP**, which will take the form of [width]x[height]. +Example: +``` +export SORC_GEOM_RDP='1280x720' +. $HOME/git/tab-sorcery/tab-sorcery.sh example.com 127.0.0.1 bob.user +``` +The default window geometry that is used if this variable is either unset, or if an invalid value is detected is **1600x900**. ## DNS Setup You'll likely want to create a DNS zone specifically for this script for better control over the hosts included. I would recommend using a TLD not normally available, to be sure you don't have any overlap with existing DNS names. This domain doesn't need to be publicly queried, and actually it's probably in interest of security if it isn't. @@ -49,7 +54,3 @@ The `host3` alias is tagged with a TXT record for cisco, so it will be: `telnet `host5` is tagged as a Windows host, so it will use: `rdesktop -g 1600x900 -u your.username 10.0.0.5` - -#### Can I change the window geometry for rdesktop? -This last one, rdesktop, is harcoded to use 1600x900 geometry for now. Very likely, a variable will be added later to allow customization, but for now most people can accomodate 1080p-like resolutions, so this size should be "generally acceptable" for an average workstation. Perhaps a little less-so for a laptop. - diff --git a/tab-sorcery.sh b/tab-sorcery.sh index 0dcc42b..3162ace 100644 --- a/tab-sorcery.sh +++ b/tab-sorcery.sh @@ -8,6 +8,12 @@ scan_domain=$1 scan_ns=$2 +# Check for and set RDP geometry config +case "$SORC_GEOM_RDP" in + [0123456789]*x*[0123456789]) geom_rdp=$SORC_GEOM_RDP;; + *) geom_rdp='1600x900';; +esac + get_hostip () { #host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'` host_ip=`echo $zone_xfer | grep $1 | grep A | awk '{print $3}'` @@ -24,7 +30,7 @@ while read host <&3; do get_hostip ${host} alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"windows"' ]; then - connect_cmd="rdesktop -g 1600x900" + connect_cmd="rdesktop -g $geom_rdp" get_hostip ${host} alias ${host_short}="${connect_cmd} -u ${user_name} ${host_ip}" elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"cisco"' ]; then From 76e127acc248eb895db0dd5bb266dcde95d1471a Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Fri, 9 Nov 2018 10:12:51 -0600 Subject: [PATCH 3/5] Removed unnecessary gitignore file --- .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e69de29..0000000 From 5ce8083a034020e093da60815c65159e36f77be1 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Mon, 19 Nov 2018 12:02:46 -0600 Subject: [PATCH 4/5] Updated README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a8dc1ca..20d1284 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,15 @@ A helpful script for simplifying connections to servers and devices on your netw ---------------------- ## Shell Setup -Add the script as a source file in your shell prompt, such as a line similar to this: +Add the script as a source file in your shell prompt, exporting any config variables, such as with lines similar to this: ``` +# Tab Sorcery +export SORC_GEOM_RDP='1600x900' #Window resolution for RDP connections . $HOME/git/tab-sorcery/tab-sorcery.sh example.com 127.0.0.1 bob.user ``` -Arguments are: +Arguments for the script are required, in the following order: ``` Scan Domain (example.com) Nameserver address (127.0.0.1) From 3fb883fd65c6ac0a9772d7fc229e166b412522cc Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Mon, 19 Nov 2018 12:08:11 -0600 Subject: [PATCH 5/5] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17f3e33..e16a3d5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Add the script as a source file in your shell prompt, exporting any config varia ``` # Tab Sorcery -export SORC_GEOM_RDP='1600x900' #Window resolution for RDP connections +export SORC_GEOM_RDP='1600x900' #(Optional) Sets the window resolution for RDP connections . $HOME/git/tab-sorcery/tab-sorcery.sh example.com 127.0.0.1 bob.user ```