summaryrefslogtreecommitdiff
path: root/conf/tcos-generation-functions.sh
diff options
context:
space:
mode:
authorMario Izquierdo (mariodebian) <mariodebian@gmail.com>2008-04-08 09:21:00 +0000
committerMario Izquierdo (mariodebian) <mariodebian@gmail.com>2008-04-08 09:21:00 +0000
commitb94b82f777985b8830494a4c37316a2b4a44ff9d (patch)
tree9d0ab3355c3da6fe3dcf429717e393fab20694cb /conf/tcos-generation-functions.sh
parent517ff441b794aa9f27da6326221968ceec54b8a7 (diff)
initramfs-tools-tcos (0.89~rc0.1)
* get_all_tcos_vars.sh (search if all TCOS_* are in base.conf) git-svn-id: http://tcosproject.org/svn/tcos/trunk/initramfs-tools-tcos@743 97557d6f-af72-4ac7-98cc-18709f36555f
Diffstat (limited to 'conf/tcos-generation-functions.sh')
-rw-r--r--conf/tcos-generation-functions.sh52
1 files changed, 39 insertions, 13 deletions
diff --git a/conf/tcos-generation-functions.sh b/conf/tcos-generation-functions.sh
index 90cbbc7..c89d5de 100644
--- a/conf/tcos-generation-functions.sh
+++ b/conf/tcos-generation-functions.sh
@@ -5,26 +5,52 @@
# functions used by tcos hooks
_echo () {
- # wrapper to echo in scripts, only print if debug is enabled
- if [ ${TCOS_DEBUG} ]; then
+ # wrapper to echo in scripts
echo "$@"
+}
+
+_debug() {
+ if [ ${TCOS_DEBUG} ]; then
+ echo " DEBUG :: $@" >&2
+ fi
+}
+
+read_template() {
+ [ ! -e "$1" ] && return
+ tpl=$(awk -F"=" '/^TCOS_TEMPLATE=/ {print $2}' $1)
+ if [ "$tpl" = "" ]; then
+ #_debug "Not found TEMPLATE in $1, searching BASED_TEMPLATE"
+ tpl=$(awk -F"=" '/^TCOS_BASED_TEMPLATE=/ {print $2}' $1)
fi
+ [ "$tpl" = "" ] && _debug "$tpl not found" && return
+ #_debug "Template $tpl"
+ for tdir in /usr/share/initramfs-tools-tcos/templates /etc/tcos/templates; do
+ #_debug "Searching in dir $tdir"
+ [ -f $tdir/$tpl ] && echo "$tdir/$tpl" && break
+ done
}
-get_template() {
- if [ "$TCOS_TEMPLATES_DIR" != "" ] && [ -d $TCOS_TEMPLATES_DIR ]; then
- if [ -f $TCOS_TEMPLATES_DIR/$TCOS_TEMPLATE ]; then
- echo " Using template => $TCOS_TEMPLATES_DIR/$TCOS_TEMPLATE" >&2
- echo "$TCOS_TEMPLATES_DIR/$TCOS_TEMPLATE"
- return
+tcos_get_templates() {
+ # read template from tcos.conf
+ tpl1=$(read_template /etc/tcos/tcos.conf)
+ tpl2=""
+ personalized=""
+ _debug "Default template $tpl"
+ for tfile in $(find /etc/tcos/templates -type f -name "*.conf"); do
+ if [ -f $tfile ]; then
+ #_debug "$tfile file exists, adding to tpl2"
+ tpl2="$tpl2 $(read_template $tfile)"
+ personalized=$tfile
else
- echo " Using default template => $TCOS_TEMPLATES_DIR/tcos.conf.all" >&2
- echo "$TCOS_TEMPLATES_DIR/tcos.conf.all"
+ _debug "Based template $tfile not found, ignoring"
fi
+ done
+ if [ "$( echo $tpl2 | sed 's/[[:blank:]]//g' )" != "" ]; then
+ _debug "return tpl2='base.conf $tpl2 $personalized'"
+ echo "/usr/share/initramfs-tools-tcos/templates/base.conf $tpl2 $personalized"
else
- echo " ** ERROR ** Templates dir not found, please update tcos.conf" >&2
- # ugly but necesary
- killall gentcos
+ _debug "return tpl1='base.conf $tpl1'"
+ echo "/usr/share/initramfs-tools-tcos/templates/base.conf $tpl1"
fi
}