aboutsummaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/templatepkg55
1 files changed, 44 insertions, 11 deletions
diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg
index e73e063..0c05fd9 100755
--- a/trunk/src/templatepkg
+++ b/trunk/src/templatepkg
@@ -167,11 +167,7 @@ function template_create {
# create a new template
- # TODO: -c <template> [jail-root|template-name]
- # - busca nao soh em /etc/simplepkg/templates
- # - mas tambem em /etc/simplepkg/defaults/templates
-
- local template_base info_commit
+ local template_base info_commit orig_template
if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then
if use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
@@ -212,15 +208,42 @@ function template_create {
info_commit="yes"
fi
- if [ "$info_commit" == "yes" ]; then
- echo $BASENAME: please run jail-commit to add files under $file into the svn repository
+ else
+ mkdir $TEMPLATE_BASE.{d,s}
+ fi
+
+ if [ -d "$ROOT" ]; then
+ template_update
+ elif [ ! -z "$ROOT" ]; then
+
+ # copy from an existing template
+
+ if [ -d "$BASE_CONF/templates/$ROOT" ]; then
+ orig_template="$BASE_CONF/templates/$ROOT"
+ elif [ -d "$BASE_CONF/defaults/templates/$ROOT" ]; then
+ orig_template="$BASE_CONF/defaults/templates/$ROOT"
+ else
+ return 1
+ fi
+
+ cat $orig_template/$ROOT.perms > $TEMPLATE_BASE.perms
+ cat $orig_template/$ROOT.template > $TEMPLATE_BASE.template
+
+ if use_svn && [ -d "$orig_template/.svn" ]; then
+ rsync -av --exclude=.svn $orig_template/$ROOT.d/ $TEMPLATE_BASE.d/
+ svn add $TEMPLATE_BASE.d/*
+ info_commit="yes"
+ else
+ rsync -av $orig_template/$ROOT.d/ $TEMPLATE_BASE.d/
fi
else
- mkdir $TEMPLATE_BASE.{d,s}
+ echo $BASENAME: warning: no root directory defined
fi
- template_update
+ if [ "$info_commit" == "yes" ]; then
+ echo $BASENAME: please run jail-commit to add files under $file into the svn repository
+ fi
}
@@ -447,8 +470,18 @@ function template_list {
# list templates
# usage: template_list [template_name]
- if [ -d "$BASE_CONF/templates" ]; then
- ls $BASE_CONF/templates/$1
+ local ls
+
+ ls="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
+ if [ "$?" == "0" ]; then
+ echo Default templates:
+ echo "$ls"
+ fi
+
+ ls="`ls $BASE_CONF/templates/$1 2> /dev/null`"
+ if [ "$?" == "0" ]; then
+ echo Custom templates:
+ ls "$ls"
fi
}