ソースを参照

Move bin to own repo

George Jones 6 年 前
コミット
22ce9c36ef
31 ファイル変更0 行追加2204 行削除
  1. 0 143
      bin/.bashrc
  2. 0 2
      bin/.exclude.default
  3. 0 286
      bin/be
  4. 0 127
      bin/dns2ip
  5. 0 39
      bin/exifSetDate
  6. 0 15
      bin/exifSetDatesThisDir
  7. 0 15
      bin/fixGitTimestamps.sh
  8. 0 45
      bin/fixctrl.sh
  9. 0 22
      bin/gitPushOrPull
  10. 0 11
      bin/gpgAgent.sh
  11. 0 15
      bin/grepOutUbunutuFiles
  12. 0 20
      bin/install
  13. 0 127
      bin/ip2dns
  14. 0 146
      bin/jpgHasDate
  15. 0 201
      bin/jpgdates
  16. 0 190
      bin/link2
  17. 0 35
      bin/link2home
  18. 0 169
      bin/link2home.sh
  19. 0 161
      bin/linkall
  20. 0 32
      bin/logCommand.sh
  21. 0 185
      bin/logstats.py
  22. 0 16
      bin/myip
  23. 0 14
      bin/old/emacs-pkg-install.sh
  24. 0 5
      bin/old/get-emacs.sh
  25. 0 45
      bin/old/mtime
  26. 0 18
      bin/old/whatsMyLocation.sh
  27. 0 11
      bin/old/whatsMyOS.sh
  28. 0 6
      bin/rdns
  29. 0 26
      bin/sshagent
  30. 0 54
      bin/thatsNotRight.sh
  31. 0 23
      bin/whoIsOnMySubnet

+ 0 - 143
bin/.bashrc

@@ -1,143 +0,0 @@
-#
-# GMJ .bashrc
-#
-# Tue Mar 26 20:07:29 2013 
-#
-
-#
-# Before anything else, fix the CTRL key !!!
-#
-
-if [ -x $HOME/bin/fixctrl.sh ]; then
-  $HOME/bin/fixctrl.sh
-fi
-
-#
-# Generic things
-#
-
-export PS1="\# [\t] \u@\h \W/ $ " 
-
-alias  cd='	pushd'
-#bind -x '"\C-l": clear;'
-alias rm='	rm -i'
-alias eg='	printenv | grep -i' 
-alias fegi='	find . -print | egrep -i'
-alias egi='	egrep -i' 
-alias psg='	/bin/ps -auxww | grep'
-
-# Useful functions 
-
-pathadd() {
-    if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
-        PATH="${PATH:+"$PATH:"}$1"
-    fi
-}
-
-# Generic path
-
-
-pathadd $HOME/bin
-
-#
-# Determine location, OS etc.
-#
-
-export myOS=
-export myLocation=
-export myPublicIP=
-export myPublicDomainName=
-
-# try to determine location, first by wireless SSIDs, then by reverse DNS
-
-if [ -x $HOME/bin/whatsMyLocation.sh ]; then
-  export myLocation=`$HOME/bin/whatsMyLocation.sh`
-fi
-
-if [ -x $HOME/bin/whatsMyOS.sh ]; then
-  export myOS=`$HOME/bin/whatsMyOS.sh`
-fi
-
-if [ -x $HOME/bin/whatsMyPublicIP.sh ]; then
-  export myPublicIP=`$HOME/bin/whatsMyPublicIP.sh`
-fi
-
-if [ "$myPublicIP" != "" ]; then
-  if [ -x $HOME/bin/rdns.sh ]; then
-    export myPublicDomainName=`$HOME/bin/rdns.sh $myPublicIP`
-  fi
-fi
-
-if [ "$myLocation" == "" ]; then
-  if [[ "$myPublicDomainName" == *comcast.net* ]]; then
-      export myLocation="home"
-  fi
-fi
-
-if [ "$myLocation" == "work" ]; then
-  if [ -f $HOME/.bashrc.atWork ]; then
-    . $HOME/.bashrc.atWork
-  fi
-elif [ "$myLocation" == "home" ]; then
-    echo at home
-    unset http_proxy
-    unset https_proxy
-fi
-
-
-#
-# Do location-specific setup
-#
-
-if [ `which emacs 2>/dev/null` ]; then
-    export VISUAL=emacs
-    export EDITOR=emacs
-fi
-
-alias emacs='		emacs-snapshot'
-
-
-
-
-
-#
-# Do OS-specific setup
-#
-
-if [ $TERM == "dumb" ]; then
-  color="";
-elif [ $myOS == "mac" ]; then
-  pathadd /opt/local/bin;
-  color="-G";
-elif [ $myOS == "linux" ]; then
-  color="--color";
-fi
-
-alias ls='	ls '$color' -a'
-alias llt=' 	ls -lt '$color' -a'
-alias lltm='	ls '$color' -a -lt | more'
-alias llth='	ls '$color' -a -lt | head'
-alias lss='	ls '$color' -a -1s | sort -n'
-alias lssr='	ls '$color' -a -1s | sort -nr'
-
-#
-# Set up silk repositories if they exist
-#
-
-case `hostname -s` in
-    manton)
-	export SILK_DATA_ROOTDIR=/analysis/gmj/share/sc12/silk/
-	export SILK_IPV6_POLICY=asv4
-	;;
-    *)
-	if [ -f /data/sensors.conf ]; then
-	    export SILK_DATA_ROOTDIR=/data
-	    export SILK_IPV6_POLICY=asv4
-        fi
-	;;
-esac
-
-
-# Let somebody know we finished running
-
-touch $HOME/.bashrc-ran

+ 0 - 2
bin/.exclude.default

@@ -1,2 +0,0 @@
-install
-.exclude

+ 0 - 286
bin/be

@@ -1,286 +0,0 @@
-#! /bin/bash
-# change aws, ssh and gpg credentials
-#
-# Usage
-#
-#   be [options] NAME
-#   be [options] --whoami
-#   be [options] --list
-#
-#  e.g.
-#
-#   If  ~/.gnupg.$1 exists, link to ~/.gnupg
-#   If  ~/.ssh/id_{dsa,rsa}.$1 exists, link to ~/.ssh/id_{dsa,rsa} and add to ssh agent
-#   If  ~/.aws/credentials.$1 exists, link to ~/.aws/credentials
-#
-# TODO
-#  - Add gpg identities
-#  - deal with git identities
-#     + Use XDG-CONFIG-HOME to switch identities?
-#       http://git.661346.n2.nabble.com/What-is-XDG-CONFIG-HOME-for-exactly-td7627117.html
-#    + See https://gist.github.com/jexchan/2351996
-#  - Switch pass(1) databases/identities
-#  - Deal with .pem files
-
-
-set -e; set -u
-
-# Helper functions
-PROG=`basename "$0" | tr -d '\n'`
-
-function info()  { echo ${PROG}\: info: "$@" 1>&2; }
-function warn()  { echo ${PROG}\: warning: "$@" 1>&2; }
-function error() { echo ${PROG}\: error: "$@" 1>&2; }
-function debug() { [[ -v DEBUG ]] && echo ${PROG}\: debug: "$@" 1>&2 || true ; }
-function die()   { echo ${PROG}\: fatal: "$@" 1>&2 && exit 1; }
-
-function usage() {
-    debug "in ${FUNCNAME[0]}"
-
-    if [[ "$#" -gt 0 ]]; then
-        warn $@
-    fi
-
-    cat <<END 1>&2
-Usage: ${PROG} [options] who
-
-   arguments
-     who               name of identity
-
-   options
-
-     -a|--aws		change/list aws credentials ONLY
-     -d|--debug         debug output
-     -g|--gnupg		change/list gnupgcredentials ONLY
-     -l|--list		list availabe credentials.
-     -s|--ssh		change/list ssh credentials ONLY
-     -v|--verbose       verbose output
-     -w|--whoami        list current identities
-
-END
-    exit 1
-}
-
-function gpg_list() {
-    # list available gpg credentail sets (diretories)
-    info available GPG credentials sets
-    ls -ld ~/.gnupg.*
-}
-
-function gpg_whoami() {
-    # list current gpg identity
-    info Current gpg credential set
-    ls -ld ~/.gnupg
-}
-
-function gpg_become() {
-    # change gpg identity
-    rm -f ~/.gnupg || true
-    ln -s ~/.gnupg."${who}" ~/.gnupg
-}
-
-function aws_list() {
-    # list available aws credentials
-    cd ~/.aws || die "Error connecting to ~/.aws"
-
-    info available AWS credentials and configs
-    ls -1 credentials.* config.*
-}
-
-function aws_whoami() {
-    # list current aws identity
-    cd ~/.aws || die "Error connecting to ~/.aws"
-
-    info Current aws credentials
-    ls -l credentials config
-}
-
-function aws_become() {
-    # change aws identity
-    cd ~/.aws || die "Error connecting to ~/.aws"
-
-    aws_creds="credentials.""${who}"
-    if [ ! -f "${aws_creds}"  ]; then
-        warn file "${aws_creds}" does not exist.  Not changing aws identity.
-    else
-        [[ -v VERBOSE ]] && set -x
-        rm -f credentials || true
-        ln -s "${aws_creds}" credentials
-        [[ -v VERBOSE ]] && set +x
-    fi
-
-    aws_config="config.""${who}"
-    if [ ! -f "${aws_config}"  ]; then
-        warn file "${aws_config}" does not exist.  Not installing.
-    else
-        [[ -v VERBOSE ]] && set -x
-        rm -f config || true
-        ln -s "${aws_config}" config
-        [[ -v VERBOSE ]] && set +x
-    fi
-}
-
-
-function ssh_list() {
-    # list available ssh credentials
-    cd ~/.ssh || die "Error connecting to ~/.ssh"
-
-    info available SSH credentials
-    ls -1 id_rsa.* id_dsa.*
-}
-
-function ssh_whoami() {
-    # list current ssh identity
-    cd ~/.ssh || die "Error connecting to ~/.ssh"
-
-    info Current SSH identities
-    ls -l id_???  || warn "no ~/.ssh/id_{rsa,dsa} file"
-    info SSH Agent Identities
-    ssh-add -l
-}
-
-function ssh_become() {
-    # change ssh identity
-    cd ~/.ssh || die "Error connecting to ~/.ssh"
-
-    rsa_creds="id_rsa.""${who}"
-    dsa_creds="id_dsa.""${who}"
-
-    if [ -f "${dsa_creds}" ]; then
-        ssh_creds="${dsa_creds}"
-    elif [ -f "${rsa_creds}" ]; then
-        ssh_creds="${rsa_creds}"
-    else
-        echo "No ssh creds found. "${rsa_creds}" and "${dsa_creds}" do not exis."
-        exit 1
-    fi
-
-    target=`basename $ssh_creds ".""${who}"`
-
-    if [ -f "${ssh_creds}"  ]; then
-        [[ -v VERBOSE ]] && set +x
-        rm -f "${target}" || true
-        ln -s "${ssh_creds}" "${target}"
-        chmod 400 "${target}"
-        ssh-add "${ssh_creds}"
-        [[ -v VERBOSE ]] && set -x
-    fi
-}
-
-
-#
-# "main()" begins here
-#
-
-# Defaults
-SSH=1
-AWS=1
-GPG=1
-
-
-
-# parse global options
-
-for i in "$@"
-do
-    case $i in
-        -a|--aws)
-            AWS=1
-            unset SSH
-            unset GPG
-            d_flag="-d"
-            shift # past argument with no value
-            ;;
-        -d|--debug)
-            DEBUG=1
-            d_flag="-d"
-            shift # past argument with no value
-            ;;
-        -g|--gnupg)
-            GNUPG=1
-            unset AWS
-            unset SSH
-            g_flag="-g"
-            shift # past argument with no value
-            ;;
-        -l|--list)
-            LIST=1
-            d_flag="-d"
-            shift # past argument with no value
-            ;;
-        -s|--ssh)
-            SSH=1
-            unset AWS
-            unset GPG
-            d_flag="-d"
-            shift # past argument with no value
-            ;;
-        -v|--verbose)
-            VERBOSE=1
-            v_flag="-v"
-            shift # past argument with no value
-            ;;
-
-        -w|--whoami)
-            WHOAMI=1
-            v_flag="-v"
-            shift # past argument with no value
-            ;;
-        -*|--*)
-            usage "Unknown state option: $i"
-            ;;
-    esac
-done
-
-# Pull off command line args
-
-if [[ !  -v LIST  && ! -v WHOAMI ]]; then
-    if [ "$#" -ne 1 ]; then
-        usage need a username
-    fi
-
-    who="${1}"
-fi
-
-if [[ ! -v SSH && ! -v AWS && ! -v GPG ]]; then
-    die "Must specify at least one of '--aws' and '--ssh' and '--gnupg'"
-fi
-
-# Change aws credentials
-
-if [ -v AWS ]; then
-
-    if [[ -v LIST ]]; then
-        aws_list
-    elif [[ -v WHOAMI ]]; then
-        aws_whoami
-    else
-        aws_become
-    fi
-fi
-
-# Change ssh credentials
-
-if [ -v SSH ]; then
-
-    if [[ -v LIST ]]; then
-        ssh_list
-    elif [[ -v WHOAMI ]]; then
-        ssh_whoami
-    else
-        ssh_become
-    fi
-fi
-
-# Change ssh credentials
-
-if [ -v GPG ]; then
-
-    if [[ -v LIST ]]; then
-        gpg_list
-    elif [[ -v WHOAMI ]]; then
-        gpg_whoami
-    else
-        gpg_become
-    fi
-fi

+ 0 - 127
bin/dns2ip

@@ -1,127 +0,0 @@
-#! /usr/bin/python
-#
-# Read a list of domain names on stdin, look up the A records, print IPs on stdout
-#
-# Usgae:
-#
-#   echo google.com | dns2ip [-a]
-#
-# or
-#
-#   echo 8.8.8.8 | ip2dns
-#
-#
-# The funcion (forward or reverse lookup) keys off the program name,
-# so install by doing:
-#
-#    $ ln dns2ip ip2dns
-#
-
-import socket
-#import fileinput
-import dns.resolver
-import sys
-import getopt
-
-def usage():
-	sys.stderr.write("Usage: echo www.google.com | dnns2ip [options]\n")
-	sys.stderr.write("   or\n")
-	sys.stderr.write("       dns2ip [options]files-contianing-dns-names [files..]\n")
-	sys.stderr.write("\n")					 
-	sys.stderr.write("   options\n")
-	sys.stderr.write("\n")					 	
-	sys.stderr.write("     --names|-n	print name as well as resolved IPs\n")
-	sys.stderr.write("     --all|-a	print IPs for all A records\n")	
-	sys.exit(1)
-
-# defaults
-printName= False
-printAll = False
-verbose=False
-inputName=""
-progName=sys.argv[0]
-
-options, remainder = getopt.getopt(sys.argv[1:], 'ahnvi:',
-                                   ["all",
-                                    'help',
-									'input='
-                                    'names',                                    
-                                    "verbose",
-								   ]
-                                   )
-for opt, arg in options:
-
-    if opt in ('-h', '--help'):
-        usage()
-        sys.exit(2)
-    elif opt in ('-i', '--input'):
-        inputName = arg
-    elif opt in ('-a', '--all'):
-        printAll= True
-    elif opt in ('-n', '--names'):
-        printName= True
-    elif opt in ('-v', '--verbose'):
-        verbose=True
-    else:
-        usage()
-        sys.exit(2)
-
-if verbose:
-	print "printName", printName
-	print "printAll", printAll
-	print "verbose", verbose
-	print "inputName", inputName
-	print "remainder", remainder
-
-myResolver = dns.resolver.Resolver() #create a new instance named 'myResolver'
-
-import fileinput
-
-for name in fileinput.input(remainder):
-
-	if verbose:
-		print "name", name
-	name = name.strip()
-
-	atLeastOne = False
-	
-	try:
-		myAnswers = []
-
-		if "dns2ip" in progName:
-			myAnswers = myResolver.query(name, "A") #Lookup the 'A' record(s) for google.com
-		elif "ip2dns" in progName:
-			addr=dns.reversename.from_address(name)
-			reverse = str(dns.resolver.query(addr,"PTR")[0])
-			myAnswers.append(reverse)
-		else:
-			usage()
-			sys.exit(2)
-
-		for rdata in myAnswers: #for each response
-				
-			sys.stdout.write("%s" % (rdata))
-
-			if printName:
-				sys.stdout.write(" %s\n" % (name))
-			else:
-				sys.stdout.write("\n")				
-
-			atLeastOne = True
-
-			if not printAll:
-				last
-	except:
-		pass
-
-
-	
-
-	
-
-
-	
-
-
-	
-	

+ 0 - 39
bin/exifSetDate

@@ -1,39 +0,0 @@
-#! /bin/bash
-# Add datestamp to JPEG or EXIF file
-#
-# Usage: exfiSetDate date file [file...]
-#
-#   date	- date to add.  Any format accepted by date(1).
-#   file	- file to have date set
-#
-# Author: George Jones <gmj@pobox.com>
-#
-# Date: Sat Dec 19 08:57:32 2015
-#
-# Prereqs:
-#    - Linux file(1) utility for typing
-#    - http://owl.phy.queensu.ca/~phil/exiftool/ for setting dates
-#
-
-set -e;
-set -u; 
-#set -x
-
-if [ $# -lt 2 ]
-  then
-    echo "Usage: $0 date file [file...]" >&2
-    exit 1
-fi
-
-when="$1"
-shift
-
-setToTime=`date --date="$when" --rfc-3339=seconds`
-exiftool -overwrite_original_in_place "-DateTimeOriginal='${setToTime}'" $*
-
-
-
-
-
-
-

+ 0 - 15
bin/exifSetDatesThisDir

@@ -1,15 +0,0 @@
-#! /bin/bash
-# Set JPG file dates for all files in this directory that do not have a date
-#
-# Usage:  exifSetDatesThisDir DATE
-#
-#    DATE - any date acceptable
-#
-# Uses:
-#   https://github.com/eludom/dotfiles/blob/master/bin/jpgdates
-#   https://github.com/eludom/dotfiles/blob/master/bin/exifSetDate
-#
-# Depends on:
-#   http://owl.phy.queensu.ca/~phil/exiftool/
-
-exifSetDate $1 `jpgdates -m -p *.jpg `

+ 0 - 15
bin/fixGitTimestamps.sh

@@ -1,15 +0,0 @@
-#! /bin/bash
-
-# Fix timestamps on tig files per ls-files
-#
-# Original from http://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps/30143117#30143117
-#
-# Fixed to work with ubuntu.
-
-
-for FILE in $(git ls-files)
-do
-    TIME=$(git log --pretty=format:%cd -n 1 --date=iso $FILE)
-    TIME2=`echo $TIME | sed 's/-//g;s/ //;s/://;s/:/\./;s/ .*//'`
-    touch -m -t $TIME2 $FILE
-done 

+ 0 - 45
bin/fixctrl.sh

@@ -1,45 +0,0 @@
-#! /bin/bash
-# Fix control keys on X or linux console
-
-set -e; set -u; echo "$0: `date;`" 
-
-# Fix in X
-
-if [ -x /usr/bin/setxkbmap ]; then
-
-    set +e
-    /usr/bin/setxkbmap 2> /dev/null
-
-    if [ $? -eq 0 ]; then
-      set -e
-
-      echo "$0: found display.  Setting ctrl:nocaps"
-      setxkbmap -option 'ctrl:nocaps'
-    fi
-fi
-
-# Fix on Linux console
-
-if [ -x /usr/bin/dumpkeys ]; then
-
-    set +e
-    /usr/bin/dumpkeys &> /dev/null
-    if [ $? -eq 0 ]; then
-        set -e
-	cd ~
-	dumpkeys | head -1 > fixctl.map
-
-	if [ $? -eq 0 ]; then 
-	    echo "$0: found console.  loadkeys keycode 58 = Control"
-	    echo "keycode 58 = Control" >> fixctl.map
-            sudo loadkeys < fixctl.map
-	else
-	    echo $0: not on console >&2
-	fi    
-    fi
-fi
-
-
-
-
-

+ 0 - 22
bin/gitPushOrPull

@@ -1,22 +0,0 @@
-#!/bin/sh
-# Check if pull or push is needed
-#
-# Usage: gitPushOrPull
-#
-# Source: http://stackoverflow.com/questions/3258243/git-check-if-pull-needed
-
-git fetch --all
-
-LOCAL=$(git rev-parse @)
-REMOTE=$(git rev-parse @{u})
-BASE=$(git merge-base @ @{u})
-
-if [ $LOCAL = $REMOTE ]; then
-    echo "Up-to-date (LOCAL $LOCAL = REMOTE $REMOTE)"
-elif [ $LOCAL = $BASE ]; then
-    echo "Need to pull (LOCAL $LOCAL = BASE $BASE)"
-elif [ $REMOTE = $BASE ]; then
-    echo "Need to push (REMOTE $REMOTE = BASE $BASE)"
-else
-    echo "Diverged"
-fi

+ 0 - 11
bin/gpgAgent.sh

@@ -1,11 +0,0 @@
-gpg-agent --daemon --enable-ssh-support \
-      --write-env-file "${HOME}/.gpg-agent-info"
-if [ -f "${HOME}/.gpg-agent-info" ]; then
-   . "${HOME}/.gpg-agent-info"
-  export GPG_AGENT_INFO
-  export SSH_AUTH_SOCK
-  export SSH_AGENT_PID
-fi
-
-GPG_TTY=$(tty)
-export GPG_TTY

+ 0 - 15
bin/grepOutUbunutuFiles

@@ -1,15 +0,0 @@
-#! /bin/bash
-# Grep out files that change a lot in Ubuntu home directory
-#
-# Usage: cd ~ ; ls -l | grepOutUbuntuFiles
-#
-# 
-# Example:  
-#
-#  To find files that have changed today on an Ubuntu system home
-#  directory that are not standard files:
-#
-#    find . -mtime -1 -print0 | xargs -0 ls -ltd  | egrep -vi \\.mozilla\|\\.macromedia\|\\.cache\|\\.config\|\\.local | egrep -vi Mail 
-#
-
-egrep -vi \\.mozilla\|\\.macromedia\|\\.cache\|\\.config\|\\.local

+ 0 - 20
bin/install

@@ -1,20 +0,0 @@
-#! /bin/bash
-# Link everthing in '$PWD' to a dir in '~/$PWD'
-#
-# Put a COPY (not link) of his in any directory that should have it's
-# file linked into root.
-
-# Any files listed (one per line) in .install.ignore will be ignored
-
-
-# get the directory of this script
-WHERE_AM_I="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-cd ${WHERE_AM_I}
-
-# Extract the directory name of this file
-BASEDIR=`basename $WHERE_AM_I`
-
-echo Linking evertying in "${WHERE_AM_I}"  into "~/""${BASEDIR}"
-~/bin/link2home.sh -v -d
-
-# any directory specific post-processing (permissions, etc) goes here.

+ 0 - 127
bin/ip2dns

@@ -1,127 +0,0 @@
-#! /usr/bin/python
-#
-# Read a list of domain names on stdin, look up the A records, print IPs on stdout
-#
-# Usgae:
-#
-#   echo google.com | dns2ip [-a]
-#
-# or
-#
-#   echo 8.8.8.8 | ip2dns
-#
-#
-# The funcion (forward or reverse lookup) keys off the program name,
-# so install by doing:
-#
-#    $ ln dns2ip ip2dns
-#
-
-import socket
-#import fileinput
-import dns.resolver
-import sys
-import getopt
-
-def usage():
-	sys.stderr.write("Usage: echo www.google.com | dnns2ip [options]\n")
-	sys.stderr.write("   or\n")
-	sys.stderr.write("       dns2ip [options]files-contianing-dns-names [files..]\n")
-	sys.stderr.write("\n")					 
-	sys.stderr.write("   options\n")
-	sys.stderr.write("\n")					 	
-	sys.stderr.write("     --names|-n	print name as well as resolved IPs\n")
-	sys.stderr.write("     --all|-a	print IPs for all A records\n")	
-	sys.exit(1)
-
-# defaults
-printName= False
-printAll = False
-verbose=False
-inputName=""
-progName=sys.argv[0]
-
-options, remainder = getopt.getopt(sys.argv[1:], 'ahnvi:',
-                                   ["all",
-                                    'help',
-									'input='
-                                    'names',                                    
-                                    "verbose",
-								   ]
-                                   )
-for opt, arg in options:
-
-    if opt in ('-h', '--help'):
-        usage()
-        sys.exit(2)
-    elif opt in ('-i', '--input'):
-        inputName = arg
-    elif opt in ('-a', '--all'):
-        printAll= True
-    elif opt in ('-n', '--names'):
-        printName= True
-    elif opt in ('-v', '--verbose'):
-        verbose=True
-    else:
-        usage()
-        sys.exit(2)
-
-if verbose:
-	print "printName", printName
-	print "printAll", printAll
-	print "verbose", verbose
-	print "inputName", inputName
-	print "remainder", remainder
-
-myResolver = dns.resolver.Resolver() #create a new instance named 'myResolver'
-
-import fileinput
-
-for name in fileinput.input(remainder):
-
-	if verbose:
-		print "name", name
-	name = name.strip()
-
-	atLeastOne = False
-	
-	try:
-		myAnswers = []
-
-		if "dns2ip" in progName:
-			myAnswers = myResolver.query(name, "A") #Lookup the 'A' record(s) for google.com
-		elif "ip2dns" in progName:
-			addr=dns.reversename.from_address(name)
-			reverse = str(dns.resolver.query(addr,"PTR")[0])
-			myAnswers.append(reverse)
-		else:
-			usage()
-			sys.exit(2)
-
-		for rdata in myAnswers: #for each response
-				
-			sys.stdout.write("%s" % (rdata))
-
-			if printName:
-				sys.stdout.write(" %s\n" % (name))
-			else:
-				sys.stdout.write("\n")				
-
-			atLeastOne = True
-
-			if not printAll:
-				last
-	except:
-		pass
-
-
-	
-
-	
-
-
-	
-
-
-	
-	

+ 0 - 146
bin/jpgHasDate

@@ -1,146 +0,0 @@
-#! /bin/bash 
-#title           :jpgHasDate.sh
-#description     :Determine if an JPEG file has a date
-#author		 :gmj@pobox.com
-#date            :Sat Dec 19 15:35:06 2015
-#version         :0.1
-#usage		 :jpgHasDate.sh [optinos] FILE [FILE...]
-#notes           :Experimeting with well-writtne bash
-#bash_version    :
-#==============================================================================
-
-set -u   # exit on undefined
-set -e   # exit on error
-# set -x # echo during execution
-
-# Useful tips
-# http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/
-readonly PROGNAME=$(basename $0)
-readonly PROGDIR=$(readlink -m $(dirname $0))
-readonly ARGS="$@"
-
-usage() {
-    if [ $# -gt 0 ]; then echo  "${PROGNAME}: $@"; echo; fi
-    cat <<- EOF
-usage: $PROGNAME [options] FILE [FILE...]
-    
-This program determins if a JPEG file has an Original Date stored
-with it and prints the filename and/or date.
-
-OPTIONS:
-   -w --withdates	Select files with dates
-   -m --missingdates	Select files with no dates
-   -p --path		Print path of matching files
-   -t --dates		Print dates of matching files
-   -v --verbose         Verbose. You can specify more then one -v to have more verbose
-   -d --debug           debug
-   -h --help            show this help
-    
-Examples:
-   print info about a single file
-   $PROGNAME --test all
-
-EOF
-}
-
-
-parseArgs() {
-    # Option parsing courtesy of 
-    # http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options
-
-
-    # NOTE: This requires GNU getopt.  On Mac OS X and FreeBSD, you have to install this
-    # separately; see below.
-    TEMP=`getopt -o wmptvdh --long withdates,missingdates,path,dates,verbose,debug,help \
-            	  -n 'jpghasDate' -- "$@"`
-
-    if [ $? != 0 ] ; then echo "getopt failed. Terminating..." >&2 ; exit 1 ; fi
-
-    # Note the quotes around `$TEMP': they are essential!
-    eval set -- "$TEMP"
-
-
-    # Set default values
-
-    # Selection Parameters
-    OPT_SELECT_WITH_DATES=false		# print files that have dates
-    OPT_SELECT_MISSING_DATES=false	# print files with no date
-    # Output Parameters
-    OPT_VERBOSE=false			# verbose output
-    OPT_DEBUG=false			# debugging output
-    OPT_PRINT_PATH=false  		# print path
-    OPT_PRINT_DATES=false		# print date
-    OPT_PRINT_ALL=true			# print all (default)
-
-    while true; do
-	case "$1" in
-	    -w | --withdates ) OPT_SELECT_WITH_DATES=true; shift ;;
-	    -m | --missingdates ) OPT_SELECT_MISSING_DATES=true; shift ;;
-	    -p | --path ) OPT_PRINT_PATH=true; shift ;;
-	    -t | --dates ) OPT_PRINT_DATES=true; shift ;;
-	    -v | --verbose ) OPT_VERBOSE=true; shift ;;
-	    -d | --debug ) OPT_DEBUG=true; shift ;;
-	    -h | --help ) usage; exit 0;shift ;;        
-	    -- ) shift; break ;;
-	    * ) break ;;
-	esac
-    done
-    
-    if [ $# -lt 1 ] ; then usage "Missing argument.  Need at least one filename."; exit 1; fi
-
-    # Defualt to printing all
-    if ! ( $OPT_PRINT_PATH || $OPT_PRINT_DATES ); then 
-	OPT_PRINT_PATH=true
-	OPT_PRINT_DATES=true
-    fi
-    
-    # Defualt to selectiing all
-    if ! ( $OPT_SELECT_WITH_DATES || $OPT_SELECT_MISSING_DATES ); then 
-	OPT_SELECT_WITH_DATES=true
-	OPT_SELECT_MISSING_DATES=true
-    fi
-
-    # Make parsing paramters readonly
-
-    readonly OPT_SELECT_WITH_DATES=${OPT_SELECT_WITH_DATES}	# print files that have dates
-    readonly OPT_SELECT_MISSING_DATES=${OPT_SELECT_MISSING_DATES}	# print files with no date
-    readonly OPT_VERBOSE=${OPT_VERBOSE}				# verbose output
-    readonly OPT_DEBUG=${OPT_DEBUG}				# debugging output
-    readonly OPT_PRINT_PATH=${OPT_PRINT_PATH}			# print path
-    readonly OPT_PRINT_DATES=${OPT_PRINT_DATES}			# print date
-    readonly OPT_PRINT_ALL=${OPT_PRINT_ALL}			# print all (default)
-
-    readonly OPT_ARGS="$@"
-}
-
-printSelectedFiles () {
-    for file in "$*"; do
-	if $OPT_DEBUG; then echo file $file >&2; fi
-	date=$(exiftool $file | grep Orig || echo "NONE")
-	date=$(echo $date | sed -e 's/Date\/Time Original\s*\:\s*//')
-	output=""
-
-	if $OPT_PRINT_PATH; then output="$file"; fi
-
-	if $OPT_PRINT_DATES; then output="$output : $date"; fi
-	
-	if $OPT_SELECT_MISSING_DATES; then 
-	    if [[ $date == *"NONE"* ]]; then
-		echo $output
-	    fi
-	fi
-
-	if $OPT_SELECT_WITH_DATES; then 
-	    if [[ $date != *"NONE"* ]]; then
-		echo $output
-	    fi
-	fi    
-    done
-}
-
-main() {
-    parseArgs $ARGS
-    printSelectedFiles $OPT_ARGS
-}
-
-main

+ 0 - 201
bin/jpgdates

@@ -1,201 +0,0 @@
-#! /bin/bash 
-#title           :jpgdates
-#description     :Select and print info about jpg files based on dates in jpg
-#author		 :gmj@pobox.com
-#date            :Sat Dec 19 15:35:06 2015
-#version         :0.1
-#usage		 :jpgdates [optinos] FILE [FILE...]
-#dependancies	 :http://owl.phy.queensu.ca/~phil/exiftool/
-#notes           :Also experimeting with well-written bash scripts
-#bash_version    :
-#
-# Copyright (C) 2015 George M. Jones
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see http://www.gnu.org/licenses/.
-#
-#==============================================================================
-
-set -u   # exit on undefined
-set -e   # exit on error
-# set -x # echo during execution
-
-# Useful tips
-# http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/
-readonly PROGNAME=$(basename $0)
-readonly PROGDIR=$(readlink -m $(dirname $0))
-readonly ARGS=("$@")
-
-function usage() {
-    if [ $# -gt 0 ]; then echo  "${PROGNAME}: $@"; echo; fi
-    cat <<- EOF
-usage: $PROGNAME [options] FILE [FILE...]
-    
-This program determins if a JPEG file has an Original Date stored
-with it and prints the filename and/or date.
-
-OPTIONS:
-   -w --withdates	Select files with dates
-   -m --missingdates	Select files with no dates
-   -p --path		Print path of matching files
-   -t --dates		Print dates of matching files
-   -i --isomtime	Print ISO-formatted mtime before file
-   -v --verbose         Verbose. You can specify more then one -v to have more verbose
-   -d --debug           debug
-   -h --help            show this help
-    
-Examples:
-   Fine info about a single file
-       $PROGNAME sample.jpg 
-
-   Find info about all jpg files in directory
-       find . -type f -name \*.jpg -print0 | xargs -L 1 -0 $PROGNAME
-
-   Find only Pathnames of jpg files Missing dates:
-       find . -type f -name \*.jpg -print0 | xargs -L 1 -0 $PROGNAME -m -p
-
-   Find all info about jpg files With dates
-       find . -type f -name \*.jpg -print0 | xargs -L 1 -0 $PROGNAME -w 
-
-   Horrible real world invocation to look at the last 10 files of the first 40 available:
-       find . -type f -name \*.jpg -print0 | tr '\0\n' '\n\0' |  head -40 | tail -10 |  tr '\0\n' '\n\0'| xargs -L 1 -n 1 -0 $PROGNAME
-
-EOF
-}
-
-
-function parseArgs() {
-    
-    # Option parsing courtesy of 
-    # http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options
-
-
-    # NOTE: This requires GNU getopt.  On Mac OS X and FreeBSD, you have to install this
-    # separately; see below.
-    TEMP=`getopt -o wmptvdih --long withdates,missingdates,path,dates,isomtime,verbose,debug,help \
-            	  -n 'jpghasDate' -- "$@"`
-
-    if [ $? != 0 ] ; then echo "getopt failed. Terminating..." >&2 ; exit 1 ; fi
-
-    # Note the quotes around `$TEMP': they are essential!
-    eval set -- "$TEMP"
-
-
-    # Set default values
-
-    # Selection Parameters
-    OPT_SELECT_WITH_DATES=false		# print files that have dates
-    OPT_SELECT_MISSING_DATES=false	# print files with no date
-    # Output Parameters
-    OPT_VERBOSE=false			# verbose output
-    OPT_DEBUG=false			# debugging output
-    OPT_PRINT_PATH=false  		# print path
-    OPT_PRINT_DATES=false		# print date
-    OPT_ISO_MTIME=false			# print iso mtime of file before path
-    OPT_PRINT_ALL=true			# print all (default)
-
-    while true; do
-	case "$1" in
-	    -w | --withdates ) OPT_SELECT_WITH_DATES=true; shift ;;
-	    -m | --missingdates ) OPT_SELECT_MISSING_DATES=true; shift ;;
-	    -p | --path ) OPT_PRINT_PATH=true; shift ;;
-	    -t | --dates ) OPT_PRINT_DATES=true; shift ;;
-	    -i | --isomtime ) OPT_ISO_MTIME=true; shift ;;	    
-	    -v | --verbose ) OPT_VERBOSE=true; shift ;;
-	    -d | --debug ) OPT_DEBUG=true; shift ;;
-	    -h | --help ) usage; exit 0;shift ;;        
-	    -- ) shift; break ;;
-	    * ) break ;;
-	esac
-    done
-    
-    if [ $# -lt 1 ] ; then usage "Missing argument.  Need at least one filename."; exit 1; fi
-
-    # Defualt to printing all
-    if ! ( $OPT_PRINT_PATH || $OPT_PRINT_DATES ); then 
-	OPT_PRINT_PATH=true
-	OPT_PRINT_DATES=true
-    fi
-    
-    # Defualt to selectiing all
-    if ! ( $OPT_SELECT_WITH_DATES || $OPT_SELECT_MISSING_DATES ); then 
-	OPT_SELECT_WITH_DATES=true
-	OPT_SELECT_MISSING_DATES=true
-    fi
-
-    # Make parsing paramters readonly
-
-    readonly OPT_SELECT_WITH_DATES=${OPT_SELECT_WITH_DATES}	# print files that have dates
-    readonly OPT_SELECT_MISSING_DATES=${OPT_SELECT_MISSING_DATES}	# print files with no date
-    readonly OPT_VERBOSE=${OPT_VERBOSE}				# verbose output
-    readonly OPT_DEBUG=${OPT_DEBUG}				# debugging output
-    readonly OPT_PRINT_PATH=${OPT_PRINT_PATH}			# print path
-    readonly OPT_PRINT_DATES=${OPT_PRINT_DATES}			# print date
-    readonly OPT_PRINT_ALL=${OPT_PRINT_ALL}			# print all (default)
-
-    OPT_ARGS=("$@")
-
-
-}
-
-function printSelectedFiles () {
-    if $OPT_DEBUG; then 
-	echo ARGS TO printSelectedFiles
-	for ARG in "$@"; do
- 	    printf 'ARG %s\n' "$ARG"
-	done
-    fi
-
-    for file in "$@"; do
-	if $OPT_DEBUG; then echo file $file >&2; fi
-	exifDate=$(exiftool "$file" | grep Orig || echo "NONE")
-	exifDate=$(echo $exifDate | sed -e 's/Date\/Time Original\s*\:\s*//')
-	output=""
-
-	if $OPT_ISO_MTIME; then 	    
-	    epochTime=`stat --printf='%Y' "$file" `
-	    isoTime=`date --date="@$epochTime" -Iminutes`
-	    output="$isoTime $output"
-	fi
-
-	if $OPT_PRINT_PATH; then output="$output$file"; fi
-
-	if $OPT_PRINT_DATES; then output="$output : $exifDate"; fi
-	
-	if $OPT_SELECT_MISSING_DATES; then 
-	    if [[ $exifDate == *"NONE"* ]]; then
-		echo $output
-	    fi
-	fi
-
-	if $OPT_SELECT_WITH_DATES; then 
-	    if [[ $exifDate != *"NONE"* ]]; then
-		echo $output
-	    fi
-	fi    
-    done
-}
-
-function main() {
-    parseArgs "$@"
-
-    printSelectedFiles "${OPT_ARGS[@]}"    
-}
-
-#main
-
-if [ ${#ARGS[@]} -lt 1 ] ; then usage "Missing argument.  Need at least one filename."; exit 1; fi
-    
-main "${ARGS[@]}"
-
-

+ 0 - 190
bin/link2

@@ -1,190 +0,0 @@
-#! /bin/bash
-#
-# Symlink a existing file to a new location.  Rename and link to old versions with datestamps.
-#
-# usage: link2 [options] target [link]
-#     -v | --vrebose	Echo command names
-#     -d | --debug	Additional debugging output
-#     -h | --help		This text
-#     -n | --dry-run	Do not execute
-#     -r | --remove 	Remove link/file if it exists
-#
-# Examples:
-#
-#  $ link2 -v /etc/passwd
-#  ln -s /etc/passwd /home/george/bin/passwd
-#
-#  $ link2 -v /etc/issue passwd
-#  mv passwd passwd.20150609:052604EDT
-#  ln -s /etc/issue passwd
-#
-#  $ link2 -r -v /etc/issue passwd
-#  link2: passwd already points to /etc/issue
-#
-#  $ link2 -r -v /etc/issue passwd
-#  rm -f passwd
-#  ln -s /etc/issue passwd
-#
-#  $ link2 -v /etc/passwd $HOME
-#  ln -s /etc/passwd /home/george/passwd
-#
-#
-# Author:
-#   George Jones
-
-set -e -u
-
-PROG_NAME=$0
-PROG_NAME=`basename $0`
-SHORT_OPTS='vdhnrs:'
-LONG_OPTS='verbose,debug,dry-run,help,remove,stack-size:'
-OPTS=`getopt -o $SHORT_OPTS --long $LONG_OPTS -n 'parse-options' -- "$@"`
-
-function usage() {
-  cat <<END >&2
-usage: $PROG_NAME [options] target [link]
-    -v | --verbose	Echo command names
-    -d | --debug	Additional debugging output
-    -h | --help		This text
-    -n | --dry-run	Do not execute
-    -r | --remove 	Remove link/file if it exists
-END
-exit 1
-}
-
-if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
-
-eval set -- "$OPTS"
-
-# Default values
-
-VERBOSE=false
-HELP=false
-DRY_RUN=false
-STACK_SIZE=0
-DEBUG=false
-REMOVE=false
-
-# Set user selected options
-
-while true; do
-  case "$1" in
-    -v | --verbose ) VERBOSE=true; shift ;;
-    -d | --debug ) DEBUG=true; shift ;;
-    -h | --help )    HELP=true; shift ;;
-    -n | --dry-run ) DRY_RUN=true; shift ;;
-    -r | --remove ) REMOVE=true; shift ;;
-    -s | --stack-size ) STACK_SIZE="$2"; shift; shift ;;
-    -- ) shift; break ;;
-    * ) break ;;
-  esac
-done
-
-if $DEBUG; then
-  VERBOSE=true
-fi
-
-if $DEBUG; then
-    echo VERBOSE=$VERBOSE
-    echo DEBUG=$DEBUG
-    echo HELP=$HELP
-    echo DRY_RUN=$DRY_RUN
-    echo REMOVE=$REMOVE
-    echo STACK_SIZE=$STACK_SIZE
-fi
-
-# validate arguments
-
-if [[ "$STACK_SIZE" =~ '"^[0-9]+$' ]]; then
-  echo "$PROG_NAME: stack_size must be an integer.  Got /$STACK_SIZE/" >&2
-  usage
-fi
-
-
-# get file arguments
-
-if [ "$#" -lt 1 ]; then
-  echo $PROG_NAME: Missing target
-  usage
-fi
-
-if $HELP; then
-  usage
-fi
-
-file=$1
-whereto=${2:-"${PWD}"}
-
-# figure out the link target, make sure it exists
-
-target="`readlink -f $file`"
-if $DEBUG; then echo target $target; fi
-
-if [ ! -e ${target} ]; then
-  echo $0: ${target} does not exist >&2
-  exit 1
-fi
-
-# figure out the link source, using basename of target
-
-base=`basename $file`
-
-if [ -d `readlink -f "${whereto}"` ]; then
-    link="${whereto}""/""${base}"
-else
-    link=${whereto}
-fi
-
-# Remove link if it exists
-
-if  $REMOVE && [ -h $link -o -f $link ]; then
-    if $DRY_RUN || $VERBOSE; then
-	echo rm -f $link
-    fi
-
-    if  ! $DRY_RUN; then
-	rm -f $link
-    fi
-fi
-
-
-# move any pre-existing file to a dated save version, unless it's the same
-
-now=`date "+%Y%m%d:%H%M%S%Z"`
-
-if [ -e ${link} ]; then
-
-    # TODO abort here if target already points to target.
-
-    expandedLink=`readlink -e ${link}`
-    expandedTarget=`readlink -e ${target}`
-
-    if [ ${expandedLink} == ${expandedTarget} ]; then
-       echo $PROG_NAME: ${link} already points to ${target} >&2
-       exit 0
-    fi
-
-    if $DRY_RUN || $VERBOSE; then
-	echo mv ${link} "${link}.${now}"
-    fi
-
-    if  ! $DRY_RUN; then
-	mv ${link} "${link}.${now}"
-    fi
-  
-fi
-
-# finally, make the link
-
-if $DEBUG; then echo target $target  >&2; fi
-
-if $DRY_RUN ||  $VERBOSE; then    
-    echo ln  -s ${target} ${link}
-fi
-
-if ! $DRY_RUN; then
-    ln  -s ${target} ${link}
-fi
-
-
-

+ 0 - 35
bin/link2home

@@ -1,35 +0,0 @@
-#! /bin/bash
-#
-# symlink this directory to ${HOME}
-#
-# This is a special case.  We have to install link2 and linkall by hand to use them.
-
-set -e -u
-
-# Get the path to this (install.sh) script.
-#   See http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
-
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
-  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-  SOURCE="$(readlink "$SOURCE")"
-  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
-done
-DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-
-
-echo DIR is $DIR
-
-base=`basename $DIR`
-
-echo base $base
-
-# remove previous symlinks if any
-
-rm -f ${HOME}/${base}
-
-#bomb out if there is a hard directory
-
-# link this directory to ${HOME}
-
-ln -s $DIR ${HOME}

+ 0 - 169
bin/link2home.sh

@@ -1,169 +0,0 @@
-#! /bin/bash
-# Symlink everything in this directory into a corresponding directory in $HOME
-#
-# - create a directory in $HOME with the same name as this directory
-# - link all files in this directory in the new directory
-# - exclude files listed in .ignore
-
-set -e -u
-
-# Helper functions
-PROG=`basename "$0" | tr -d '\n'`
-
-function info()  { echo ${PROG}\: info: "$@" 1>&2; }
-function warn()  { echo ${PROG}\: warning: "$@" 1>&2; }
-function error() { echo ${PROG}\: error: "$@" 1>&2; }
-function debug() { [[ -v DEBUG ]] && echo ${PROG}\: debug: "$@" 1>&2 || true ; }
-function die()   { echo ${PROG}\: fatal: "$@" 1>&2 && exit 1; }
-
-#
-# Command line parsing
-#
-
-function usage() {
-    debug "in ${FUNCNAME[0]}"
-
-    if [[ "$#" -gt 0 ]]; then
-	warn $@
-    fi
-
-    cat <<END 1>&2
-Usage: ${PROG} [options]
-
-   options
-
-     -d|--debug         debug output
-     -h|--home          link directly to $HOME
-     -l|--linkdir       symlink directory itself
-     -r|--remove        remove old files
-     -v|--verbose       verbose output
-
-END
-    exit 1
-}
-
-# globals variables
-
-declare -A EXCLUSIONS
-
-# parse global options
-
-for i in "$@"
-do
-    case $i in
-	-d|--debug)
-	    DEBUG=1
-	    d_flag="-d"
-	    shift # past argument with no value
-	    ;;
-	-l|--linkdir)
-	    LINKDIR=1
-	    d_flag="-d"
-	    shift # past argument with no value
-	    ;;
-	-h|--home)
-	    TOHOME=1
-	    d_flag="-d"
-	    shift # past argument with no value
-	    ;;
-	-r|--remove)
-	    REMOVE=1
-	    # remove old files
-	    shift # past argument with no value
-	    ;;
-	-v|--verbose)
-	    VERBOSE=1
-	    v_flag="-v"
-	    shift # past argument with no value
-	    ;;
-	-*|--*)
-	    usage "Unknown state option: $i"
-	    ;;
-    esac
-done
-
-# Pull off command line args
-
-if [ "$#" -ge 1 ]; then
-    usage "No arguments expected"
-fi
-
-# Get abolute path to directory of current file
-#REALDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-# use current directory
-WHERE_AM_I=`pwd`
-
-# Extract the directory name of this file
-BASEDIR=`basename $WHERE_AM_I`
-
-# create name of directory in $HOME
-
-if [[ -v TOHOME ]]; then
-    DIR_IN_HOME="${HOME}"
-else
-    DIR_IN_HOME="${HOME}/${BASEDIR}"
-fi
-
-if [[ -v LINKDIR ]]; then
-
-    if [ -v REMOVE ]; then
-
-	if [[ "${HOME}" == "${DIR_IN_HOME}" ]]; then
-	    [[ -v VERBOSE ]] &&  info not removing "${HOME}"
-	else
-	  rm -f "${DIR_IN_HOME}"
-	  [[ -v VERBOSE ]] &&  info rm -f "${DIR_IN_HOME}"
-	fi
-    fi
-
-    [[ -v VERBOSE ]] &&  info ln -s "${WHERE_AM_I}" "${DIR_IN_HOME}"
-    ln -s "${WHERE_AM_I}"  "${DIR_IN_HOME}" || warn "Unable to link ${WHERE_AM_I}"
-
-    exit 0
-else
-    # crate the directory name in $HOME if DNE
-    mkdir -p "${DIR_IN_HOME}"
-fi
-
-#
-# symlink everything here to $HOME
-#
-cd "${WHERE_AM_I}"
-
-if [ -f '.ignore' ]; then
-    for exclude in `cat .ignore`; do
-	EXCLUSIONS["${exclude}"]="${exclude}"
-    done
-fi
-
-debug linking files
-
-#for file in * .[a-z]*; do
-for file in * .[a-z0-9A-Z_\-]*; do
-
-    SOURCE="${WHERE_AM_I}/${file}"
-    TARGET="${DIR_IN_HOME}/${file}"
-
-    [ -e "${file}" ] || continue
-
-    if [ ${EXCLUSIONS["${file}"]+DNE} ]; then
-	info skiping "${file}"
-    else
-
-	if [ -v REMOVE ]; then
-
-	    [[ -v VERBOSE ]] &&  info rm -f "${DIR_IN_HOME}/${file}"
-	    rm -f "${DIR_IN_HOME}/${file}"
-	fi
-
-	if [ -h "${TARGET}" ]; then
-	    [[ -v VERBOSE ]] &&  info "${TARGET}" already exists. Skipping.
-	else
-	    [[ -v VERBOSE ]] &&  info ln -s "${SOURCE}" "${DIR_IN_HOME}"
-	    ln -s "${SOURCE}"  "${DIR_IN_HOME}" || warn "Unable to link ${SOURCE}"
-	fi
-
-    fi
-
-
-done

+ 0 - 161
bin/linkall

@@ -1,161 +0,0 @@
-#! /bin/bash
-#
-# symlink all files in an src directory to a target directory
-#
-# usage: link2 [options] srcDir [targetDir]
-#     -v | --verbose	Echo command names
-#     -d | --debug	Additional debugging output
-#     -h | --help		This text
-#     -n | --dry-run	Do not execute
-#     -r | --remove 	Remove link/file if it exists
-#
-# targetDir is created (mkdir -p) if it does not exist.   Existing
-# symlinks are replaced.
-#
-
-# Examples:
-#
-#  Link all files in /etc to ./etc, creating ~./etc if needed
-#
-#    $ linkall -v /etc
-#  
-#
-#  Link all files in ~/git/public/dotfiles to $HOME, replacing existing links
-#
-#    $ linkall ~/git/public/dotfiles $HOME
-#
-
-# Author:
-#   George Jones
-
-set -e -u
-
-PROG_NAME=$0
-PROG_NAME=`basename $0`
-SHORT_OPTS='vdhnrs:'
-LONG_OPTS='verbose,debug,dry-run,help,remove,stack-size:'
-OPTS=`getopt -o $SHORT_OPTS --long $LONG_OPTS -n 'parse-options' -- "$@"`
-
-function usage() {
-  cat <<END >&2
-usage: $PROG_NAME [options] srcDir targetDir
-    -v | --verbose	Echo command names
-    -d | --debug	Additional debugging output
-    -h | --help		This text
-    -n | --dry-run	Do not execute
-    -r | --remove 	Remove link/file if it exists
-END
-exit 1
-}
-
-if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
-
-eval set -- "$OPTS"
-
-# Default values
-
-VERBOSE=false
-HELP=false
-DRY_RUN=false
-STACK_SIZE=0
-DEBUG=false
-REMOVE=false
-
-# Set user selected options
-
-while true; do
-  case "$1" in
-    -v | --verbose ) VERBOSE=true; shift ;;
-    -d | --debug ) DEBUG=true; shift ;;
-    -h | --help )    HELP=true; shift ;;
-    -n | --dry-run ) DRY_RUN=true; shift ;;
-    -r | --remove ) REMOVE=true; shift ;;
-    -s | --stack-size ) STACK_SIZE="$2"; shift; shift ;;
-    -- ) shift; break ;;
-    * ) break ;;
-  esac
-done
-
-if $DEBUG; then
-  VERBOSE=true
-fi
-
-if $DEBUG; then
-    echo VERBOSE=$VERBOSE
-    echo DEBUG=$DEBUG
-    echo HELP=$HELP
-    echo DRY_RUN=$DRY_RUN
-    echo REMOVE=$REMOVE
-    echo STACK_SIZE=$STACK_SIZE
-fi
-
-# validate arguments
-
-if [[ "$STACK_SIZE" =~ '"^[0-9]+$' ]]; then
-  echo "$PROG_NAME: stack_size must be an integer.  Got /$STACK_SIZE/" >&2
-  usage
-fi
-
-
-# get file arguments
-
-if [ "$#" -lt 1 ]; then
-  echo $PROG_NAME: missing srcDir
-  usage
-fi
-
-if $HELP; then
-  usage
-fi
-
-srcDir=$1
-targetDir=${2:-"${PWD}"}
-
-# figure out the link target, make sure it exists
-
-if [ ! -d ${srcDir} ]; then
-  echo $0: ${srcDir} does not exist or is not a directory>&2
-  exit 1
-fi
-
-
-# Make sure targetDir exists, creating if necessary
-
-
-if [ -d `readlink -f "${targetDir}"` ]; then
-  if $DRY_RUN || $VERBOSE; then
-  	echo ${targetDir} exists
-  fi
-
-elif [ -e "${targetDir}" ]; then
-  echo $0: ${targetDir} exists but is not  or is not a directory>&2
-  exit 1
-else
-  if $DRY_RUN || $VERBOSE; then
-  	echo mkdir -p  ${targetDir}
-  fi
-  mkdir -p "${targetDir}"
-fi
-
-
-
-# Link all files in $srcDir to $targetDir
-
-cd "$srcDir"
-
-for f in `ls -1 -a`; do
-
-  if [ "$f" == '.' ] || [ "$f" == '..' ]; then
-    continue
-  fi
-
-  if $DRY_RUN || $VERBOSE; then
-        echo rm -f  "$targetDir/$f" || true
-  fi
-
-  rm -f  "$targetDir/$f" || true
-  ln -s  "$srcDir/$f" "$targetDir"
-done
-
-
-

+ 0 - 32
bin/logCommand.sh

@@ -1,32 +0,0 @@
-#! /bin/bash
-
-# log command line invocation and then invoke the origianl command
-#
-# Usage:
-#
-#   mv foo foo.orig
-#   ln -s logCommand.sh foo
-#
-# where foo is some executable, then
-#
-#  foo
-#
-# and
-#
-#  tail ${HOME}/logCommand.log
-#
-# to see command arguments.
-#
-# HISTORY:
-#    <2014-04-01 Tue>, George Jones, crteated.
-
-logTo=${HOME}/logCommand.log
-
-cmdName=${0}.orig
-
-touch $logTo
-echo `date` ${cmdName} is about to execute  ${cmdName} $*  >> $logTo
-$cmdName $*
-
-
-

+ 0 - 185
bin/logstats.py

@@ -1,185 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-Print stats for log files in a list of directories
-
-This program takes a list of log file directories and prints various statistics
-for the files in the directories
-"""
-
-__author__ = 'George Jones'
-__maintainer__ = 'George Jones'
-__email__ = 'gmj@pobox.com'
-__version__ = '0.0.1'
-
-import optparse
-import os
-import fnmatch
-import sys
-from os import path
-import time
-import gzip
-
-# Setup
-
-def parse_args(argv):
-    global optp
-    usage = """
-        %prog [--quiet] <dir_name> [<dir_name> ...]"""
-
-    # Parse arguments.
-    optp = optparse.OptionParser(description=__doc__.strip(), version=__version__,
-                             usage=usage)
-    optp.add_option('-d', '--debug', help="Print debugging output",
-                action='store_true')
-    optp.add_option('-q', '--quiet', help="be quiet! (For use with scripts/cron)",
-                action='store_true')
-    optp.add_option('-n', '--byname', help="Compare file dates lexically by filename, not mtime (not implemetned)",
-                action='store_true')        
-    optp.add_option('-f', '--files', type='string', action='append',
-                    metavar='<files',
-                    default="*.log" ,
-                    help="files to match (regexp), example: '2015-10-*.log', default: '*.log'")
-    (opts, args) = optp.parse_args()
-
-    return opts, args
-
-def p_error(msg=None):
-    optp.print_help()
-    if msg:
-        optp.error(msg)
-    sys.exit(1)
-
-def main():
-
-    # Parse arguments
-
-    global opts
-    opts, args = parse_args(sys.argv)
-    
-    if (len(args) == 0):
-        p_error("need at least one directory name")
-        sys.exit(1)
-
-    if opts.debug:
-        print "args", args
-
-    # print header
-
-
-    print  "|".join(["","dir","totalFiles","totalSize","totalLines","avgRecord","oldestTime","oldestFile","newestTime","newestFile",""])      
-
-    # Enumaerate log files of interest
-
-    for dir in args:
-
-        # initialize totals for this directory
-
-        dirTotalsFiles = 0
-        dirTotalsSize = 0
-        dirTotalsLines = 0
-        dirTotalsOldestTimestamp = 4000000000 # 'Tue Oct  2 03:06:40 2096'. 
-                                              # If this code is running after that...
-                                              # George Jones <gmj@pobox.com>  Sat Oct 31 10:21:59 2015
-        dirTotalsOldestName = ""
-        dirTotalsNewestTimestamp = 0
-        dirTotalsNewestName = ""
-
-        if opts.debug:
-            print "dir", dir
-
-        if not os.path.isdir(dir):
-            sys.stderr.write(dir, ' is not a directory, skipping'+ str(e))
-            next
-
-        files = [dir + "/" + f for f in os.listdir(dir)  
-                 if 
-                 (path.isfile(dir + "/" + f) and 
-                  (fnmatch.fnmatch(f,opts.files) or
-                   fnmatch.fnmatch(f,opts.files + ".*.gz")))]
-        if opts.debug:
-            print "files", files
-
-        for file in files:
-            
-            # handle compressed files if requested
-            
-            # Get direct info about the file
-
-            statinfo = os.stat(file)
-
-            if file.endswith(".gz"):
-                num_lines = sum(1 for line in gzip.open(file,'rb'))
-
-                if opts.debug:
-                    sys.stderr.write('Compressed file  ' + file + ' has  ' + str(num_lines) + ' lines' + "\n")
-                
-            else:
-                try:
-                    num_lines = sum(1 for line in open(file))
-                except Exception, e:
-                    sys.stderr.write('Unable to count lines in ' + file + ' '+ str(e) + "\n")
-                    num_lines = 0
-
-
-            if opts.debug:
-                print "file:", file, "size", statinfo.st_size,  "num_lines", num_lines, "mtime:", time.ctime(statinfo.st_mtime)
-
-            # compute derived statistics about the file
-
-            if num_lines > 0:
-                avgLineSize = statinfo.st_size / num_lines
-            else:
-                avgLineSize = 0
-
-            # Add info to summary list
-
-            dirTotalsFiles += 1
-            dirTotalsSize += statinfo.st_size
-            dirTotalsLines += num_lines
-
-            # keep track of oldest and newest files
-
-            if opts.byname:
-                if dirTotalsOldestName == "" or file < dirTotalsOldestName:
-                    if opts.debug:
-                        print "New Oldest File ", file
-                    dirTotalsOldestName = file
-                    dirTotalsOldestTimestamp = 0
-
-                if dirTotalsNewestName == "" or file > dirTotalsNewestName:
-                    if opts.debug:
-                        print "New Newest File ", file
-                    dirTotalsNewestName = file
-                    dirTotalsNewestTimestamp = 0
-                    
-            else:
-                if statinfo.st_mtime < dirTotalsOldestTimestamp:
-                    if opts.debug:
-                        print statinfo.st_mtime, "<", dirTotalsOldestTimestamp
-                        print "New Oldest Timestamp: ", dirTotalsOldestTimestamp                
-                    dirTotalsOldestTimestamp = statinfo.st_mtime
-                    dirTotalsOldestName = file
-
-
-                if statinfo.st_mtime > dirTotalsNewestTimestamp:
-                    if opts.debug:
-                        print statinfo.st_mtime, ">", dirTotalsNewestTimestamp
-                        print "New Newest Timestamp: ", dirTotalsNewestTimestamp                
-                    dirTotalsNewestTimestamp = statinfo.st_mtime
-                    dirTotalsNewestName = file
-
-        # compute derived statistics about the directory
-
-        if dirTotalsLines > 0:
-            dirAvgRecord = dirTotalsSize / dirTotalsLines
-        else:
-            dirAvgRecord = 0
-
-        # print directory summary
-        
-        print "|".join(["",dir, str(dirTotalsFiles),str(dirTotalsSize),str(dirTotalsLines),str(dirAvgRecord),time.ctime(dirTotalsOldestTimestamp),dirTotalsOldestName,time.ctime(dirTotalsNewestTimestamp),dirTotalsNewestName,""])
-
-if __name__ == '__main__':
-    main()

+ 0 - 16
bin/myip

@@ -1,16 +0,0 @@
-#! /bin/bash
-# script to determine my public IP address
-
-# deal with timeouts?
-#myIP=`dig +short @resolver1.opendns.com myip.opendns.com`
-#myIP=`curl -s ifconfig.me`
-#echo "$myIP"
-#curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' 
-
-# This works very well, and quickly !!!
-# http://serverfault.com/questions/89114/finding-the-public-ip-address-in-a-shell-script
-dig @resolver1.opendns.com myip.opendns.com +short
-
-
-
-

+ 0 - 14
bin/old/emacs-pkg-install.sh

@@ -1,14 +0,0 @@
-#!/bin/sh
-# From 
-#   http://hacks-galore.org/aleix/blog/archives/2013/01/08/install-emacs-packages-from-command-line
-
-
-if [ $# -ne 1 ]
-then
-  echo "Usage: `basename $0` <package>"
-  exit 1
-fi
-
-which emacs
-
-emacs-snapshot --batch --eval "(defconst pkg-to-install '$1)" -l ~/elisp/emacs-pkg-install.el

+ 0 - 5
bin/old/get-emacs.sh

@@ -1,5 +0,0 @@
-#! /bin/bash
-sudo add-apt-repository ppa:cassou/emacs
-sudo apt-get update
-sudo apt-get purge emacs emacs-snapshot-common emacs-snapshot-bin-common emacs-snapshot emacs-snapshot-el emacs-snapshot-gtk emacs23 emacs23-bin-common emacs23-common emacs23-el emacs23-nox emacs23-lucid auctex apel emacs24 emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacs24-el
-sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot

+ 0 - 45
bin/old/mtime

@@ -1,45 +0,0 @@
-#! /bin/sh
-# WHAT: find files modified in the current directory and subdirectories in a given range of days.
-#
-# WHY: I use this to find files I've been working on in a given date range.
-#
-# USAGE:
-#	modified [oldest [youngest]]
-#
-#         - oldest is the oldest modtime to include.  Default 7.
-#         - youngest is the youngest modtime to  include.  Default 0.
-#
-# EXAMPLES:
-#	Show the files modified in the last week.
-#
-#	  $ modified
-#
-#       Show the files modified last week
-#
-#	  $ modified 14 7
-#
-#       Show fils modified 3 weeks ago
-#
-#         $ modified 28 21
-#
-# NOTES:
-#	Filenames with a space (" ") in them are a problem.  
-#       For now, we use "*" to match spaces.
-#
-# TODO:
-#       - Do something better for filenames with spaces.
-#       - Use some flavor of getopt
-#         + Allow specification of atime
-#	  + Allow specification of directory and filename
-#          
-#
-# HISTORY
-#	gmj@pobox.com - 2014-02-26 - created.
-
-
-# usecomand line args, or supply defaults
-OLDEST=${1:-7}
-YOUNGEST=${2:-0}
-
-#ls -ltd `find . -mtime +${YOUNGEST} -mtime -${OLDEST} -print | sed 's/ /*/g'`
-ls -ltd `find . -mtime -${OLDEST} -print | sed 's/ /*/g'`

+ 0 - 18
bin/old/whatsMyLocation.sh

@@ -1,18 +0,0 @@
-#! /bin/bash
-# script to determine where I am
-
-whereAmI=
-if [ -x /usr/sbin/airport ]; then
-  # http://osxdaily.com/2012/02/28/find-scan-wireless-networks-from-the-command-line-in-mac-os-x/
-#  if grep -q '^[ \t]*foo' <<<`/usr/sbin/airport -s`; then
-
-  if grep -q '[ \t]foo' <<<`/usr/sbin/airport -s`; then
-      whereAmI="home"
-  fi
-
-  if grep -q '[ \t]SEIDC' <<<`/usr/sbin/airport -s`; then
-      whereAmI="work"
-  fi
-fi
-
-echo $whereAmI

+ 0 - 11
bin/old/whatsMyOS.sh

@@ -1,11 +0,0 @@
-#! /bin/bash -f
-
-osName=""
-if grep -q -i Darwin <<<"`uname -a`"; then
-    osName="mac";
-elif grep -q -i linux <<<"`uname -a`"; then
-    osName="linux";
-fi
-
-echo $osName
-

+ 0 - 6
bin/rdns

@@ -1,6 +0,0 @@
-#!/bin/bash
-# Do reverse DNS lokup
-myhostname=`host $1`
-if [ "$?" -eq 0 ]; then
-  echo `echo $myhostname | cut -d " " -f 5`
-fi

+ 0 - 26
bin/sshagent

@@ -1,26 +0,0 @@
-#! /bin/bash
-
-# http://stackoverflow.com/questions/18880024/start-ssh-agent-on-login
-
-SSH_ENV="$HOME/.ssh/environment"
-
-function start_agent {
-    echo "Initialising new SSH agent..."
-    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
-    echo succeeded
-    chmod 600 "${SSH_ENV}"
-    . "${SSH_ENV}" > /dev/null
-    /usr/bin/ssh-add;
-}
-
-# Source SSH settings, if applicable
-
-if [ -f "${SSH_ENV}" ]; then
-    . "${SSH_ENV}" > /dev/null
-    #ps ${SSH_AGENT_PID} doesn't work under cywgin
-    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
-        start_agent;
-    }
-else
-    start_agent;
-fi

+ 0 - 54
bin/thatsNotRight.sh

@@ -1,54 +0,0 @@
-1#! /bin/bash
-# Create a report about Things That Are Not Right on my home Ubuntu system.
-#
-# Usage:
-#
-#	thatsNotRight.sh 
-#
-# Inputs:
-#
-# Outputs:
-#	output on stdout for logging, mailing, grepping, etc.
-#
-#
-# Author: Geroge Jones
-# Date: 2014-11-16
-#
-
-#
-# When is this run ?
-#
-
-#
-# uptime
-#
-# Start simple with a (nonroot) cron like this
-#
-#   6 * * * *  uptime >> ${HOME}/log/$(date +\%Y\%m\%d)_uptime.log
-#
-# then parse the output (should be 24 entries/day)
-# For more fancy solutions, see http://stackoverflow.com/questions/79490/linux-uptime-history 
-
-updateLogfile=/home/george/log/$(date +\%Y\%m\%d)_uptime.log
-wc -l ${updateLogfile=} | sed 's/^/UptimeCount: /g'
-
-#
-# System reboots 
-#
-
-last reboot | sed 's/^/lastReboot: /g'
-
-#
-# Bad login attempts
-#
-# Thanks to http://securitasdato.blogspot.com/2010/01/fun-with-lastb.html
-#
-
-lastb -i -a | head -20 | sed 's/^/lastb: /g'
-
-# Reporting bad behavior
-#
-# Possibly participate here http://www.blocklist.de/en/index.html
-#
-
-

+ 0 - 23
bin/whoIsOnMySubnet

@@ -1,23 +0,0 @@
-#! /bin/bash
-#
-# A quick script to see who (DNS names) are on the same subnet.  
-# Assumes eth0 and /24.
-#
-# Usage: onMySubnet [ip]
-#
-# George Jones <gmj@pobox.com>, Wed Sep 30 05:50:02 2015
-#
-
-eth0Addr=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
-
-addrWith4Octets="${1:-${eth0Addr}}"
-
-
-addrWith3Octets=`echo $addrWith4Octets | cut -d"." -f1-3`
-
-i=1;
-while [ "$i" -lt 255 ]; do 
-    host ${addrWith3Octets}.$i | grep -v NX; 
-    i=$((i+1)); 
-done
-