Compare commits
8 Commits
master
...
feature-pr
Author | SHA1 | Date | |
---|---|---|---|
715c783e62 | |||
d63343865c | |||
888f626d4f | |||
ef395c4443 | |||
3b3c588dcc | |||
495bbb5f4a | |||
5df896a47e | |||
10f06bc421 |
7
doc/source_var/doja.sh
Executable file
7
doc/source_var/doja.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo doja loadet
|
||||||
|
|
||||||
|
function ja() {
|
||||||
|
echo ja
|
||||||
|
}
|
11
doc/source_var/main.sh
Executable file
11
doc/source_var/main.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo try to import functions of script "$1"
|
||||||
|
|
||||||
|
export "mod=$1"
|
||||||
|
|
||||||
|
[[ -s "$mod" ]] && source "$mod"
|
||||||
|
|
||||||
|
|
||||||
|
ja
|
||||||
|
[ "$?" != "0" ] && echo use $0 with doja.sh next time ;)
|
@ -11,8 +11,8 @@ iso_source="/data/local/Desinfect_Remaster/tmp/desinfect-2017.iso"
|
|||||||
# squashfs_path="/data/local/Desinfect_Remaster/tmp/filesystem.squashfs"
|
# squashfs_path="/data/local/Desinfect_Remaster/tmp/filesystem.squashfs"
|
||||||
|
|
||||||
## Ziel, Lable der zu erstellenden CD/DVD
|
## Ziel, Lable der zu erstellenden CD/DVD
|
||||||
iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_`date '+%Y-%m-%d'`.iso"
|
iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_<date>.iso"
|
||||||
iso_lable="DESINFECT_`date '+%Y-%m-%d'`"
|
iso_lable="DESINFECT_<date>"
|
||||||
|
|
||||||
|
|
||||||
## Netzwerk Sinstellungen
|
## Netzwerk Sinstellungen
|
||||||
@ -28,7 +28,7 @@ project="desinfect.17"
|
|||||||
|
|
||||||
## LOG Einstellungen
|
## LOG Einstellungen
|
||||||
## log_file ist optionall
|
## log_file ist optionall
|
||||||
log_file="/data/local/Desinfect_Remaster/tmp/logs/`date '+%Y-%m-%d'`.log"
|
log_file="/data/local/Desinfect_Remaster/tmp/logs/<date>.log"
|
||||||
## Senden mit sendmail einen Report
|
## Senden mit sendmail einen Report
|
||||||
# log_mail_source="desinfect@email.clocal"
|
# log_mail_source="desinfect@email.clocal"
|
||||||
# log_mail_smtp="smtp.mail.local:25"
|
# log_mail_smtp="smtp.mail.local:25"
|
||||||
|
69
src/func/config_build
Normal file
69
src/func/config_build
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#remaster lib
|
||||||
|
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 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_file" | grep ^[^#] | grep ^project= | cut -d "#" -f 1 | tr -d '"'`"
|
||||||
|
|
||||||
|
#check if project template exist
|
||||||
|
[ -f "<LIBDIR>/proj/$project" ] || {
|
||||||
|
echo "No Project \"$project\" is not supported"
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
# loard project
|
||||||
|
source "<LIBDIR>/proj/$project"
|
||||||
|
|
||||||
|
echo; echo #space
|
||||||
|
|
||||||
|
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 '"'`
|
||||||
|
config_corect="false"
|
||||||
|
|
||||||
|
#check if this is a alowed config key
|
||||||
|
for i in $config_keys; do
|
||||||
|
[ "$i" == "$config_key" ] && config_corect="true"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$config_corect" == "true" ]; then
|
||||||
|
#load config key
|
||||||
|
|
||||||
|
#replace value strings
|
||||||
|
config_value="${config_value/<date>/`date '+%Y-%m-%d'`}"
|
||||||
|
config_value="${config_value/<time>/`date '+%H:%M:%S'`}"
|
||||||
|
onfig_value="${config_value/<DATE>/`date '+%Y-%m-%d'`}"
|
||||||
|
config_value="${config_value/<TIME>/`date '+%H:%M:%S'`}"
|
||||||
|
|
||||||
|
#save seting in environment var
|
||||||
|
echo "$config_key='$config_value'" | tee $config_env
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "WARNUNG: $config_key is an inconrect setting. This will be ignored"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#this func is standalone executable
|
||||||
|
[ -n "$1" ] && {
|
||||||
|
config_build $@
|
||||||
|
}
|
@ -2,8 +2,8 @@
|
|||||||
#remaster lib
|
#remaster lib
|
||||||
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
||||||
|
|
||||||
#check_config
|
#config_check
|
||||||
function check_config() {
|
function config_check() {
|
||||||
|
|
||||||
#Project
|
#Project
|
||||||
[ -f "<LIBDIR>/proj/$project" ] || {
|
[ -f "<LIBDIR>/proj/$project" ] || {
|
||||||
@ -24,7 +24,7 @@ function check_config() {
|
|||||||
echo 'iso_source -> squashfs'
|
echo 'iso_source -> squashfs'
|
||||||
else
|
else
|
||||||
# ERROR
|
# ERROR
|
||||||
echo "No corect AIM in Settings"
|
echo "Settings: No corect AIM"
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -32,14 +32,14 @@ function check_config() {
|
|||||||
if [ -f "$squashfs_path" ]; then
|
if [ -f "$squashfs_path" ]; then
|
||||||
if [ -n "$iso_aim" ]; then
|
if [ -n "$iso_aim" ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo "only Squashfs source in Settings, cant creat ISO"
|
echo "Settings: only Squashfs source in Settings, cant creat ISO"
|
||||||
return 3
|
return 3
|
||||||
else
|
else
|
||||||
echo 'squashfs -> squashfs'
|
echo 'squashfs -> squashfs'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# ERROR
|
# ERROR
|
||||||
echo "No corect Source in Settings"
|
echo "Settings: No corect Source"
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -51,5 +51,5 @@ function check_config() {
|
|||||||
|
|
||||||
#this func is standalone executable
|
#this func is standalone executable
|
||||||
[ -n "$1" ] && {
|
[ -n "$1" ] && {
|
||||||
check_config $@
|
config_check $@
|
||||||
}
|
}
|
@ -6,8 +6,12 @@
|
|||||||
##### B a s e ####
|
##### B a s e ####
|
||||||
##################
|
##################
|
||||||
# .
|
# .
|
||||||
|
|
||||||
|
# Enviroment
|
||||||
project_relation=""
|
project_relation=""
|
||||||
[ -z "$project" ] && project=base
|
[ -z "$project" ] && project=base
|
||||||
|
config_keys="iso_source iso_aim iso_lable squashfs_path proxy_host proxy_port domain nameserver project log_file log_mail_source log_mail_smtp log_mail_aim log_mail_subject tools_list"
|
||||||
|
|
||||||
|
|
||||||
#tools_add [chroot_dir] [tools_list]
|
#tools_add [chroot_dir] [tools_list]
|
||||||
function tools_add() {
|
function tools_add() {
|
||||||
|
152
src/remaster.sh
152
src/remaster.sh
@ -5,7 +5,7 @@
|
|||||||
#@licence GNUv3
|
#@licence GNUv3
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
################## S e t t i n g s ##################################################
|
################## F u n c t i o n s ################################################
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
|
||||||
#set functions
|
#set functions
|
||||||
@ -14,44 +14,6 @@
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#read main setting
|
|
||||||
if [ -f "<ROOTDIR>/etc/remaster/config.cfg" ]; then
|
|
||||||
source "<ROOTDIR>/etc/remaster/config.cfg"
|
|
||||||
else
|
|
||||||
if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg" ]; then
|
|
||||||
source "<ROOTDIR>/etc/remaster/config.sample.cfg"
|
|
||||||
else
|
|
||||||
echo "ERROR config not found"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################################################################
|
|
||||||
################## F u n c t i o n s ################################################
|
|
||||||
#####################################################################################
|
|
||||||
|
|
||||||
### Error Handlings ###
|
|
||||||
|
|
||||||
#check_config
|
|
||||||
source <LIBDIR>/func/check_config
|
|
||||||
|
|
||||||
#on_exit [error_level]
|
#on_exit [error_level]
|
||||||
source <LIBDIR>/func/on_exit
|
source <LIBDIR>/func/on_exit
|
||||||
|
|
||||||
@ -112,64 +74,78 @@ source <LIBDIR>/func/chroot_is_mounted
|
|||||||
#chroot_sh [chroot_dir] [command]
|
#chroot_sh [chroot_dir] [command]
|
||||||
source <LIBDIR>/func/chroot_sh
|
source <LIBDIR>/func/chroot_sh
|
||||||
|
|
||||||
####################################
|
### config ###
|
||||||
### Workaround - set Project
|
|
||||||
source <LIBDIR>/proj/desinfect.17
|
#config_build jobfile configenv
|
||||||
####################################
|
source <LIBDIR>/func/config_build
|
||||||
|
|
||||||
|
#config_check
|
||||||
|
source <LIBDIR>/func/config_check
|
||||||
|
|
||||||
|
|
||||||
|
#####################################################################################
|
||||||
|
################## S e t t i n g s ##################################################
|
||||||
|
#####################################################################################
|
||||||
|
|
||||||
|
#read main setting
|
||||||
|
if [ -f "<ROOTDIR>/etc/remaster/config.cfg" ]; then
|
||||||
|
config="<ROOTDIR>/etc/remaster/config.cfg"
|
||||||
|
else
|
||||||
|
if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg" ]; then
|
||||||
|
config="<ROOTDIR>/etc/remaster/config.sample.cfg"
|
||||||
|
else
|
||||||
|
echo "ERROR config not found"
|
||||||
|
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 '"'`"
|
||||||
|
[ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
################# P r o c e s s ... #######################
|
################# P r o c e s s ... #######################
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
#Start LOG
|
### Start LOG ###
|
||||||
tail -f "$log_file" --pid="$$" &
|
tail -f "$log_file" --pid="$$" &
|
||||||
|
|
||||||
|
echo "Remaster LOG `date '+%Y-%m-%d'`" > "$log_file"
|
||||||
|
echo >> "$log_file"
|
||||||
|
|
||||||
|
|
||||||
|
### S e t t i n g s ###
|
||||||
|
config_env=`mktemp`
|
||||||
|
config_build $config $config_env >> "$log_file"
|
||||||
|
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
|
||||||
|
source $config_env
|
||||||
|
|
||||||
|
|
||||||
|
### Enviroment ###
|
||||||
|
echo "### Enviroment ###" >> "$log_file"
|
||||||
|
|
||||||
chroot_path="`mktemp -d`"
|
chroot_path="`mktemp -d`"
|
||||||
iso_extr_dir="`mktemp -d`"
|
iso_extr_dir="`mktemp -d`"
|
||||||
|
|
||||||
echo "Remaster LOG `date '+%Y-%m-%d'`" > "$log_file"
|
|
||||||
echo "MODE: renew" >> "$log_file"
|
|
||||||
echo "HOST: `hostname`" >> "$log_file"
|
|
||||||
echo >> "$log_file"
|
|
||||||
|
|
||||||
echo "### S e t t i n g s ###" >> "$log_file"
|
|
||||||
echo "#CD/DVD" >> "$log_file"
|
|
||||||
echo "iso_source=\"$iso_source\"" >> "$log_file"
|
|
||||||
echo "iso_aim=\"$iso_aim\"" >> "$log_file"
|
|
||||||
echo "iso_lable=\"$iso_lable\"" >> "$log_file"
|
|
||||||
echo >> "$log_file"
|
|
||||||
|
|
||||||
echo "#Filesystem (for pxe)" >> "$log_file"
|
|
||||||
echo "squashfs_path=\"$squashfs_path\"" >> "$log_file"
|
|
||||||
echo >> "$log_file"
|
|
||||||
|
|
||||||
echo "#Network" >> "$log_file"
|
|
||||||
echo "proxy_host=\"$proxy_host\"" >> "$log_file"
|
|
||||||
echo "proxy_port=\"$proxy_port\"" >> "$log_file"
|
|
||||||
echo "domain=\"$domain\"" >> "$log_file"
|
|
||||||
echo "nameserver=\"$nameserver\"" >> "$log_file"
|
|
||||||
echo >> "$log_file"
|
|
||||||
|
|
||||||
echo "#remaster_script" >> "$log_file"
|
|
||||||
echo "project=\"$project\"" >> "$log_file"
|
|
||||||
echo >> "$log_file"
|
|
||||||
|
|
||||||
echo "log_file=\"$log_file\""
|
|
||||||
echo "log_mail_aim=\"$log_mail_aim\""
|
|
||||||
echo "log_mail_subject=\"$log_mail_subj >> "$log_file"ect\""
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "#Sonstiges" >> "$log_file"
|
|
||||||
echo "tools_list=\"$tools_list\"" >> "$log_file"
|
|
||||||
echo $'\n' >> "$log_file"
|
|
||||||
|
|
||||||
echo "### Enviroment ###"
|
|
||||||
echo "iso_extr_dir=\"$iso_extr_dir\"" >> "$log_file"
|
echo "iso_extr_dir=\"$iso_extr_dir\"" >> "$log_file"
|
||||||
echo "chroot_path=\"$chroot_path\"" >> "$log_file"
|
echo "chroot_path=\"$chroot_path\"" >> "$log_file"
|
||||||
#env >> "$log_file"
|
echo "HOST: `hostname`" >> "$log_file"
|
||||||
echo $'\n\n' >> "$log_file"
|
|
||||||
|
|
||||||
echo $'### R U N ... ###\n' >> "$log_file"
|
|
||||||
|
|
||||||
#1. Set and Check Enviroment
|
#1. Set and Check Enviroment
|
||||||
check_user >> "$log_file"
|
check_user >> "$log_file"
|
||||||
@ -178,11 +154,15 @@ error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_fil
|
|||||||
check_dependency >> "$log_file"
|
check_dependency >> "$log_file"
|
||||||
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
|
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
|
||||||
|
|
||||||
check_config >> "$log_file"
|
config_check >> "$log_file"
|
||||||
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
|
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
|
||||||
|
|
||||||
check_update >> "$log_file"
|
check_update >> "$log_file"
|
||||||
|
|
||||||
|
|
||||||
|
### R U N ... ###
|
||||||
|
echo $'### R U N ... ###\n' >> "$log_file"
|
||||||
|
|
||||||
# 2. Entpacke ISO
|
# 2. Entpacke ISO
|
||||||
iso_extract "$iso_source" "$iso_extr_dir" >> "$log_file"
|
iso_extract "$iso_source" "$iso_extr_dir" >> "$log_file"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user