aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/jail-commit
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 14:29:54 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-11 14:29:54 +0000
commitf9a8dfcd51e481a49355d94a3e74f2762519378f (patch)
tree948f0382081bd2eb8b1b5458a9661b67a090e795 /trunk/src/jail-commit
parentfef31cbc9988ead081aaec587222b44ed524b6fd (diff)
downloadsimplepkg-f9a8dfcd51e481a49355d94a3e74f2762519378f.tar.gz
simplepkg-f9a8dfcd51e481a49355d94a3e74f2762519378f.tar.bz2
changed repository layout to trunk/, tags/ and branches/ scheme
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@181 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src/jail-commit')
-rwxr-xr-xtrunk/src/jail-commit93
1 files changed, 93 insertions, 0 deletions
diff --git a/trunk/src/jail-commit b/trunk/src/jail-commit
new file mode 100755
index 0000000..8de547c
--- /dev/null
+++ b/trunk/src/jail-commit
@@ -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
+ fi
+ perms="`numeric_perm $1/$file`"
+ owner="`get_owner $1/$file`"
+ group="`get_group $1/$file`"
+ echo "$file;$owner;$group;$perms" >> $TEMPLATE_BASE.perms
+ 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 -u $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 -u main
+ template_merge /
+ template_svn_commit $TEMPLATE_BASE
+ fi
+fi
+