diff options
-rw-r--r-- | trunk/lib/common.sh | 1 | ||||
-rwxr-xr-x | trunk/src/jail-commit | 72 | ||||
-rwxr-xr-x | trunk/src/jail-update | 8 |
3 files changed, 47 insertions, 34 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 28ee8ea..38e9468 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -431,6 +431,7 @@ function copy_template_files { echo "$BASENAME: copying template files..." if [ -d "$TEMPLATE_BASE.d" ]; then if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then + svn update rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/ else rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/ 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 diff --git a/trunk/src/jail-update b/trunk/src/jail-update index 09d1555..471591b 100755 --- a/trunk/src/jail-update +++ b/trunk/src/jail-update @@ -50,14 +50,6 @@ if [ "$?" != "0" ]; then exit 1 fi -if [ -d "$TEMPLATE_BASE.d" ]; then - true -fi - -if [ -s "$TEMPLATE_BASE.perms" ]; then - -fi - copy_template_files $1 set_jail_perms $1 |