11 Commits

Author SHA1 Message Date
715c783e62 gen config env from jobfile 2018-06-04 03:28:34 +02:00
d63343865c set var the right way 2018-06-02 23:09:05 +02:00
888f626d4f aktuel. version 2018-06-02 22:50:47 +02:00
18b42628a0 restruct config 2018-06-02 22:49:54 +02:00
ef395c4443 error message tells error source 2018-06-02 08:09:49 +02:00
3b3c588dcc rename func 2018-06-01 23:44:39 +02:00
f809343015 report corect meaning 2018-06-01 01:56:41 +02:00
495bbb5f4a dont exec config, parse it 2018-06-01 01:52:11 +02:00
5df896a47e commit 2018-05-31 20:23:11 +02:00
10f06bc421 idee ... 2018-05-31 20:17:42 +02:00
4cb8816cc1 notes, smal fix 2018-05-22 12:46:20 +02:00
10 changed files with 195 additions and 116 deletions

2
doc/notes Normal file
View File

@ -0,0 +1,2 @@
initrd:
https://help.ubuntu.com/community/LiveCDCustomization#Removing_the_.28Casper.29_Autologina

7
doc/source_var/doja.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
echo doja loadet
function ja() {
echo ja
}

11
doc/source_var/main.sh Executable file
View 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 ;)

View File

@ -1,36 +1,39 @@
#cfg
######################################################### #########################################################
## sample-config rename it to config.cfg after changes ## ## sample-config rename it to config.cfg after changes ##
######################################################### #########################################################
#CD/DVD ## Quelle der Project CD/DVD
#entweder iso_source oder squashfs_path alls quelle iso_source="/data/local/Desinfect_Remaster/tmp/desinfect-2017.iso"
# -> bei iso gen erforderlich!
iso_source="/data/remaster/desinfect-2017.iso"
#destination optinal
iso_aim="/data/remaster/result/custom_desinfect_`date '+%Y-%m-%d'`.iso"
iso_lable="DESINFECT_`date '+%Y-%m-%d'`"
#Filesystem (for pxe) ## Pfad zum gepakten Live System
#entweder iso_source oder squashfs_path alls quelle ## (kann anstat einer ISO auch als Quelle dienen, dann aber auch zwingend als Ziel)
squashfs_path="/data/remaster/result/filesystem.squashfs" # squashfs_path="/data/local/Desinfect_Remaster/tmp/filesystem.squashfs"
#Network ## Ziel, Lable der zu erstellenden CD/DVD
proxy_host="proxy.local" iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_<date>.iso"
proxy_port="8080" iso_lable="DESINFECT_<date>"
domain="local"
nameserver="10.x.x.2,10.x.x.1"
#remaster_script
## Netzwerk Sinstellungen
## Proxy:
# proxy_host="10.40.8.108"
# proxy_port="8080"
domain="fritz.box"
nameserver="10.40.255.254"
## Project / Distro
## Aktuell unterstützt: debian; ubuntu; ubuntu.14.04; ubuntu.16.04; desinfect.17
project="desinfect.17" project="desinfect.17"
#LOG ## LOG Einstellungen
log_file="/data/remaster/logs/`date '+%Y-%m-%d'`.log" ## log_file ist optionall
log_mail_source="desinfect@email.clocal" log_file="/data/local/Desinfect_Remaster/tmp/logs/<date>.log"
log_mail_smtp="smtp.mail.local:25" ## Senden mit sendmail einen Report
log_mail_aim="6543@email.clocal" # log_mail_source="desinfect@email.clocal"
log_mail_subject="Desinfect_Remaster" # log_mail_smtp="smtp.mail.local:25"
# log_mail_aim="6543@email.clocal"
# log_mail_subject="Desinfect_Remaster"
#Sonstiges #Sonstiges
tools_list="xrdp clamav nano htop nmon iftop tmux dsniff nmap openssh-server tightvncserver rsync e2fsprogs foremost gddrescue recoverjpeg safecopy sleuthkit testdisk arp-scan" tools_list="xrdp clamav nano htop nmon iftop tmux dsniff nmap openssh-server tightvncserver rsync e2fsprogs foremost gddrescue recoverjpeg safecopy sleuthkit testdisk arp-scan"

View File

@ -7,7 +7,7 @@ function check_update() {
if curl https://raw.githubusercontent.com/6543/remaster/master/changes/remaster.md | diff - <(zcat <ROOTDIR>/usr/share/doc/remaster/changelog.gz ); then if curl https://raw.githubusercontent.com/6543/remaster/master/changes/remaster.md | diff - <(zcat <ROOTDIR>/usr/share/doc/remaster/changelog.gz ); then
echo 'INFO: Programm Aktuell' echo 'INFO: Programm Aktuell'
else else
echo 'WARNUNG: neue Version verfügbar' echo 'WARNUNG: Ausgeführte Version entspricht nicht dem offiziellen Release'
fi fi
} }

69
src/func/config_build Normal file
View 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 $@
}

View File

@ -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 $@
} }

View File

@ -2,6 +2,9 @@
#remaster lib #remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; } [ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
#dependency
source <LIBDIR>/func/filesystem_get_type
#filesystem_extract [filesystem_img_source] [chroot_path] #filesystem_extract [filesystem_img_source] [chroot_path]
function filesystem_extract() { function filesystem_extract() {
echo "extract filesystem ..." echo "extract filesystem ..."

View File

@ -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() {

View File

@ -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"