gen config env from jobfile

This commit is contained in:
6543 2018-06-04 03:28:34 +02:00
parent d63343865c
commit 715c783e62
2 changed files with 24 additions and 12 deletions

View File

@ -2,14 +2,25 @@
#remaster lib #remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; } [ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }


#config_load config #config_build jobfile configenv
function config_load() { function config_build() {
config="$1" config_file="$1"
config_env="$2"


echo "### S e t t i n g s ###" echo "### S e t t i n g s ###"


[ -f "$config_file" ] || {
echo "Config: wrong path for jobfile"
exit 3
}
[ -f "$config_env" ] || {
echo "Config: wrong path for config enviroment"
exit 3
}


##load project ##load project
export "`cat "$config" | grep ^[^#] | grep ^project= | cut -d "#" -f 1 | tr -d '"'`" export "`cat "$config_file" | grep ^[^#] | grep ^project= | cut -d "#" -f 1 | tr -d '"'`"


#check if project template exist #check if project template exist
[ -f "<LIBDIR>/proj/$project" ] || { [ -f "<LIBDIR>/proj/$project" ] || {
@ -21,7 +32,7 @@ function config_load() {


echo; echo #space echo; echo #space


cat "$config" | grep ^[^#] | cut -d "#" -f 1 | grep '=' | while read line; do cat "$config_file" | grep ^[^#] | cut -d "#" -f 1 | grep '=' | while read line; do
#read each var line #read each var line
config_key=`echo $line | cut -d "=" -f 1` config_key=`echo $line | cut -d "=" -f 1`
config_value=`echo $line | cut -d "=" -f 2 | tr -d '"'` config_value=`echo $line | cut -d "=" -f 2 | tr -d '"'`
@ -42,8 +53,7 @@ function config_load() {
config_value="${config_value/<TIME>/`date '+%H:%M:%S'`}" config_value="${config_value/<TIME>/`date '+%H:%M:%S'`}"


#save seting in environment var #save seting in environment var
eval "$config_key=\"$config_value\"" echo "$config_key='$config_value'" | tee $config_env
echo $config_key=${!config_key}


else else
echo "WARNUNG: $config_key is an inconrect setting. This will be ignored" echo "WARNUNG: $config_key is an inconrect setting. This will be ignored"
@ -55,5 +65,5 @@ function config_load() {


#this func is standalone executable #this func is standalone executable
[ -n "$1" ] && { [ -n "$1" ] && {
config_load $@ config_build $@
} }

View File

@ -76,8 +76,8 @@ source <LIBDIR>/func/chroot_sh


### config ### ### config ###


#config_load [config] #config_build jobfile configenv
source <LIBDIR>/func/config_load source <LIBDIR>/func/config_build


#config_check #config_check
source <LIBDIR>/func/config_check source <LIBDIR>/func/config_check
@ -98,6 +98,7 @@ else
exit 1 exit 1
fi fi
fi fi
### -> $1 jobfile, if zero and onlyone file exist ues this else print error and list
#check LOG #check LOG
{ {
export "`cat "$config" | grep ^[^#] | grep ^log_file= | cut -d "#" -f 1 | tr -d '"'`" export "`cat "$config" | grep ^[^#] | grep ^log_file= | cut -d "#" -f 1 | tr -d '"'`"
@ -130,9 +131,10 @@ echo >> "$log_file"




### S e t t i n g s ### ### S e t t i n g s ###
config_load $config >> "$log_file" config_env=`mktemp`
config_build $config $config_env >> "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file" error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
echo $'\n\n' >> "$log_file" source $config_env




### Enviroment ### ### Enviroment ###