#! /bin/tcsh -f # {{{ Versioning and license info # # $Id: setup,v 1.13 2006/08/21 15:55:14 proclus Exp $ # Many thanks to Robert L. Campbell # Copyright (C) 2006 Michael L. Love # # 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 2 # 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # or find it at: http://www.gnu.org/copyleft/gpl.html # # }}} # {{{ Variable definitions setenv BOLD "" setenv UNBOLD "" setenv PREMARK "[01;" setenv POSTMARK "m" setenv UNMARK "" # cleanup ansi here ;-} # setenv UNMARK "" setenv UNMARK "" setenv UNMARK "" setenv UNMARK "" setenv LTGREY ${PREMARK}0${POSTMARK} setenv UNLTGREY ${UNMARK} setenv UNDERLINE ${PREMARK}4${POSTMARK} setenv UNUNDERLINE ${UNMARK} setenv BLINK ${PREMARK}5${POSTMARK} setenv UNBLINK ${UNMARK} setenv BLOCK ${PREMARK}7${POSTMARK} setenv UNBLOCK ${UNMARK} setenv GREY ${PREMARK}30${POSTMARK} setenv UNGREY ${UNMARK} setenv YELLOW ${PREMARK}33${POSTMARK} setenv UNYELLOW ${UNMARK} setenv GREEN ${PREMARK}32${POSTMARK} setenv UNGREEN ${UNMARK} setenv BLUE ${PREMARK}34${POSTMARK} setenv UNBLUE ${UNMARK} setenv CYAN ${PREMARK}36${POSTMARK} setenv UNCYAN ${UNMARK} setenv RED ${PREMARK}31${POSTMARK} setenv UNRED ${UNMARK} setenv MAGENTA ${PREMARK}35${POSTMARK} setenv UNMAGENTA ${UNMARK} setenv WHITE ${PREMARK}37${POSTMARK} setenv UNWHITE ${UNMARK} setenv BLOCKYELLOW ${PREMARK}43${POSTMARK} setenv UNBLOCKYELLOW ${UNMARK} setenv BLOCKGREEN ${PREMARK}42${POSTMARK} setenv UNBLOCKGREEN ${UNMARK} setenv BLOCKBLUE ${PREMARK}44${POSTMARK} setenv UNBLOCKBLUE ${UNMARK} setenv BLOCKCYAN ${PREMARK}46${POSTMARK} setenv UNBLOCKCYAN ${UNMARK} setenv BLOCKRED ${PREMARK}41${POSTMARK} setenv UNBLOCKRED ${UNMARK} setenv BLOCKMAGENTA ${PREMARK}45${POSTMARK} setenv UNBLOCKMAGENTA ${UNMARK} setenv BLOCKWHITE ${PREMARK}47${POSTMARK} setenv UNBLOCKWHITE ${UNMARK} # }}} # {{{ Set some basic/general values # determine operating system (architecture) setenv OS `uname -s` setenv OS_VERSION `uname -r` setenv MACHINE `uname -m` if ( -f /etc/debian_version ) then setenv DISTRO Debian else if ( -f /etc/fedora-release ) then setenv DISTRO FedoraCore else setenv DISTRO endif # make some big programs run better! if ( ${OS} != 'Darwin' && ${OS_VERSION} != '7.0.0' ) then unlimit stacksize limit coredumpsize 0 endif # }}} ############### # Host arrays # # set these! # ################################################################################ setenv theDarwins "darwintel gd-serv-01 gd-shell-02 kepler moerbeke" setenv theDx86 "darwintel gd-serv-01 gd-shell-02" setenv All "darwintel gd-serv-01 gd-shell-02 kepler moerbeke medici" ################################################################################ # strip path from command, yawn foreach dirFileName ( `echo $0 | sed s/'\/'/' '/g` ) setenv command "$dirFileName" end # # Each host array has two commands assigned; a my* command to list # the hosts, and a run* command to execute a command on the hosts # concurrently. pdsh is used for the concurrency below, but there # are alternatives, such as dsh. Plain ssh could be used to run # non-concurrently. # # We use a bash version of this program to parallel execute on about # 30 hosts in my department at work, but I am keeping the bash # version private ;-}. # # start command switch switch ($command) case "mydx": setenv theHosts "${theDx86}" goto doMyHosts breaksw case "rundx": setenv theHosts "${theDx86}" goto doRunIt breaksw case "mydar": setenv theHosts "${theDarwins}" goto doMyHosts breaksw case "rundar": setenv theHosts "${theDarwins}" goto doRunIt breaksw case "myall": setenv theHosts "${All}" goto doMyHosts breaksw case "runall": setenv theHosts "${All}" goto doRunIt breaksw default: echo $YELLOW"Welcome to proclus' admin tool. For usage info use vi."$UNYELLOW exit endsw # end command switch doMyHosts: echo ${theHosts} | sed s/' '/'; echo '/g | sed s/'^'/'echo '/ | csh exit doRunIt: setenv pdshHostArgs "`echo '${theHosts}' | sed s/' '/' -w '/g`" pdsh -R ssh -l root -w ${pdshHostArgs} $* exit