aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r--trunk/lib/common.sh95
1 files changed, 75 insertions, 20 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh
index 4e73ea5..f9c115f 100644
--- a/trunk/lib/common.sh
+++ b/trunk/lib/common.sh
@@ -15,6 +15,8 @@
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place - Suite 330, Boston, MA 02111-1307, USA
#
+# $Rev$ - $Author$
+#
BASE_CONF="/etc/simplepkg"
CONF="$BASE_CONF/simplepkg.conf"
@@ -150,13 +152,13 @@ function eval_parameter {
function set_constants {
- # Set common constants
- # on/off
- on=1
- off=0
- # yes/no
- yes=1
- no=0
+ # Set common constants
+ # on/off
+ on=1
+ off=0
+ # yes/no
+ yes=1
+ no=0
}
@@ -294,8 +296,9 @@ function eval_config {
if [ "$TEMPLATE_STORAGE_STYLE" != "simplepkg-folder" ] && \
[ "$TEMPLATE_STORAGE_STYLE" != "templates-folder" ] && \
- [ "$TEMPLATE_STORAGE_STYLE" != "own-folder" ]; then
- TEMPLATE_STORAGE_STYLE="own-folder"
+ [ "$TEMPLATE_STORAGE_STYLE" != "own-folder" ] && \
+ [ "$TEMPLATE_STORAGE_STYLE" != "compact" ]; then
+ TEMPLATE_STORAGE_STYLE="compact"
fi
if [ ! -z "$ROOT" ]; then
@@ -390,7 +393,13 @@ function search_default_template {
elif [ -e "$TEMPLATE_FOLDER/default/default.template" ]; then
TEMPLATE_BASE="$TEMPLATE_FOLDER/default/default"
echo $BASENAME: using default template
+ elif [ -e "$TEMPLATE_FOLDER/default/packages" ]; then
+ TEMPLATE_BASE="$TEMPLATE_FOLDER/default"
+ echo $BASENAME: using default template
elif [ -e "$BASE_CONF/defaults/templates/default/default.template" ]; then
+ TEMPLATE_BASE="$BASE_CONF/defaults/templates/default/default"
+ echo $BASENAME using default template
+ elif [ -e "$BASE_CONF/defaults/templates/default/packages" ]; then
TEMPLATE_BASE="$BASE_CONF/defaults/templates/default"
echo $BASENAME using default template
else
@@ -425,6 +434,8 @@ function search_template {
TEMPLATE_BASE="$TEMPLATE_FOLDER/$1"
elif [ -f "$TEMPLATE_FOLDER/$1/$1.template" ]; then
TEMPLATE_BASE="$TEMPLATE_FOLDER/$1/$1"
+ elif [ -f "$TEMPLATE_FOLDER/$1/packages" ]; then
+ TEMPLATE_BASE="$TEMPLATE_FOLDER/$1"
elif [ -f "$BASE_CONF/defaults/templates/$1/$1.template" ] && \
[ "$2" != "--update" ]; then
TEMPLATE_BASE="$BASE_CONF/defaults/templates/$1/$1"
@@ -435,8 +446,12 @@ function search_template {
TEMPLATE_BASE="$BASE_CONF/$1"
elif [ "$TEMPLATE_STORAGE_STYLE" == "templates-folder" ]; then
TEMPLATE_BASE="$TEMPLATE_FOLDER/$1"
- else
+ elif [ "$TEMPLATE_STORAGE_STYLE" == "own-folder" ]; then
TEMPLATE_BASE="$TEMPLATE_FOLDER/$1/$1"
+ elif [ "$TEMPLATE_STORAGE_STYLE" == "compact" ]; then
+ TEMPLATE_BASE="$TEMPLATE_FOLDER/$1"
+ else
+ TEMPLATE_BASE="$TEMPLATE_FOLDER/$1"
fi
elif [ "$2" == "--update" ]; then
return 1
@@ -448,6 +463,46 @@ function search_template {
}
+function template_packages {
+
+ if [ "$TEMPLATE_STORAGE_STYLE" == "compact" ]; then
+ echo $TEMPLATE_BASE/packages
+ else
+ echo $TEMPLATE_BASE.template
+ fi
+
+}
+
+function template_perms {
+
+ if [ "$TEMPLATE_STORAGE_STYLE" == "compact" ]; then
+ echo $TEMPLATE_BASE/perms
+ else
+ echo $TEMPLATE_BASE.perms
+ fi
+
+}
+
+function template_files {
+
+ if [ "$TEMPLATE_STORAGE_STYLE" == "compact" ]; then
+ echo $TEMPLATE_BASE/files
+ else
+ echo $TEMPLATE_BASE.d
+ fi
+
+}
+
+function template_scripts {
+
+ if [ "$TEMPLATE_STORAGE_STYLE" == "compact" ]; then
+ echo $TEMPLATE_BASE/scripts
+ else
+ echo $TEMPLATE_BASE.s
+ fi
+
+}
+
# -----------------------------------------------
# unix permission functions
# -----------------------------------------------
@@ -745,7 +800,7 @@ function update_template_files {
# update template files from svn
# usage: update_template_files
- if templates_under_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
+ if templates_under_svn && [ -d "`template_files`/.svn" ]; then
echo Checking out last template revision from svn...
cd `dirname $TEMPLATE_BASE`
svn update
@@ -761,13 +816,13 @@ function update_jail_packages {
# check if installed packages are listed in the template
for pack in `ls -1 $1/var/log/packages/`; do
pack=`package_name $pack`
- if ! `grep -v -e "^#" $TEMPLATE_BASE.template | cut -d : -f 1 | awk '{ print $1 }' | grep -q -e "^$pack\$"`; then
+ if ! `grep -v -e "^#" $(template_packages) | cut -d : -f 1 | awk '{ print $1 }' | grep -q -e "^$pack\$"`; then
ROOT=$1 removepkg $pack
fi
done
# check if each package from the template is installed
- grep -v -e "^#" $TEMPLATE_BASE.template | cut -d : -f 1 | awk '{ print $1 }' | while read pack; do
+ grep -v -e "^#" `template_packages` | cut -d : -f 1 | awk '{ print $1 }' | while read pack; do
# check if the package is installed
pack="`echo $pack | sed -e 's/\+/\\\+/'`"
@@ -788,12 +843,12 @@ function copy_template_files {
# usage: copy_template_files <jail-path>
if [ -d "$1" ]; then
- if [ -d "$TEMPLATE_BASE.d" ]; then
+ if [ -d "`template_files`" ]; then
echo "Copying template files to $1..."
- if templates_under_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
- rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $1/
+ if templates_under_svn && [ -d "`template_files`/.svn" ]; then
+ rsync -av --exclude=.svn `template_files`/ $1/
else
- rsync -av $TEMPLATE_BASE.d/ $1/
+ rsync -av `template_files`/ $1/
fi
fi
fi
@@ -805,11 +860,11 @@ function set_jail_perms {
# set template file permissions under a jail
# usage: set_jail_perms <jail-path>
- if [ -s "$TEMPLATE_BASE.perms" ]; then
+ if [ -s "`template_perms`" ]; then
echo Setting jail $1 permissions...
- cat $TEMPLATE_BASE.perms | while read entry; do
+ cat `template_perms` | while read entry; do
file="`echo $entry | cut -d ";" -f 1`"
- if [ -e "$TEMPLATE_BASE.d/$file" ] && [ -a "$1/$file" ]; then
+ if [ -e "`template_files`/$file" ] && [ -a "$1/$file" ]; then
owner="`echo $entry | cut -d ";" -f 2`"
group="`echo $entry | cut -d ";" -f 3`"
perms="`echo $entry | cut -d ";" -f 4`"