diff options
Diffstat (limited to 'trunk/src/jail-commit')
-rwxr-xr-x | trunk/src/jail-commit | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/trunk/src/jail-commit b/trunk/src/jail-commit index b318f94..59fccad 100755 --- a/trunk/src/jail-commit +++ b/trunk/src/jail-commit @@ -25,6 +25,13 @@ else exit 1 fi +function usage { + + echo $BASENAME: commit a jail configuration into a template + echo usage: $BASENAME [<jail-path> [template]] + +} + function template_merge { # copy differences between the jail @@ -57,40 +64,53 @@ function template_merge { function template_svn_commit { if use_svn; then - cd `basedir $TEMPLATE_BASE` - svn commit -m "changes for `date`" + cd `basedir $TEMPLATE_BASE` + svn commit -m "changes for `date`" fi } -# TODO: command line parsing: with no arguments, jail-commit -# does exactly what it does now, but we also need to add -# options to choose just one jail to commit; perhaps -# make this similar to jail-update command line behaviour. +function do_commit { + + # commit jail changes to a repository + # usage: do_commit <jailpath> [template] + + local jailpath template + + jailpath="$1" + jail="`basename $jailpath`" + + if [ ! -z "$2" ]; then + template="$2" + else + template="$jail" + fi -if [ -f $JAIL_LIST ]; then - for jailpath in `cat $JAIL_LIST`; do - jail="`basename $jailpath`" - search_template $jail --update - if [ "$?" == "0" ]; then + search_template $template --update + if [ "$?" == "0" ]; then + if [ "$jailpath" == "/" ]; then + echo updating main installation... + else echo updating $jailpath... - if [ -d "$TEMPLATE_BASE.d" ] || [ -a "$TEMPLATE_BASE.template" ]; then - templatepkg -u $jail $jailpath - template_merge $jailpath - template_svn_commit $TEMPLATE_BASE - fi fi - done -fi + if [ -d "$TEMPLATE_BASE.d" ] || [ -a "$TEMPLATE_BASE.template" ]; then + templatepkg -u $jail $jailpath + template_merge $jailpath + template_svn_commit $TEMPLATE_BASE + fi + fi + +} -# main jail -search_template main --update -if [ "$?" == "0" ]; then - if [ -a "$TEMPLATE_BASE.template" ] || [ -a "$TEMPLATE_BASE.template" ]; then - echo updating main installation... - templatepkg -u main - template_merge / - template_svn_commit $TEMPLATE_BASE +if [ ! -z "$1" ]; then + do_commit $1 $2 +else + if [ -f $JAIL_LIST ]; then + for jailpath in `cat $JAIL_LIST`; do + do_commit $jailpath + done fi + # main jail + do_commit / main fi |