]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
some changes on jail-commit, small changes in common.sh and jail-update
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 21 Mar 2007 01:46:54 +0000 (01:46 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 21 Mar 2007 01:46:54 +0000 (01:46 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@208 04377dda-e619-0410-9926-eae83683ac58

trunk/lib/common.sh
trunk/src/jail-commit
trunk/src/jail-update

index 28ee8ea34289ffcda644001cb01ade5de7855f27..38e9468b4f05131b79545dce618763eb585f25e1 100644 (file)
@@ -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/
index b318f94c5279d8c4841679e6ad864340e5658eaa..59fccadc5151405ea1b22cced4228746ba38f6fa 100755 (executable)
@@ -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
 
index 09d15558c3154da55621265dbccebead96e0d96c..471591b51bd629d2bcfed9fed20bdbca6efccb8c 100755 (executable)
@@ -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