diff options
author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2007-04-05 20:27:30 +0000 |
---|---|---|
committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2007-04-05 20:27:30 +0000 |
commit | 99f1bfcd86daa3f0b01ba62c667f8b2c378690c4 (patch) | |
tree | c95cbb680deffbfc8096c7270f259b720f9827f9 /trunk/src | |
parent | 586b4aa194d17d337a0c552dbf273e282a7550bf (diff) | |
download | simplepkg-99f1bfcd86daa3f0b01ba62c667f8b2c378690c4.tar.gz simplepkg-99f1bfcd86daa3f0b01ba62c667f8b2c378690c4.tar.bz2 |
templatepkg: now --create can copy from an existing template
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@255 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rwxr-xr-x | trunk/src/templatepkg | 55 |
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 } |