Merge branch 'feature-check-config' into develop

add feature check_config
This commit is contained in:
6543 2018-05-20 23:26:44 +02:00
commit d41fa9e1b0
3 changed files with 108 additions and 5 deletions

76
src/func/check_config Executable file
View File

@ -0,0 +1,76 @@
#!/bin/bash
#remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }

#check_config [log_file]
function check_config() {

#LOG
{
log_file=$1
[ -z "$log_file" ] && log_file="/tmp/remaster_`date '+%Y-%m-%d'`"

if [ -f "$log_file" ]; then
echo > "$log_file"
else
#check if folder exist
[ -d "${log_file%/*}" ] || {
# N-> exit 3
echo "Directory for Log didnt exist"
exit 3
}
#create LOG
touch "$log_file"
fi
}



#Project
[ -f "<LIBDIR>/proj/$distro" ] || {
echo "No Project \"$distro\" is not supported" | tee -a "$log_file"
return 3
}

#live-system files
if [ -f "$iso_source" ]; then
if [ -n "$iso_destination" ] && [ -d "${iso_destination%/*}" ]; then
#Lable
[ -z "$iso_lable" ] && iso_lable="$distro"

echo 'iso_source -> iso_destination' | tee -a "$log_file"
echo 'iso_source -> squashfs [optinal]' | tee -a "$log_file"
else
if [ -n "$filesystem_source" ] && [ -d "${filesystem_source%/*}" ]; then
echo 'iso_source -> squashfs' | tee -a "$log_file"
else
# ERROR
echo "No corect AIM in Settings" | tee -a "$log_file"
return 3
fi
fi
else
if [ -f "$filesystem_source" ]; then
if [ -n "$iso_destination" ]; then
# ERROR
echo "only Squashfs source in Settings, cant creat ISO" | tee -a "$log_file"
return 3
else
echo 'squashfs -> squashfs' | tee -a "$log_file"
fi
else
# ERROR
echo "No corect Source in Settings" | tee -a "$log_file"
return 3
fi
fi




}

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

0
src/proj/desinfect2017 Normal file
View File

View File

@ -25,6 +25,23 @@ else
exit 1
fi
fi
#check LOG
{
[ -z "$log_file" ] && log_file="/tmp/remaster_`date '+%Y-%m-%d'`"

if [ -f "$log_file" ]; then
echo > "$log_file"
else
#check if folder exist
[ -d "${log_file%/*}" ] || {
# N-> exit 3
echo "Directory for Log didnt exist"
exit 3
}
#create LOG
touch "$log_file"
fi
}

#####################################################################################
################## M o d e s ########################################################
@ -32,8 +49,7 @@ fi

#remaster.sh renew
function main_renew() {

[ -f "$log_file" ] || touch "$log_file"
#Start LOG
tail -f "$log_file" --pid="$$" &

chroot_path="`mktemp -d`"
@ -90,6 +106,9 @@ function main_renew() {
check_dependency
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

check_config "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

check_update | tee -a "$log_file"

[ "$distro" != "" ] && distro="_$distro"
@ -195,8 +214,7 @@ function main_renew() {
#remaster.sh update_pxe
function main_update_pxe() {

[ "$log_file" == "" ] && log_file="`mktemp`"
[ -f "$log_file" ] || touch "$log_file"
#Start LOG
tail -f "$log_file" --pid="$$" &

chroot_path="`mktemp -d`"
@ -245,6 +263,9 @@ function main_update_pxe() {
check_dependency
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

check_config "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

[ "$distro" != "" ] && distro="_$distro"

# 1. Entpacken der Dateien des Live-Systems
@ -308,7 +329,7 @@ function main_update_pxe() {

#remaster.sh update_iso #in arbeit
function main_update_iso() {
[ -f "$log_file" ] || touch "$log_file"
#Start LOG
tail -f "$log_file" --pid="$$" &

chroot_path="`mktemp -d`"
@ -367,6 +388,9 @@ function main_update_iso() {
check_dependency
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

check_config "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"

[ "$distro" != "" ] && distro="_$distro"

# 2. Entpacke ISO
@ -479,6 +503,9 @@ function main_update_iso() {

### Error Handlings ###

#check_config [log_file]
source <LIBDIR>/func/check_config

#on_exit [error_level]
source <LIBDIR>/func/on_exit