gen config env from jobfile
This commit is contained in:
parent
d63343865c
commit
715c783e62
@ -2,14 +2,25 @@
|
||||
#remaster lib
|
||||
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
||||
|
||||
#config_load config
|
||||
function config_load() {
|
||||
config="$1"
|
||||
#config_build jobfile configenv
|
||||
function config_build() {
|
||||
config_file="$1"
|
||||
config_env="$2"
|
||||
|
||||
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
|
||||
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
|
||||
[ -f "<LIBDIR>/proj/$project" ] || {
|
||||
@ -21,7 +32,7 @@ function config_load() {
|
||||
|
||||
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
|
||||
config_key=`echo $line | cut -d "=" -f 1`
|
||||
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'`}"
|
||||
|
||||
#save seting in environment var
|
||||
eval "$config_key=\"$config_value\""
|
||||
echo $config_key=${!config_key}
|
||||
echo "$config_key='$config_value'" | tee $config_env
|
||||
|
||||
else
|
||||
echo "WARNUNG: $config_key is an inconrect setting. This will be ignored"
|
||||
@ -55,5 +65,5 @@ function config_load() {
|
||||
|
||||
#this func is standalone executable
|
||||
[ -n "$1" ] && {
|
||||
config_load $@
|
||||
config_build $@
|
||||
}
|
@ -76,8 +76,8 @@ source <LIBDIR>/func/chroot_sh
|
||||
|
||||
### config ###
|
||||
|
||||
#config_load [config]
|
||||
source <LIBDIR>/func/config_load
|
||||
#config_build jobfile configenv
|
||||
source <LIBDIR>/func/config_build
|
||||
|
||||
#config_check
|
||||
source <LIBDIR>/func/config_check
|
||||
@ -98,6 +98,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
### -> $1 jobfile, if zero and onlyone file exist ues this else print error and list
|
||||
#check LOG
|
||||
{
|
||||
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 ###
|
||||
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"
|
||||
echo $'\n\n' >> "$log_file"
|
||||
source $config_env
|
||||
|
||||
|
||||
### Enviroment ###
|
||||
|
Loading…
Reference in New Issue
Block a user