]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
lots of changes:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Fri, 9 Feb 2007 16:44:20 +0000 (16:44 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Fri, 9 Feb 2007 16:44:20 +0000 (16:44 +0000)
- jail-update renamed to jail-commit
- mkjail, jail-commit and templatepkg with svn support
- templates now has permission tracking
- etc

git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@164 04377dda-e619-0410-9926-eae83683ac58

79 files changed:
conf/simplepkg.conf.new
doc/CHANGELOG
lib/common.sh
simplepkg.SlackBuild
src/jail-commit [new file with mode: 0755]
src/jail-update [deleted file]
src/mkjail
templates/openoffice/openoffice.d/etc/profile.d/lang.csh [moved from templates/openoffice.d/etc/profile.d/lang.csh with 100% similarity]
templates/openoffice/openoffice.d/etc/profile.d/lang.sh [moved from templates/openoffice.d/etc/profile.d/lang.sh with 100% similarity]
templates/openoffice/openoffice.d/opt/OpenOffice.org [moved from templates/openoffice.d/opt/OpenOffice.org with 100% similarity]
templates/openoffice/openoffice.s/post-install.sh [moved from templates/openoffice.s/post-install.sh with 100% similarity]
templates/openoffice/openoffice.template [moved from templates/openoffice.template with 100% similarity]
templates/slackware/slackware.template [moved from templates/slackware.template with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/apache/httpd.conf [moved from templates/vserver-legacy.d/etc/apache/httpd.conf with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/apache/php.ini [moved from templates/vserver-legacy.d/etc/apache/php.ini with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/apache/vhosts [moved from templates/vserver-legacy.d/etc/apache/vhosts with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/hosts [moved from templates/vserver-legacy.d/etc/hosts with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/logrotate.d/apache [moved from templates/vserver-legacy.d/etc/logrotate.d/apache with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/profile [moved from templates/vserver-legacy.d/etc/profile with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.0 [moved from templates/vserver-legacy.d/etc/rc.d/rc.0 with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.4 [moved from templates/vserver-legacy.d/etc/rc.d/rc.4 with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.6 [moved from templates/vserver-legacy.d/etc/rc.d/rc.6 with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.K [moved from templates/vserver-legacy.d/etc/rc.d/rc.K with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.M [moved from templates/vserver-legacy.d/etc/rc.d/rc.M with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.S [moved from templates/vserver-legacy.d/etc/rc.d/rc.S with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.httpd [moved from templates/vserver-legacy.d/etc/rc.d/rc.httpd with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.inet2 [moved from templates/vserver-legacy.d/etc/rc.d/rc.inet2 with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.inetd [moved from templates/vserver-legacy.d/etc/rc.d/rc.inetd with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.ip_forward [moved from templates/vserver-legacy.d/etc/rc.d/rc.ip_forward with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.local [moved from templates/vserver-legacy.d/etc/rc.d/rc.local with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.mysqld [moved from templates/vserver-legacy.d/etc/rc.d/rc.mysqld with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.postfix [moved from templates/vserver-legacy.d/etc/rc.d/rc.postfix with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.sendmail [moved from templates/vserver-legacy.d/etc/rc.d/rc.sendmail with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.serial [moved from templates/vserver-legacy.d/etc/rc.d/rc.serial with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.sshd [moved from templates/vserver-legacy.d/etc/rc.d/rc.sshd with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.syslog [moved from templates/vserver-legacy.d/etc/rc.d/rc.syslog with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rc.d/rc.sysvinit [moved from templates/vserver-legacy.d/etc/rc.d/rc.sysvinit with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/rssh.conf [moved from templates/vserver-legacy.d/etc/rssh.conf with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/etc/ssh/sshd_config [moved from templates/vserver-legacy.d/etc/ssh/sshd_config with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/var/www/htdocs/missing.html [moved from templates/vserver-legacy.d/var/www/htdocs/missing.html with 100% similarity]
templates/vserver-legacy/vserver-legacy.d/var/www/missing.html [moved from templates/vserver-legacy.d/var/www/missing.html with 100% similarity]
templates/vserver-legacy/vserver-legacy.s/GPG-KEY [moved from templates/vserver-legacy.s/GPG-KEY with 100% similarity]
templates/vserver-legacy/vserver-legacy.s/devices.tar.gz [moved from templates/vserver-legacy.s/devices.tar.gz with 100% similarity]
templates/vserver-legacy/vserver-legacy.s/skel.conf [moved from templates/vserver-legacy.s/skel.conf with 100% similarity]
templates/vserver-legacy/vserver-legacy.s/vserver-legacy.sh [moved from templates/vserver-legacy.s/vserver-legacy.sh with 100% similarity]
templates/vserver-legacy/vserver-legacy.template [moved from templates/vserver-legacy.template with 100% similarity]
templates/vserver/vserver.d/etc/apache/httpd.conf [moved from templates/vserver.d/etc/apache/httpd.conf with 100% similarity]
templates/vserver/vserver.d/etc/apache/php.ini [moved from templates/vserver.d/etc/apache/php.ini with 100% similarity]
templates/vserver/vserver.d/etc/apache/vhosts [moved from templates/vserver.d/etc/apache/vhosts with 100% similarity]
templates/vserver/vserver.d/etc/hosts [moved from templates/vserver.d/etc/hosts with 100% similarity]
templates/vserver/vserver.d/etc/logrotate.d/apache [moved from templates/vserver.d/etc/logrotate.d/apache with 100% similarity]
templates/vserver/vserver.d/etc/profile [moved from templates/vserver.d/etc/profile with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc [moved from templates/vserver.d/etc/rc.d/rc with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.0 [moved from templates/vserver.d/etc/rc.d/rc.0 with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.4 [moved from templates/vserver.d/etc/rc.d/rc.4 with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.6 [moved from templates/vserver.d/etc/rc.d/rc.6 with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.K [moved from templates/vserver.d/etc/rc.d/rc.K with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.M [moved from templates/vserver.d/etc/rc.d/rc.M with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.S [moved from templates/vserver.d/etc/rc.d/rc.S with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.httpd [moved from templates/vserver.d/etc/rc.d/rc.httpd with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.inet2 [moved from templates/vserver.d/etc/rc.d/rc.inet2 with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.inetd [moved from templates/vserver.d/etc/rc.d/rc.inetd with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.ip_forward [moved from templates/vserver.d/etc/rc.d/rc.ip_forward with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.local [moved from templates/vserver.d/etc/rc.d/rc.local with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.mysqld [moved from templates/vserver.d/etc/rc.d/rc.mysqld with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.postfix [moved from templates/vserver.d/etc/rc.d/rc.postfix with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.sendmail [moved from templates/vserver.d/etc/rc.d/rc.sendmail with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.serial [moved from templates/vserver.d/etc/rc.d/rc.serial with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.sshd [moved from templates/vserver.d/etc/rc.d/rc.sshd with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.syslog [moved from templates/vserver.d/etc/rc.d/rc.syslog with 100% similarity]
templates/vserver/vserver.d/etc/rc.d/rc.sysvinit [moved from templates/vserver.d/etc/rc.d/rc.sysvinit with 100% similarity]
templates/vserver/vserver.d/etc/rssh.conf [moved from templates/vserver.d/etc/rssh.conf with 100% similarity]
templates/vserver/vserver.d/etc/ssh/sshd_config [moved from templates/vserver.d/etc/ssh/sshd_config with 100% similarity]
templates/vserver/vserver.d/var/www/htdocs/missing.html [moved from templates/vserver.d/var/www/htdocs/missing.html with 100% similarity]
templates/vserver/vserver.d/var/www/missing.html [moved from templates/vserver.d/var/www/missing.html with 100% similarity]
templates/vserver/vserver.s/GPG-KEY [moved from templates/vserver.s/GPG-KEY with 100% similarity]
templates/vserver/vserver.s/devices.tar.gz [moved from templates/vserver.s/devices.tar.gz with 100% similarity]
templates/vserver/vserver.s/vserver.sh [moved from templates/vserver.s/vserver.sh with 100% similarity]
templates/vserver/vserver.template [moved from templates/vserver.template with 100% similarity]

index f590feb391ce465b42da1714ad9e8d6a2e0c256a..28af9a73ff80a00402b4200b07405826daaeb4ca 100644 (file)
@@ -94,6 +94,22 @@ CONSIDER_ALL_PACKAGES_AS_PATCHES="0"
 # stored in the same tree.
 STORE_ROOT_PATCHES_ON_PATCHES_DIR="0"
 
+# Set to yes if your templates will be placed in a subversion repository
+# This just work if TEMPLATE_STORAGE_STYLE is set to own-folder (default)
+TEMPLATES_UNDER_SVN="no"
+
 # Where your templates will be located
+# Dont change it except you know what you're doing.
 TEMPLATE_FOLDER="/etc/simplepkg/templates"
 
+# This variable controls in which folder / subfolder your templates will
+# be stored. Possible values are:
+#
+# - simplepkg-folder: templates are stored at /etc/simplepkg
+# - templates-folder: templates are stored at /etc/simplepkg/templates
+# - own-folder: each template stored at its own folder
+#               at /etc/simplepkg/templates/template-name
+#
+# This variable has backwards purposes only, so dont change it.
+TEMPLATE_STORAGE_STYLE="own-folder"
+
index c64e5fc9ee7a4556fadc1c3c45404f7ddb76d754..8797935b9f367aba09e3c5b7d7fca4e741ed927c 100644 (file)
@@ -12,6 +12,7 @@ simplepkg changelog
                - /etc/simplepkg/template_name.template
                - /etc/simplepkg/templates/template_name.template
                - /etc/simplepkg/templates/template_name/template_name.template
+            jail-update: renamed to jail-commit
 
 0.4.9pre18-23: simplaret:
                - enhanced http retrieval: curl support
index 5b8246966e39996de7f5331b579a8af65a05bd59..fc62611a2406c1c662ee4d1f0b7a21a75384660b 100644 (file)
@@ -199,9 +199,7 @@ function eval_config {
     HTTP_TOOL="`eval_parameter HTTP_TOOL curl`"
     CONNECT_TIMEOUT="`eval_parameter CONNECT_TIMEOUT 0`"
     TEMPLATE_FOLDER="`eval_parameter TEMPLATE_BASE /etc/simplepkg/templates`"
-
-    # TODO: also add this stuff in simplepkg.conf.new
-    # TEMPLATE_STORAGE_STYLE
+    TEMPLATE_STORAGE_STYLE="`eval_parameter TEMPLATE_STORAGE_STYLE own_folder`"
 
     SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`"
     SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`"
@@ -212,6 +210,7 @@ function eval_config {
     WARNING="`eval_boolean_parameter WARNING 0`"
     SIGNATURE_CHECKING="`eval_boolean_parameter SIGNATURE_CHECKING 0`"
     DEPENDENCY_CHECKING="`eval_boolean_parameter DEPENDENCY_CHECKING 1`"
+    TEMPLATES_UNDER_SVN="`eval_boolean_parameter TEMPLATES_UNDER_SVN 0`"
 
     # Enabling this option (i.e, setting to "1" or "yes"), simplaret will
     # donwload even # already applied patches, a good option when you plan
@@ -283,6 +282,12 @@ function eval_config {
     echo "$SIMPLARET not found, please install it before run $0"
   fi
 
+  if [ "$TEMPLATE_STORAGE_STYLE" != "simplepkg-folder" ] && \
+     [ "$TEMPLATE_STORAGE_STYLE" != "templates-folder" ] && \
+     [ "$TEMPLATE_STORAGE_STYLE" != "own-folder" ]; then
+    TEMPLATE_STORAGE_STYLE="own-folder"
+  fi
+
 }
 
 function default_version {
@@ -329,7 +334,7 @@ function search_default_template {
 function search_template {
 
   # determine the template to be used
-  # usage: <search-template> <template-name> [--new]
+  # usage: <search-template> <template-name> [--new | --update]
 
   #
   # templates can be stored either on
@@ -348,9 +353,16 @@ function search_template {
   else
     if [ "$2" == "--new" ]; then
       # we need to return the path for a new template
-      # TODO: set a path for the new template
-      # TODO: TEMPLATE_STORAGE_STYLE
-      true
+      if [ "$TEMPLATE_STORAGE_STYLE" == "simplepkg-folder" ]; then
+        TEMPLATE_BASE="$BASE_CONF/$1"
+      elif [ "$TEMPLATE_STORAGE_STYLE" == "templates-folder" ]; then
+        TEMPLATE_BASE="$BASE_CONF/templates/$1"
+      else
+        TEMPLATE_BASE="$BASE_CONF/templates/$1/$1"
+        mkdir -p $BASE_CONF/templates/$1
+      fi
+    elif [ "$2" == "--update" ]
+      return 1
     else
       echo $BASENAME: template $1 not found
       search_default_template
@@ -359,3 +371,41 @@ function search_template {
 
 }
 
+function numeric_perm {
+
+  # get the numeric permission of a file
+  # usage: numeric_perm <file-name>
+
+  # just a bit of forbidden secrets
+
+  if [ -a "$file" ]; then
+    ls -ln $file | awk '{ print $1 }' | \
+    sed -e 's/^.//' -e 's/r/4/g' -e 's/w/2/g' -e 's/x/1/g'
+        -e 's/-/0/g' -e 's/\(.\)\(.\)\(.\)/\1+\2+\3/g' | \
+    fold -w5 | bc -l | xargs | sed -e 's/ //g'
+  fi
+
+}
+
+function get_owner {
+
+  # get the numeric owner for a file
+  # usage: get_owner <file>
+
+  if [ -a "$1" ]; then
+    ls -ln $1 | awk '{ print $3 }'
+  fi
+
+}
+
+function get_group {
+
+  # get the numeric group for a file
+  # usage: get_group <file>
+
+  if [ -a "$1" ]; then
+    ls -ln $1 | awk '{ print $4 }'
+  fi
+
+}
+
index c3a392b94e57f65c1dccb86b5f4b7d18c2a18a7f..da4c4966b76f9e0a0ef5a19d49ba3f371b7a7ff9 100755 (executable)
@@ -10,9 +10,9 @@ VERSION="0.4.9pre24"
 ARCH="noarch"
 LIBEXEC="/usr/libexec/$PACKAGE"
 BINDIR="/usr/bin"
-BINARY_LIST="simplaret repos"
+BINARY_LIST="simplaret repos lspkg"
 SBINDIR="/usr/sbin"
-SBINARY_LIST="mkjail templatepkg jail-update jail-upgrade lspkg metapkg rebuildpkg createpkg"
+SBINARY_LIST="mkjail templatepkg jail-update jail-commit metapkg rebuildpkg createpkg"
 LIB_LIST="common.sh"
 DOC_DIR="/usr/doc"
 DOC_LIST="COPYING TODO CHANGELOG README README.pt_BR README.simplaret README.simplaret.pt_BR"
@@ -49,7 +49,7 @@ done
 
 # especifico do simplepkg
 mkdir -p $PACK_DIR/etc/$PACKAGE/
-rsync -av --exclude=.svn templates/* $PACK_DIR/etc/$PACKAGE/
+rsync -av --exclude=.svn templates/* $PACK_DIR/etc/$PACKAGE/templates/
 chmod +x $PACK_DIR/etc/$PACKAGE/vserver.s/*.sh
 chmod +x $PACK_DIR/etc/$PACKAGE/vserver-legacy.s/*.sh
 cp conf/simplepkg.conf.new $PACK_DIR/etc/$PACKAGE
diff --git a/src/jail-commit b/src/jail-commit
new file mode 100755 (executable)
index 0000000..b48a0f9
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/bash
+#
+# jail-update: update config files from a jail to a template
+# feedback: rhatto@riseup.net | gpl
+#
+#  Jail-update is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU General Public License as published by the Free Software
+#  Foundation; either version 2 of the License, or any later version.
+#
+#  Jail-update is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License along with
+#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+#  Place - Suite 330, Boston, MA 02111-1307, USA
+#
+
+COMMON="/usr/libexec/simplepkg/common.sh"
+
+if [ -f "$COMMON" ]; then
+  source $COMMON
+else
+  echo "error: file $COMMON found, check your `basename $0` installation"
+  exit 1
+fi
+
+function template_merge {
+
+  # copy differences between the jail
+  # and the template in the template folder
+
+  # usage: template_merge <jail-path>
+
+  if [ -z "$1" ] || [ ! -d "$TEMPLATE_BASE.d" ]; then
+    return 1
+  fi
+
+  rm -f $TEMPLATE_BASE.perms
+  touch $TEMPLATE_BASE.perms
+  cd $TEMPLATE_BASE.d
+
+  for file in `find`; do
+    if [[ -f "$file" && -f "$1/$file" ]]; then
+      if ! diff $file $1/$file; then
+        echo updating $file
+        cp -af $1/$file $file
+        perms="`numeric_perm $1/$file`"
+        owner="`get_owner $1/$file`"
+        group="`get_group $1/$file`"
+        echo "$file;$owner;$group;$perms" >> $TEMPLATE_BASE.perms
+      fi
+    fi
+  done
+
+}
+
+function template_svn_commit {
+
+  if [ "$TEMPLATES_UNDER_SVN" == "1" ] && \
+     [ "$TEMPLATE_STORAGE_STYLE" == "own-folder" ]; then
+      cd `basedir $TEMPLATE_BASE`
+      svn commit -m "changes for `date`"
+  fi
+
+}
+
+if [ -f $JAIL_LIST ]; then
+  for jailpath in `cat $JAIL_LIST`; do
+    jail="`basename $jailpath`"
+    search_template $jail --update
+    if [ "$?" == "0" ]; then
+      echo updating $jailpath...
+      if [ -d "$TEMPLATE_BASE.d" ] || [ -a "$TEMPLATE_BASE.template" ]; then
+        templatepkg -a $jail $jailpath
+        template_merge $jailpath
+        template_svn_commit $TEMPLATE_BASE
+      fi
+    fi
+  done
+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 -a main
+    template_merge /
+    template_svn_commit $TEMPLATE_BASE
+  fi
+fi
+
diff --git a/src/jail-update b/src/jail-update
deleted file mode 100755 (executable)
index 07d1d1b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-#
-# jail-update: update config files from a jail to a template
-# feedback: rhatto@riseup.net | gpl
-#
-#  Jail-update is free software; you can redistribute it and/or modify it under the
-#  terms of the GNU General Public License as published by the Free Software
-#  Foundation; either version 2 of the License, or any later version.
-#
-#  Jail-update is distributed in the hope that it will be useful, but WITHOUT ANY
-#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License along with
-#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-#  Place - Suite 330, Boston, MA 02111-1307, USA
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-
-if [ -f "$COMMON" ]; then
-  source $COMMON
-else
-  echo "error: file $COMMON found, check your `basename $0` installation"
-  exit 1
-fi
-
-# TODO: get the correct template folder
-
-if [ -f $JAIL_LIST ]; then
-  for jailpath in `cat $JAIL_LIST`; do
-    jail="`basename $jailpath`"
-    echo updating $jailpath...
-    if [ -d "$BASE_CONF/$jail.d" ] || [ -a "$BASE_CONF/$jail.template" ]; then
-      templatepkg -a $jail $jailpath
-      cd $BASE_CONF/$jail.d
-      for file in `find`; do
-        if [[ -f "$file" && -f "$jailpath/$file" ]]; then
-           if ! diff $file $jailpath/$file; then
-             echo updating $file
-             cp -f $jailpath/$file $file
-           fi
-        fi
-      done
-    fi
-  done
-fi
-
-# main jail
-if [ -a "$BASE_CONF/main.template" ]; then
-  echo updating main installation...
-  templatepkg -a main
-fi
-if [ -d "$BASE_CONF/main.d" ]; then
-  cd $BASE_CONF/main.d
-  for file in `find`; do
-    if [[ -f "$file" && -f "/$file" ]]; then
-      if ! diff $file /$file; then
-        echo updating $file
-        cp -f /$file $file
-      fi
-    fi
-  done
-fi
index 0f9834da5027409aa02bcbd0d8e65fd5f4c343d0..0b6adb3840302cdb30651a38e8639026b46bdd09 100755 (executable)
 COMMON="/usr/libexec/simplepkg/common.sh"
 BASENAME="`basename $0`"
 
-function usage {
-  echo "usage: [ARCH=arch] [VERSION=version] [ROOT=/otherroot] $BASENAME <jail-name> [template]"
-  exit 1
-}
-
 if [ -f "$COMMON" ]; then
   source $COMMON
 else
@@ -32,11 +27,87 @@ else
   exit 1
 fi
 
+function usage {
+
+  echo "usage: [ARCH=arch] [VERSION=version] [ROOT=/otherroot] $BASENAME <jail-name> [template]"
+  exit 1
+
+}
+
+function copy_template_files {
+
+  # copy template files into jail
+  # usage: copy_template_files <jail-path>
+
+  if [ -d "$1" ]; then
+    echo "$BASENAME: copying template files..."
+    if [ -d "$TEMPLATE_BASE.d" ]; then 
+      if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then 
+        rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
+      else
+        rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
+      fi
+    fi
+  fi
+
+}
+
+function set_jail_perms {
+
+  # set template file permissions under a jail
+  # usage: set_jail_perms <jail-path>
+
+  if [ -s "$TEMPLATE_BASE.perms" ]; then
+    cat $TEMPLATE_BASE.perms | while read entry; do
+      file="`echo $entry | cut -d ";" -f 1`"
+      if [ -a "$TEMPLATE_BASE.d/$file" ] && [ -a "$1/$file" ]; then
+        owner="`echo entry | cut -d ";" -f 2`"
+        group="`echo entry | cut -d ";" -f 3`"
+        perms="`echo entry | cut -d ";" -f 4`"
+        chmod $perms $1/$file
+        chown $owner:$group $1/$file
+      fi
+    done
+  fi
+
+}
+
+function exec_post_install_scripts {
+
+  # exec post installation scripts
+  # usage: exec_post_install_script <jail-root> <jail-name>
+
+  if [ -z "$2" ]; then
+    return 1
+  fi
+
+  echo "$BASENAME: executing template scripts..."
+  if [ -d "$TEMPLATE_BASE.s" ]; then
+    for script in `ls $TEMPLATE_BASE.s/`; do
+      if [ -x "$TEMPLATE_BASE.s/$script" ]; then
+        exec $TEMPLATE_BASE.s/$script $1 $2
+      fi
+    done
+  fi
+
+}
+
+function jailist_update {
+
+  # update the jail list file
+  # usage: jailist_update <jail-path>
+
+  if ! grep -q "^$1" $JAIL_LIST; then
+    echo $1 >> $JAIL_LIST
+  fi
+
+}
+
 if [ -z "$1" ]; then
   usage
 else
   server="$1"
-  eval_config `basename $0` -u
+  eval_config $BASENAME -u
 fi
 
 if [ ! -z "$2" ]; then
@@ -64,22 +135,12 @@ else
 fi
 
 echo "$BASENAME: instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
-install_packages
 
-echo "$BASENAME: copying template files..."
-if [ -d "$TEMPLATE_BASE.d" ]; then 
-  rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
-fi
-
-echo "$BASENAME: executing template scripts..."
-if [ -d "$TEMPLATE.s" ]; then
-  for script in `ls $TEMPLATE.s/`; do
-    if [ -x "$TEMPLATE_BASE.s/$script" ]; then
-      exec $TEMPLATE_BASE.s/$script $JAIL_ROOT $server
-    fi
-  done
-fi
+install_packages
+copy_template_files $JAIL_ROOT/$server
+set_jail_perms $JAIL_ROOT/$server
+exec_post_install_scripts $JAIL_ROOT $server
+jailist_update $JAIL_ROOT/$server
 
-echo $JAIL_ROOT/$server >> $JAIL_LIST
 echo $BASENAME: done creating $server jail