diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.sh | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/lib/common.sh b/lib/common.sh index 5b82469..fc62611 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -199,9 +199,7 @@ function eval_config { 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 + TEMPLATE_STORAGE_STYLE="`eval_parameter TEMPLATE_STORAGE_STYLE own_folder`" SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`" SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`" @@ -212,6 +210,7 @@ function eval_config { WARNING="`eval_boolean_parameter WARNING 0`" SIGNATURE_CHECKING="`eval_boolean_parameter SIGNATURE_CHECKING 0`" DEPENDENCY_CHECKING="`eval_boolean_parameter DEPENDENCY_CHECKING 1`" + TEMPLATES_UNDER_SVN="`eval_boolean_parameter TEMPLATES_UNDER_SVN 0`" # Enabling this option (i.e, setting to "1" or "yes"), simplaret will # donwload even # already applied patches, a good option when you plan @@ -283,6 +282,12 @@ function eval_config { echo "$SIMPLARET not found, please install it before run $0" fi + if [ "$TEMPLATE_STORAGE_STYLE" != "simplepkg-folder" ] && \ + [ "$TEMPLATE_STORAGE_STYLE" != "templates-folder" ] && \ + [ "$TEMPLATE_STORAGE_STYLE" != "own-folder" ]; then + TEMPLATE_STORAGE_STYLE="own-folder" + fi + } function default_version { @@ -329,7 +334,7 @@ function search_default_template { function search_template { # determine the template to be used - # usage: <search-template> <template-name> [--new] + # usage: <search-template> <template-name> [--new | --update] # # templates can be stored either on @@ -348,9 +353,16 @@ function search_template { 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 + if [ "$TEMPLATE_STORAGE_STYLE" == "simplepkg-folder" ]; then + TEMPLATE_BASE="$BASE_CONF/$1" + elif [ "$TEMPLATE_STORAGE_STYLE" == "templates-folder" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/$1" + else + TEMPLATE_BASE="$BASE_CONF/templates/$1/$1" + mkdir -p $BASE_CONF/templates/$1 + fi + elif [ "$2" == "--update" ] + return 1 else echo $BASENAME: template $1 not found search_default_template @@ -359,3 +371,41 @@ function search_template { } +function numeric_perm { + + # get the numeric permission of a file + # usage: numeric_perm <file-name> + + # just a bit of forbidden secrets + + if [ -a "$file" ]; then + ls -ln $file | awk '{ print $1 }' | \ + sed -e 's/^.//' -e 's/r/4/g' -e 's/w/2/g' -e 's/x/1/g' + -e 's/-/0/g' -e 's/\(.\)\(.\)\(.\)/\1+\2+\3/g' | \ + fold -w5 | bc -l | xargs | sed -e 's/ //g' + fi + +} + +function get_owner { + + # get the numeric owner for a file + # usage: get_owner <file> + + if [ -a "$1" ]; then + ls -ln $1 | awk '{ print $3 }' + fi + +} + +function get_group { + + # get the numeric group for a file + # usage: get_group <file> + + if [ -a "$1" ]; then + ls -ln $1 | awk '{ print $4 }' + fi + +} + |