diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md index a8dc1ca..e16a3d5 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' #(Optional) Sets the 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) @@ -20,8 +22,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 +56,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 1b0b508..3162ace 100644 --- a/tab-sorcery.sh +++ b/tab-sorcery.sh @@ -8,13 +8,19 @@ 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}'` } 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}'` @@ -24,7 +30,7 @@ for host in `echo $zone_xfer | awk '{print $1}'`; 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 @@ -36,7 +42,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