diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh index 2b78c10..5b82469 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -198,6 +198,10 @@ function eval_config { FTP_TOOL="`eval_parameter FTP_TOOL curl`" 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 SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`" SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`" @@ -307,3 +311,51 @@ function default_arch { } +function search_default_template { + + if [ -f "$BASE_CONF/templates/default.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/default" + echo $BASENAME: using default template + elif [ -f "$BASE_CONF/default.template" ]; then + TEMPLATE_BASE="$BASE_CONF/default" + echo $BASENAME using default template + else + echo $BASENAME: error: default template not found + echo $BASENAME: please create a template using templatepkg + return 1 + fi +} + +function search_template { + + # determine the template to be used + # usage: <search-template> <template-name> [--new] + + # + # templates can be stored either on + # + # - $BASE_CONF/template_name.template + # - $BASE_CONF/templates/template_name.template + # - $BASE_CONF/templates/template_name/template_name.template + # + + if [ -f "$BASE_CONF/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/$1" + elif [ -f "$BASE_CONF/templates/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/$1" + elif [ -f "$BASE_CONF/templates/$1/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/$1/$1" + 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 + else + echo $BASENAME: template $1 not found + search_default_template + fi + fi + +} + |