Changeset 120
- Timestamp:
- 12/04/2006 01:32:20 (5 years ago)
- Location:
- trunk/confman
- Files:
-
- 3 added
- 4 edited
-
Makefile (modified) (1 diff)
-
confman (modified) (3 diffs)
-
confman.conf (modified) (2 diffs)
-
confmancommon.sh (added)
-
confmanlib.sh (modified) (5 diffs)
-
confsync.sh (added)
-
export.sh (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/confman/Makefile
r119 r120 2 2 PREFIX := $(PREFIX)/rescomp 3 3 4 DIRFLAGS = -d -o root -g wheel -m 0555 5 EXFLAGS = -Sp -o root -g wheel -m 0555 6 INFLAGS = -Sp -o root -g wheel -m 0444 7 8 BINFILES = abspath 9 SBINFILES = confman 10 LIBEXECFILES = export.sh confsync.sh 11 LIBFILES = confmanlib.sh confmandoc.sh 12 ENVFILES = confman_completions 13 DIRECTORIES = /etc /etc/env.d /lib /sbin /bin /libexec 14 4 15 install : 5 mkdir -p $(PREFIX)/etc/env.d 6 mkdir -p $(PREFIX)/lib 7 mkdir -p $(PREFIX)/sbin 8 mkdir -p $(PREFIX)/bin 16 .for dir in $(DIRECTORIES) 17 install $(DIRFLAGS) ${dir} 18 .endfor 19 .for file in $(BINFILES) 20 install $(EXFLAGS) ${file} $(PREFIX)/bin/ 21 .endfor 22 .for file in $(SBINFILES) 23 install $(EXFLAGS) ${file} $(PREFIX)/sbin/ 24 .endfor 25 for file in $(LIBEXECFILES) 26 install $(EXFLAGS) ${file} $(PREFIX)/libexec/ 27 .endfor 28 for file in $(LIBFILES) 29 install $(INFLAGS) ${file} $(PREFIX)/lib/ 30 .endfor 31 .for file in $(ENVFILES) 32 install $(INFLAGS) ${file} $(PREFIX)/etc/env.d/ 33 .endfor 34 install -Sp -o root -g wheel -m 0444 confman.conf \ 35 $(PREFIX)/etc/confman.conf-default 9 36 install -Sp -o soluzer -g wheel -m 0444 confmanrc \ 10 37 /var/home/soluzer/.confmanrc 11 install -Sp -o root -g wheel -m 0555 confman $(PREFIX)/sbin/confman12 install -Sp -o root -g wheel -m 0555 abspath $(PREFIX)/bin/abspath13 install -Sp -o root -g wheel -m 0444 confman.conf \14 $(PREFIX)/etc/confman.conf-default15 install -Sp -o root -g wheel -m 0444 confmanlib.sh \16 $(PREFIX)/lib/confmanlib.sh17 install -Sp -o root -g wheel -m 0444 confmandoc.sh \18 $(PREFIX)/lib/confmandoc.sh19 install -Sp -o root -g wheel -m 0444 bash_completions \20 $(PREFIX)/etc/env.d/confman_completions21 38 22 39 fetch: -
trunk/confman/confman
r117 r120 12 12 # $Id$ 13 13 14 15 16 # Some global definitions. Defaults that can be overriden by options. 17 GCONF="/usr/local/rescomp/etc/confman.conf" 18 UCONF="${HOME}/.confmanrc" 19 MYNAME=`basename $0` 20 21 # First things first. Check to see if the logging fd is open. If it's not, 22 # we re-spawn confman inside a pipe. 23 if (true >&5) 2>/dev/null ; then 24 exec 4>&2 2>&5 >&3- 25 else 26 exec 3>&1 27 exec $0 $* 5>&1 1>&3 | logger -t "$MYNAME ($USER)" -s 28 exit ${PIPESTATUS[0]} 29 fi 30 31 # Get the global config 32 if [ -f $GCONF ] ; then 33 . $GCONF 34 else 35 echo "Global config file couldn't be located" >&2 36 exit 1 37 fi 38 39 # Get the user config 40 if [ -f $UCONF ] ; then 41 . $UCONF 42 fi 43 44 # Set debugging: 45 if [ -z $DEBUG ] ; then 46 DEBUG="false" 47 fi 48 49 # Now, we source the library 50 if [ -f $REPO_LIBRARY ] ; then 51 . $REPO_LIBRARY 52 else 53 echo "Couldn't source the confman shell library" >&2 54 exit 1 55 fi 56 57 # And the documentation library 58 if [ -f $REPO_DOCS ] ; then 59 . $REPO_DOCS 60 else 61 echo "Couldn't source the confman shell library" >&2 62 exit 1 63 fi 64 65 # And we read in the layers that make this host 66 if [ -f $RECIPE_PATH ] ; then 67 LAYERS=`cat $RECIPE_PATH | grep "^[^#]"` 68 else 69 echo "Couldn't read the host's recipe!" >&2 70 exit 1 71 fi 14 #. /usr/local/rescomp/lib/confmancommon.sh 15 . $HOME/src/sysadmin/confman/confmancommon.sh 72 16 73 17 # Set a default editor … … 83 27 # Have to make this less restrictive due to NFS home dirs. 84 28 umask 022 85 86 # And we'll set a trap:87 trap "conf_cleanexit" SIGINT SIGTERM SIGHUP88 89 29 90 30 # This function implements the setup subcommand. It is intended to be called … … 148 88 149 89 echo "Commit operation started" >&2 150 for layer in $LAYERS ; do 151 conf_commit $layer $msg || return $? 152 done 90 conf_commit "$LAYERS" $msg || return $? 153 91 for layer in $LAYERS ; do 154 92 echo "Rolling on $layer..." -
trunk/confman/confman.conf
r100 r120 14 14 15 15 # The hostname providing our config repository: 16 REPO_HOSTNAME=" kermit.rescomp.berkeley.edu"16 REPO_HOSTNAME="svn.rescomp.berkeley.edu" 17 17 18 18 # The path on the remote host to find the repository: … … 42 42 DEFAULT_COMMENT="#" 43 43 44 # This is the URI for clients to locate the exported working copy. This 45 # is used by system processes (crons). There are URI handlers for 46 # file://, http://, https://, ftp://, sftp://, and scp://. Port numbers 47 # are not handled correctly in sftp and scp URIs. 48 CONF_EXPORT_FILE="/var/db/confman/export.tgz" 49 CONF_EXPORT_URI="scp://${REPO_HOSTNAME}${CONF_EXPORT_FILE}" 50 51 # What group should be able to read confman files? 52 CONF_GROUP="staff" 53 44 54 # Enable or disable debugging 45 55 DEBUG="false" -
trunk/confman/confmanlib.sh
r117 r120 55 55 # Commits module $1 with message $2 56 56 function conf_commit { 57 local module =$157 local modules=$(echo $modules | tr ' ' ',') 58 58 local msg="$2" 59 svn commit -F "$msg" ${WORK_PATH}/$module 59 60 # $modules is in the form foo,bar,baz. This eval trick forces 61 # curly brace expansion. 62 svn commit -F "$msg" $(eval echo foo/{$modules}) 63 } 64 65 function conf_fetch { 66 local tmpfile=`mktemp -t confman` 67 local proto="${CONF_EXPORT_URI%:/*}" 68 local remote 69 70 case $proto in 71 sftp|scp) 72 remote="${CONF_EXPORT_URI#*://}" 73 remote="${remote/\//:/}" 74 scp $remote $tmpfile 75 ;; 76 http|https|ftp) 77 fetch -o $tmpfile $remote 78 ;; 79 file) 80 remote="${CONF_EXPORT_URI#*://}" 81 cp $remote $tmpfile 82 ;; 83 *) 84 echo "Unsupported Protocol in conf_fetch" >&2 85 return 1 86 ;; 87 esac 88 echo $tmpfile 89 return 0 60 90 } 61 91 … … 63 93 function conf_status { 64 94 svn status $* 95 } 96 97 # This exports a working copy of the repository to a tarball 98 function conf_export { 99 local tmpdir=`mktemp -d -t confman` 100 local tarball="$1" 101 svn checkout "${REPO_URI}" "${tmpdir}/conf" 102 tar -czf "$tarball" -C "$tmpdir" conf 103 rm -rf "$tmpdir" 65 104 } 66 105 … … 400 439 } 401 440 441 # Accepts log messages on stdin until EOF 442 function conf_logger { 443 cat | logger -t "$MYNAME[$$]: $USER" -s 444 } 445 402 446 # WARNING: If you refer to fd 2 in this code, this function will silently 403 447 # fail when called by trap. DO NOT ATTEMPT TO LOG TO fd 2 IN THIS FUNCTION! … … 405 449 # process, which is receiving its input from our fd 2. 406 450 function conf_cleanexit { 451 echo "Confman received a signal. Exiting cleanly." | conf_logger 407 452 echo "Abort, Abort! Patience is a virtue." >&4 408 453 echo "Please wait until I finish cleaning up after you." >&4 409 410 echo "Removing leftover temp files..." >&4411 find /tmp -maxdepth 1 -user `whoami` -name 'confman*' -exec rm -f {} \;412 454 413 455 # And in case we got an interrupt during a rollout, we still want the … … 415 457 chmod 700 ${WORK_PATH} 416 458 459 echo "Removing leftover temp files..." >&4 460 find /tmp -maxdepth 1 -user `whoami` -name 'confman*' -exec rm -rf {} \; 461 417 462 # And this clears any locks we may have created on our working copy: 418 463 echo "Undoing damage to your working copy..." >&4 419 svn cleanup ${WORK_PATH}464 [ -d "${WORK_PATH}" ] && svn cleanup ${WORK_PATH} 420 465 echo "All clean. Terminating." >&4 421 466
Note: See TracChangeset
for help on using the changeset viewer.
