diff options
-rw-r--r-- | trunk/lib/common.sh | 1 | ||||
-rwxr-xr-x | trunk/src/templatepkg | 34 |
2 files changed, 26 insertions, 9 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 9a1f1e0..6d23262 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -372,7 +372,6 @@ function search_template { TEMPLATE_BASE="$BASE_CONF/templates/$1" else TEMPLATE_BASE="$BASE_CONF/templates/$1/$1" - mkdir -p $BASE_CONF/templates/$1 fi elif [ "$2" == "--update" ]; then return 1 diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg index e2feaa7..b0afb3b 100755 --- a/trunk/src/templatepkg +++ b/trunk/src/templatepkg @@ -214,14 +214,7 @@ function template_update { # update the template package list - components="$TEMPLATE_BASE.template $TEMPLATE_BASE.perms $TEMPLATE_BASE.d $TEMPLATE_BASE.s" - for component in $components; do - if [ ! -e "$component" ]; then - echo $BASENAME: template component not found: $component - echo $BASENAME: please run $BASENAME -c before update a template - exit 1 - fi - done + check_template_exist if [ ! -d "$ROOT/var/log/packages" ]; then echo $ROOT/var/log/packages: directory not found @@ -279,6 +272,8 @@ function template_add { return 1 fi + check_template_exist + jail="/$1" file="$2" @@ -363,6 +358,29 @@ function slash { } +function check_template_exist { + + # check if a template exists + + local components + + components="$TEMPLATE_BASE.template $TEMPLATE_BASE.perms $TEMPLATE_BASE.d $TEMPLATE_BASE.s" + + if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then + echo $BASENAME: template not found + exit 1 + fi + + for component in $components; do + if [ ! -e "$component" ]; then + echo $BASENAME: template component not found: $component + echo $BASENAME: please run $BASENAME -c before update a template + exit 1 + fi + done + +} + # command line parsing if [ -z "$2" ]; then |