Changeset 4
- Timestamp:
- 03/15/2006 22:31:33 (6 years ago)
- Location:
- mgmt
- Files:
-
- 2 edited
-
mgmt.conf (modified) (1 diff)
-
mgmtlib.sh (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mgmt/mgmt.conf
r2 r4 17 17 REPO_LOCAL="`hostname -s`" 18 18 19 # The directory from the ro to of the repository to tags:20 REPO_ TAGS="tags"19 # The directory from the root of the repository to our checkpoints: 20 REPO_CHECKPTS="checkpoints" 21 21 22 22 # Where to keep our "working copy" of the system: -
mgmt/mgmtlib.sh
r3 r4 16 16 svn checkout ${REPO_URI} ${WORK_PATH}/.. 17 17 else 18 svn update ${WORK_PATH}/${REPO_CORE} 19 svn update ${WORK_PATH}/${REPO_LOCAL} 18 svn update ${WORK_PATH} 20 19 fi 21 20 … … 33 32 fi 34 33 35 echo "Still no luck. I'm going to call c reate_host." >&236 conf_create_ host34 echo "Still no luck. I'm going to call conf_create_module." >&2 35 conf_create_module ${REPO_LOCAL} 37 36 } 38 37 39 38 # Assumes that we already have core setup in our work path. 40 function conf_create_host { 41 mkdir -p ${WORK_PATH}/${REPO_LOCAL}/{usr/local/,}etc 42 svn add ${WORK_PATH}/${REPO_LOCAL} 43 svn commit ${WORK_PATH}/${REPO_LOCAL} -m \ 39 function conf_create_module { 40 if [ -z $1 ] ; then return 1 ; fi 41 svn mkdir ${WORK_PATH}/$1 42 svn mkdir ${WORK_PATH}/${REPO_CHECKPTS}/$1 43 svn commit ${WORK_PATH}/${REPO_LOCAL} ${WORK_PATH}/${REPO_CHECKPTS} -m \ 44 44 "Created directory structure for ${REPO_LOCAL} --`whoami`" 45 45 } … … 48 48 function conf_commit { 49 49 CPWD=$PWD 50 if [ -z $1 ] ; then 51 echo "You forgot to specify a module." >&2 52 return 1 53 fi 50 54 cd ${WORK_PATH} 51 55 echo "Type your commit message (escape \\\"double-quotes\\\"):" … … 53 57 read MESSAGE 54 58 svn commit -m "${MESSAGE} --`whoami`" $* 55 rollout 59 for mod in $* ; do 60 rollout $mod 61 done 56 62 cd $CPWD 57 63 } 58 64 59 65 # Roll out the specified module, optionally at the specified checkpoint 60 # eg: rollout MODULE [checkpoint] 61 function rollout { 62 : 66 # eg: conf_rollout MODULE [checkpoint] 67 function conf_rollout { 68 if [ -z $1 ] ; then 69 return 1 70 fi 71 module="$1" 72 if [ -z $2 ] ; then 73 moduledir="${WORK_PATH}/$module" 74 else 75 moduledir="${WORK_PATH}/checkpoints/${module}/${2}" 76 fi 77 for directory in `find $moduledir -type d | grep -v "\.svn"` ; do 78 livedir=`echo $directory | sed "s:$moduledir::"` 79 livedir="/home/ccowart/img${livedir}" 80 if [ ! -d $livedir ] ; then 81 mkdir -p $livedir 82 fi 83 done 84 for file in `find $moduledir -type f | grep -v "\.svn"` ; do 85 livefile=`echo "$file" | sed "s:$moduledir::"` 86 livefile="/home/ccowart/img${livefile}" 87 livedir=`dirname $livefile` 88 cmd="install -Sp -o root -g wheel -m 0444 $file $livefile" 89 echo $cmd 90 $cmd 91 done 63 92 } 64 93 65 # These functions take care of tagging your current working copy. 66 function tag_host { 67 tag_generic ${REPO_LOCAL} $1 94 # This function generates a checkpoint called NAME for the given MODULE. 95 # eg: conf_new_checkpoint MODULE NAME 96 function conf_new_checkpoint { 97 module=$1 98 checkpoint=$2 99 chkpath="${WORK_PATH}/${REPO_CHECKPTS}/${module}/${checkpoint}" 100 if [ -z $module -o -z $checkpoint ] ; then 101 return 1 102 fi 103 svn copy ${WORK_PATH}/${module} ${chkpath} 104 msg="Created a checkpoint, ${checkpoint} for ${REPO_LOCAL} --`whoami`" 105 svn commit ${WORK_PATH}/${REPO_CHECKPTS} -m "$msg" 68 106 } 69 107 70 function tag_core { 71 tag_generic ${REPO_CORE} $1 108 # This function will remove the checkpoint NAME from MODULE. 109 # eg: conf_rm_checkpoint MODULE NAME 110 function conf_rm_checkpoint { 111 module=$1 112 checkpoint=$2 113 chkpath="${WORK_PATH}/${REPO_CHECKPTS}/${module}/${checkpoint}" 114 if [ -z $module -o -z $checkpoint ] ; then 115 return 1 116 fi 117 svn rm ${chkpath} 118 msg="Removed the checkpoint ${checkpoint} from ${REPO_LOCAL} --`whoami`" 119 svn commit ${WORK_PATH}/${REPO_CHECKPTS} -m "$msg" 72 120 } 73 121 74 function tag_generic { 75 if [ -z $2 ] ; then 76 echo "You forgot to specify a name for your tag!" >&2 77 return 1 122 # This function will restore the state of your module's working copy to the 123 # named checkpoint. eg: conf_rollback MODULE NAME 124 function conf_rollback { 125 module=$1 126 checkpoint=$2 127 modpath="${WORK_PATH}/${module}" 128 chkpath="${WORK_PATH}/${REPO_CHECKPTS}/${module}/${checkpoint}" 129 if [ -z $module -o -z $checkpoint ] ; then 130 return 1 78 131 fi 79 if [ -d ${WORK_PATH}/${REPO_TAGS}/${1}-${2} ] ; then 80 svn rm ${WORK_PATH}/${REPO_TAGS}/${1}-${2} 81 fi 82 svn copy ${WORK_PATH}/${1} ${WORK_PATH}/${REPO_TAGS}/${1}-${2} 83 echo "Don't forget to commit!" 132 svn rm ${WORK_PATH}/${module} 133 svn update ${WORK_PATH}/${module} 134 svn commit -m "Removing ${module} for rollback ==`whoami`" $modpath 135 svn copy $chkpath $modpath 136 msg="Rolled ${module} back to checkpoint ${checkpoint}" 137 echo $msg | conf_commit $module 84 138 } 85 139 86 140 87 88
Note: See TracChangeset
for help on using the changeset viewer.
