Changeset 123
- Timestamp:
- 12/04/2006 20:38:36 (5 years ago)
- Location:
- trunk/confman
- Files:
-
- 6 edited
-
confman (modified) (4 diffs)
-
confman.conf (modified) (2 diffs)
-
confmandoc.sh (modified) (3 diffs)
-
confmanlib.sh (modified) (9 diffs)
-
confsync.sh (modified) (2 diffs)
-
export.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/confman/confman
r122 r123 96 96 conf_assemble_sing $file || return $? 97 97 done 98 conf_recordAction commit 99 conf_markclean 98 100 echo "Commit operation finished successfully" >&2 99 101 rm -f $msg 100 101 102 else 102 103 print_usage 1 … … 120 121 121 122 echo "Installation operation started." >&2 123 conf_commit "$LAYERS" $msg || return $? 122 124 for layer in $LAYERS ; do 123 $DEBUG && echo "Layer: $layer" >&4 124 conf_commit $layer $msg || return $? 125 conf_install $layer $* 125 conf_install $layer "$@" 126 126 done 127 127 for file in $SINGULARITIES ; do 128 128 conf_assemble_sing $file || conf_cleanexit 129 129 done 130 conf_recordAction install 131 if ! conf_isclean ; then 132 echo "WARNING: Recent 'install' operations prevented a 'sync'" >&2 133 echo "Running a 'commit' is highly recommended." >&2 134 fi 130 135 echo "Installation operation succeeded." >&2 131 136 fi … … 576 581 577 582 conf_rmattr "$attr" "$@" 583 } 584 585 function state { 586 if conf_isclean ; then 587 echo "This host is clean." 588 else 589 echo "This host may be dirty. Consider running a 'commit' operation" 590 fi 578 591 } 579 592 … … 598 611 help ) print_help "$@" ; exit 0 ;; 599 612 setup|se* ) setup "$@" ;; 600 status|st* ) status "$@" ;; 613 status ) status "$@" ;; 614 state ) state ;; 601 615 create|cr* ) create "$@" ;; 602 616 update|u* ) update "$@" ;; -
trunk/confman/confman.conf
r121 r123 31 31 SINGULARITIES="/etc/rc.conf" 32 32 33 # A place where confman can keep state 34 REPO_DB="/var/db/confman" 35 33 36 # The warning message for all files 34 37 CONF_WARNING="WARNING! This file is under confman revision control." … … 60 63 #LIVE_ROOT="/home/ccowart/img" 61 64 62 -
trunk/confman/confmandoc.sh
r122 r123 28 28 $MYNAME import module livefile 29 29 $MYNAME install workingfile [ workingfile ... ] 30 $MYNAME status [ working_copy ] 31 $MYNAME state 30 32 $MYNAME ls [ workingfile | workingdirectory ] 31 33 $MYNAME lsattr [ workingfile | workingdirectory ] … … 145 147 EOF 146 148 ;; 147 st *)149 status ) 148 150 cat <<EOF 149 151 $MYNAME provides a command-line interface to Rescomp's server … … 154 156 155 157 Look at the status entries for the file or directory specified by working_copy. 158 EOF 159 ;; 160 state ) 161 cat <<EOF 162 $MYNAME provides a command-line interface to Rescomp's server 163 configuration management system. 164 165 Usage: 166 $MYNAME state 167 168 This command indicates whether the system is "dirty" or "clean." 169 170 A dirty system is one that has missed an automated "sync" operation in order 171 to preserve changes made by installation operations occuring between the 172 repository's export and the system's call to "sync." 173 174 Dirty systems may have out-of-date configuration files. Subsquent sync or 175 commit operations can bring the sytem up-to-date. 156 176 EOF 157 177 ;; -
trunk/confman/confmanlib.sh
r122 r123 10 10 11 11 REPO_URI="${REPO_PROTOCOL}${REPO_HOSTNAME}${REPO_PATH}" 12 REPO_ACTION="${REPO_DB}/last_action" 13 REPO_SYNC_STATE="${REPO_DB}/state" 12 14 13 15 # Checks out the conf tree if we don't already have it. Updates it if we do. … … 55 57 # Commits module $1 with message $2 56 58 function conf_commit { 57 local modules=$(echo $ modules| tr ' ' ',')59 local modules=$(echo $1 | tr ' ' ',') 58 60 local msg="$2" 59 61 60 62 # $modules is in the form foo,bar,baz. This eval trick forces 61 63 # curly brace expansion. 62 svn commit -F "$msg" $(eval echo foo/{$modules}) 64 if echo "$modules" | grep ',' > /dev/null ; then 65 svn commit -F "$msg" $(eval echo ${WORK_PATH}/{$modules}) 66 else 67 svn commit -F "$msg" ${WORK_PATH}/$modules 68 fi 63 69 } 64 70 … … 72 78 remote="${CONF_EXPORT_URI#*://}" 73 79 remote="${remote/\//:/}" 74 scp $remote $tmpfile80 scp -p $remote $tmpfile 75 81 ;; 76 82 http|https|ftp) … … 79 85 file) 80 86 remote="${CONF_EXPORT_URI#*://}" 81 cp $remote $tmpfile87 cp -p $remote $tmpfile 82 88 ;; 83 89 *) … … 97 103 # This exports a working copy of the repository to a tarball 98 104 function conf_export { 99 local tmpdir=`mktemp -d -t confman`100 105 local tarball="$1" 101 svn checkout "${REPO_URI}" "${tmpdir}/conf" 102 tar -czf "$tarball" -C "$tmpdir" conf 103 rm -rf "$tmpdir" 106 conf_checkout_tree 107 tar -czf "$tarball" -C "${WORK_PATH}" . 104 108 } 105 109 … … 159 163 # See if it even exists 160 164 file="${moduledir}${livefile}" 161 echo Install: $file162 165 if [ ! -e "$file" ] && [ -z "$1" ] ; then 163 166 return 0 … … 240 243 local checkpoint=$2 241 244 local chkpath="${WORK_PATH}/${REPO_CHECKPTS}/${module}/${checkpoint}" 242 local revision=` svn info ${WORK_PATH}|awk '/Last Changed Rev:/ {print $4}'`245 local revision=`conf_revision` 243 246 echo $revision > $chkpath 244 247 svn add $chkpath … … 470 473 } 471 474 475 function conf_markclean { 476 echo clean > $REPO_SYNC_STATE 477 } 478 479 function conf_markdirty { 480 echo dirty > $REPO_SYNC_STATE 481 } 482 483 function conf_isclean { 484 local state=`cat $REPO_SYNC_STATE` 485 case $state in 486 clean) return 0 ;; 487 dirty) return 1 ;; 488 *) echo "Invalid state. Reporting dirty." >&2 ; return 1 ;; 489 esac 490 } 491 492 # Returns the current revision number of the repository on stdout 493 function conf_revision { 494 svn info ${WORK_PATH} | awk '/Last Changed Rev:/ {print $4}' 495 } 496 497 # Returns the revision of the last commit or install operation on stdout 498 function conf_sysrev { 499 cut -d ':' -f 2 $REPO_ACTION 500 } 501 502 # Returns the last action of the repository on stdout 503 function conf_lastact { 504 cut -d ':' -f 1 $REPO_ACTION 505 } 506 507 # Records the specified action 508 function conf_recordAction { 509 local action="$1" 510 local revision=`conf_revision` 511 echo "${action}:${revision}" > $REPO_ACTION 512 } 513 472 514 # WARNING: If you refer to fd 2 in this code, this function will silently 473 515 # fail when called by trap. DO NOT ATTEMPT TO LOG TO fd 2 IN THIS FUNCTION! … … 484 526 485 527 echo "Removing leftover temp files..." >&4 486 find /tmp -maxdepth 1 -user `whoami` -name 'confman*'-exec rm -rf {} \;528 find /tmp/confman* -maxdepth 0 -user `whoami` -exec rm -rf {} \; 487 529 488 530 # And this clears any locks we may have created on our working copy: -
trunk/confman/confsync.sh
r121 r123 26 26 tarball=$(conf_fetch) 27 27 tmpdir=$(mktemp -d -t confman) 28 28 29 tar -xzf $tarball -C $tmpdir 29 30 rm -rf $tarball 30 WORK_PATH="$tmpdir/conf" 31 WORK_PATH="$tmpdir" 32 33 tar_revision=`conf_revision` 34 sys_revision=`conf_sysrev` 35 last_action=$(conf_lastact) 36 37 if [ "x$last_action" = "xinstall" ] && [ $tar_revision -lt $sys_revision ] 38 then 39 echo "Error: File system may be dirty." \ 40 "A commit operation is recommended." >&2 41 echo "Error: $tarball is out of date. Exiting without making changes." >&2 42 conf_markdirty 43 rm -rf $tmpdir 44 exit 1 45 fi 46 47 if [ $tar_revision -lt $sys_revision ] ; then 48 exit 0 49 fi 50 51 exit 31 52 32 53 echo "Sync operation started" >&2 … … 39 60 conf_assemble_sing $file || conf_cleanexit 40 61 done 62 conf_markclean 63 conf_recordAction sync 41 64 echo "Sync operation finished successfully" >&2 42 65 43 66 rm -rf $tmpdir 44 67 45 -
trunk/confman/export.sh
r121 r123 26 26 27 27 REPO_URI="file://$REPO_PATH" 28 backup=`mktemp -t confman` 28 29 29 conf_export $CONF_EXPORT_FILE 30 echo "Backing up $CONF_EXPORT_FILE" 31 cp $CONF_EXPORT_FILE $backup 30 32 33 echo "Beginning export operation." >&2 34 if ! conf_export $CONF_EXPORT_FILE ; then 35 echo "The export failed. Restoring $CONF_EXPORT_FILE from backup." >&2 36 mv $backup $CONF_EXPORT_FILE 37 echo "Exiting." >&2 38 exit 1 39 fi 40 echo "Export complete." >&2 41 42 echo "Removing $backup" 43 rm $backup 44
Note: See TracChangeset
for help on using the changeset viewer.
