Compare commits
9 Commits
feature-lx
...
feature-pr
Author | SHA1 | Date | |
---|---|---|---|
715c783e62 | |||
d63343865c | |||
888f626d4f | |||
18b42628a0 | |||
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 ;)
|
@ -1,36 +1,39 @@
|
||||
#cfg
|
||||
|
||||
#########################################################
|
||||
## sample-config rename it to config.cfg after changes ##
|
||||
#########################################################
|
||||
|
||||
#CD/DVD
|
||||
#entweder iso_source oder squashfs_path alls quelle
|
||||
# -> 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'`"
|
||||
## Quelle der Project CD/DVD
|
||||
iso_source="/data/local/Desinfect_Remaster/tmp/desinfect-2017.iso"
|
||||
|
||||
#Filesystem (for pxe)
|
||||
#entweder iso_source oder squashfs_path alls quelle
|
||||
squashfs_path="/data/remaster/result/filesystem.squashfs"
|
||||
## Pfad zum gepakten Live System
|
||||
## (kann anstat einer ISO auch als Quelle dienen, dann aber auch zwingend als Ziel)
|
||||
# squashfs_path="/data/local/Desinfect_Remaster/tmp/filesystem.squashfs"
|
||||
|
||||
#Network
|
||||
proxy_host="proxy.local"
|
||||
proxy_port="8080"
|
||||
domain="local"
|
||||
nameserver="10.x.x.2,10.x.x.1"
|
||||
## Ziel, Lable der zu erstellenden CD/DVD
|
||||
iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_<date>.iso"
|
||||
iso_lable="DESINFECT_<date>"
|
||||
|
||||
#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"
|
||||
|
||||
#LOG
|
||||
log_file="/data/remaster/logs/`date '+%Y-%m-%d'`.log"
|
||||
log_mail_source="desinfect@email.clocal"
|
||||
log_mail_smtp="smtp.mail.local:25"
|
||||
log_mail_aim="6543@email.clocal"
|
||||
log_mail_subject="Desinfect_Remaster"
|
||||
## LOG Einstellungen
|
||||
## log_file ist optionall
|
||||
log_file="/data/local/Desinfect_Remaster/tmp/logs/<date>.log"
|
||||
## Senden mit sendmail einen Report
|
||||
# log_mail_source="desinfect@email.clocal"
|
||||
# log_mail_smtp="smtp.mail.local:25"
|
||||
# log_mail_aim="6543@email.clocal"
|
||||
# log_mail_subject="Desinfect_Remaster"
|
||||
|
||||
#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"
|
||||
|
@ -5,7 +5,7 @@
|
||||
#check_dependency
|
||||
# -> 0 | -> 16
|
||||
function check_dependency() {
|
||||
for packet in squashfs-tools xorriso lxc wget sed sendemail; do
|
||||
for packet in squashfs-tools xorriso wget sed sendemail; do
|
||||
[ "`dpkg -l $packet 2>&1`" == "dpkg-query: Kein Paket gefunden, das auf $packet passt" ] && {
|
||||
echo "### ERROR ### Packet $packet not installed"
|
||||
return 16
|
||||
|
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
#remaster lib
|
||||
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
||||
|
||||
## overload chroot with lxc
|
||||
function chroot() {
|
||||
lxc-attach -n _remaster_ -- "$2" "$3" "$4" "$5" "$6" "$7"
|
||||
}
|
||||
|
||||
## create lxc config
|
||||
|
||||
#chroot_config [chroot_dir]
|
||||
function chroot_config() {
|
||||
|
||||
chroot_dir="$1"
|
||||
|
||||
# Container specific configuration
|
||||
echo "lxc.rootfs = $chroot_dir"
|
||||
echo "lxc.rootfs.backend = dir"
|
||||
echo "lxc.utsname = _remaster_"
|
||||
|
||||
# Network configuration
|
||||
echo "lxc.network.type = veth"
|
||||
echo "lxc.network.link = lxcbr0"
|
||||
echo "lxc.network.flags = up"
|
||||
echo "lxc.network.hwaddr = 00:16:3e:5a:ba:1e"
|
||||
}
|
||||
|
||||
[ -n "$1" ] && {
|
||||
echo param
|
||||
$1
|
||||
}
|
@ -13,13 +13,11 @@ function chroot_initial() {
|
||||
return 12
|
||||
}
|
||||
|
||||
[ -d "/var/lib/lxc/_remaster_/" ] && {
|
||||
echo "### Warning ### chroot_initial: lxc container exists"
|
||||
[ -f "/var/lib/lxc/_remaster_/config" ] && {
|
||||
mv -f "/var/lib/lxc/_remaster_/config" "/var/lib/lxc/_remaster_/config.old"
|
||||
}
|
||||
}
|
||||
mkdir -p "/var/lib/lxc/_remaster_/"
|
||||
#mount virus definitions
|
||||
mount -t tmpfs tmpfs "$chroot_dir/tmp"
|
||||
mount -t tmpfs tmpfs "$chroot_dir/root"
|
||||
mount --bind /dev "$chroot_dir/dev"
|
||||
mount --bind /proc "$chroot_dir/proc"
|
||||
|
||||
rm "$chroot_dir/etc/resolv.conf"
|
||||
cp "/etc/resolv.conf" "$chroot_dir/etc/resolv.conf"
|
||||
|
@ -7,15 +7,12 @@
|
||||
function chroot_is_mounted() {
|
||||
#$1 = chroot directory
|
||||
|
||||
#get state of _remaster from lxc
|
||||
STATE=`lxc-ls _remaster_ -f -F STATE | tail -n 1 | sed 's/ //g'`
|
||||
|
||||
if [ "#$STATE#" == "#STOPPED#" ] ; then
|
||||
#nothing running
|
||||
echo "false"
|
||||
else
|
||||
#container is running
|
||||
if [ "`mount | grep "$1"`" != "" ] ; then
|
||||
#ther is smething mounted
|
||||
echo "true"
|
||||
else
|
||||
#nothing mounted
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
|
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
|
||||
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
||||
|
||||
#check_config
|
||||
function check_config() {
|
||||
#config_check
|
||||
function config_check() {
|
||||
|
||||
#Project
|
||||
[ -f "<LIBDIR>/proj/$project" ] || {
|
||||
@ -24,7 +24,7 @@ function check_config() {
|
||||
echo 'iso_source -> squashfs'
|
||||
else
|
||||
# ERROR
|
||||
echo "No corect AIM in Settings"
|
||||
echo "Settings: No corect AIM"
|
||||
return 3
|
||||
fi
|
||||
fi
|
||||
@ -32,14 +32,14 @@ function check_config() {
|
||||
if [ -f "$squashfs_path" ]; then
|
||||
if [ -n "$iso_aim" ]; then
|
||||
# ERROR
|
||||
echo "only Squashfs source in Settings, cant creat ISO"
|
||||
echo "Settings: only Squashfs source in Settings, cant creat ISO"
|
||||
return 3
|
||||
else
|
||||
echo 'squashfs -> squashfs'
|
||||
fi
|
||||
else
|
||||
# ERROR
|
||||
echo "No corect Source in Settings"
|
||||
echo "Settings: No corect Source"
|
||||
return 3
|
||||
fi
|
||||
fi
|
||||
@ -51,5 +51,5 @@ function check_config() {
|
||||
|
||||
#this func is standalone executable
|
||||
[ -n "$1" ] && {
|
||||
check_config $@
|
||||
config_check $@
|
||||
}
|
@ -10,9 +10,6 @@ function workspace_erase() {
|
||||
[ -d "$dir" ] && rm -r -f "$dir"
|
||||
done
|
||||
|
||||
#lxc
|
||||
[ -d /var/lib/lxc/_remaster_/ ] && rm -R /var/lib/lxc/_remaster_/
|
||||
|
||||
echo "done"
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,12 @@
|
||||
##### B a s e ####
|
||||
##################
|
||||
# .
|
||||
|
||||
# Enviroment
|
||||
project_relation=""
|
||||
[ -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]
|
||||
function tools_add() {
|
||||
|
@ -261,22 +261,3 @@ function project_mods-desinfect.17() {
|
||||
}
|
||||
}
|
||||
function project_mods() { project_mods-desinfect.17 $@; }
|
||||
|
||||
function chroot_initial-desinfect2017() {
|
||||
#$1 = chroot dir
|
||||
|
||||
<LIBDIR>/func/chroot_initial "$1"
|
||||
|
||||
#LXC Start
|
||||
config="/var/lib/lxc/_remaster_/config"
|
||||
|
||||
#special conf for distros:
|
||||
echo "lxc.include = /usr/share/lxc/config/nesting.conf" > $config
|
||||
echo "lxc.include = /usr/share/lxc/config/ubuntu.common.conf" >> $config
|
||||
echo "lxc.arch = x86_64" >> $config
|
||||
|
||||
#normal config
|
||||
chroot_config "$chroot_dir" >> $config
|
||||
#LXC End
|
||||
}
|
||||
function chroot_initial() { chroot_initial-desinfect.17 $@; }
|
||||
|
155
src/remaster.sh
155
src/remaster.sh
@ -5,7 +5,7 @@
|
||||
#@licence GNUv3
|
||||
|
||||
#####################################################################################
|
||||
################## S e t t i n g s ##################################################
|
||||
################## F u n c t i o n s ################################################
|
||||
#####################################################################################
|
||||
|
||||
#set functions
|
||||
@ -14,44 +14,6 @@
|
||||
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]
|
||||
source <LIBDIR>/func/on_exit
|
||||
|
||||
@ -96,9 +58,6 @@ source <LIBDIR>/func/iso_create
|
||||
|
||||
### chroot ###
|
||||
|
||||
## overload chroot with lxc
|
||||
source <LIBDIR>/func/chroot
|
||||
|
||||
#chroot_initial [chroot_dir]
|
||||
source <LIBDIR>/func/chroot_initial
|
||||
|
||||
@ -115,64 +74,78 @@ source <LIBDIR>/func/chroot_is_mounted
|
||||
#chroot_sh [chroot_dir] [command]
|
||||
source <LIBDIR>/func/chroot_sh
|
||||
|
||||
####################################
|
||||
### Workaround - set Project
|
||||
source <LIBDIR>/proj/desinfect.17
|
||||
####################################
|
||||
### config ###
|
||||
|
||||
#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 ... #######################
|
||||
###########################################################
|
||||
|
||||
#Start LOG
|
||||
### Start LOG ###
|
||||
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`"
|
||||
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 "chroot_path=\"$chroot_path\"" >> "$log_file"
|
||||
#env >> "$log_file"
|
||||
echo $'\n\n' >> "$log_file"
|
||||
|
||||
echo $'### R U N ... ###\n' >> "$log_file"
|
||||
echo "HOST: `hostname`" >> "$log_file"
|
||||
|
||||
#1. Set and Check Enviroment
|
||||
check_user >> "$log_file"
|
||||
@ -181,11 +154,15 @@ error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_fil
|
||||
check_dependency >> "$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"
|
||||
|
||||
check_update >> "$log_file"
|
||||
|
||||
|
||||
### R U N ... ###
|
||||
echo $'### R U N ... ###\n' >> "$log_file"
|
||||
|
||||
# 2. Entpacke ISO
|
||||
iso_extract "$iso_source" "$iso_extr_dir" >> "$log_file"
|
||||
|
||||
|
Reference in New Issue
Block a user