[ncolug] Re: Linux Home Automation

  • From: nor thern <zboson2003@xxxxxxxxx>
  • To: ncolug@xxxxxxxxxxxxx
  • Date: Sun, 16 Dec 2007 12:55:25 -0800 (PST)

Rob Gibson <nosbig@xxxxxxxxx> wrote: Here is the next revision...  What do you 
all think?


# Initialize command substitutions

# Initialize Paths and Ports

${PING} -c 5 www.google.com &> /dev/null || ${MKTEMP} -p ${TMPPATH}
if [ $(${FIND} ${TMPPATH} -type f -name "${TEMPLATE}*" -print | ${WC}
-l) -gt 2 ]
###if [ $(${LS} -1 ${TMPPATH}/${TEMPLATE}* | ${WC} -l) -gt 2 ]
        ${BR} -x ${X10PORT} ${X10DEVICE} OFF
        ${SLEEP} 5
        ${BR} -x ${X10PORT} ${X10DEVICE} ON
        for file in $(${FIND} ${TMPPATH} -type f -name "${TEMPLATE}*" -print)
                ${RM} ${file}
        ${ECHO} -ne "Network Failure: " >> ${LOGFILE}
        ${ECHO} $(${DATE} +"%Y-%m-%d-%M%S") >> ${LOGFILE}

On Dec 15, 2007 11:35 PM, Mike  wrote:
> Rob Gibson wrote:
> > Since Mike raised the issue, why is it bad to use a ~/bin directory?
> > This script is a bad example, as the actions of this script inherently
> > affect all users of the system.  In production use (and my next
> > revision), I would put the script in /usr/local/bin.  But, I have
> > several scripts which are just short one-line scripts for recalling
> > some of my personal internet radio streams.  For those items which are
> > designed by one user for that user to only, would it not make sense to
> > place the files in the user's home directory?  Or did I miss a chapter
> > of the FHS or something?  ;-)
> >
> Short one liners are great in ~/bin, that is one place to put them.
> Often I create ~/temp.d or ~/tmp.d and put stuff there.  Those aren't in
> my path so must be called appropriately.  No this isn't a violation of
> FHS to my knowledge, just be warned that on a multiple user system it
> will cause you headaches.  Chuck offered to comment in another post if
> there was interest.  I still will defer all further to him, too many
> nightmares!
> > The new revision will include mktemp directories and placing them in
> > /var/tmp.  I like the idea of having all of the files located in a
> > designated temp directory.  The output is definitely something I would
> > keep.  I just don't want cron reporting the success output of 5 pings
> > every 5 minutes...  ;-)  So, I dumped that output.  If anything else
> > goes wrong, I will get the message.
> >
> Guess I might not have gotten my point across here.  Cron by default
> will email you _any_ output that a script generates, not just errors.
> If this info isn't useful most people start treating it like spam and
> start to ignore it.
> > The serial device permissions, I am not worried about.  The perms on
> > /dev/ttyS0 are 660 with root:dialout.  My user belongs to the dialout
> > group.  Since no dial-up modems are in use here and never will be on
> > this device, I might remove all users from dialout, add nobody to that
> > group, and run the script from nobody's crontab.
> >
> > Rob
> The dialout group is probably just a legacy name nowadays.  My point was
> probably missed here also.  Say in the current version someone did get
> control via a race condition or some other method.  When they got a
> shell or the ability to execute an overwritten file, they now have
> access to the serial port as you, also then control of your X10 devices.
>   Likely to happen?  Probably not a high risk, still worthy of
> consideration in my mind.  Actually I'd be more concerned that the race
> condition existed to begin with.
> Mike
> nice work, Rob, i see where there revisions were placed
is the file kept in /usr/local/bin ?

Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

Other related posts: