Compare commits

..

8 Commits

Author SHA1 Message Date
6543 715c783e62 gen config env from jobfile 2018-06-04 03:28:34 +02:00
6543 d63343865c set var the right way 2018-06-02 23:09:05 +02:00
6543 888f626d4f aktuel. version 2018-06-02 22:50:47 +02:00
6543 ef395c4443 error message tells error source 2018-06-02 08:09:49 +02:00
6543 3b3c588dcc rename func 2018-06-01 23:44:39 +02:00
6543 495bbb5f4a dont exec config, parse it 2018-06-01 01:52:11 +02:00
6543 5df896a47e commit 2018-05-31 20:23:11 +02:00
6543 10f06bc421 idee ... 2018-05-31 20:17:42 +02:00
20 changed files with 714 additions and 213 deletions

View File

@ -1,6 +1,6 @@
Package: remaster
Source: remaster
Version: 2.1.0
Version: 2.0.4
Architecture: all
Maintainer: 6543 <6543@obermui.de>
Installed-Size: <SIZE>

View File

@ -1,10 +1,6 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https://code.obermui.de/api/v1/repos/6543/remaster/releases&query=$[0].tag_name)](https://code.obermui.de/6543/remaster/releases)
[![PGP Sig](https://img.shields.io/keybase/pgp/6543)](https://mh.obermui.de/publickey.gpg)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2F6543%2Fremaster.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2F6543%2Fremaster?ref=badge_shield)

# remaster


## Description

The aim of this Project is to create a daemon for a server, witch update live systems. You should only have to install the modules for different OS/Live-Projects. It also set the right network settings (Proxy, DNS, ...) and will be extendible wit PXE menu. additional: Web Interface (Create/Change/Delete Jobs; Download Latest ISO; Start/Stop PXE Server)

View File

@ -30,13 +30,3 @@
* restructure code
* use proj templates
* some help scripts

2019-09-20 - 2.1.0
* fixes
- filesystem_extract: filesystem_get_type
- update dev scripts
- work without arguments
* check_update: acuret message
* restruct sample config
* add "Help & Info" menue/section (#24) (#20)
* --config | custom config (#25)

View File

@ -1,13 +1,13 @@
Erorrs:
Erorr Liste:

ID: Description
----------------------------------------------------
1 general error
2 no paramters / wrong parameters
3 wrong settings
4 programm missing
1 Allgemeiner Fehler
2 No Paramters / wrong parameters
3 Wrong Settings!
4 Programm missing

10 need root permission
10 no root
11 file no found
12 dir not found
13 cant create/delete file/dir

BIN
doc/Server Bedienung.odt Normal file

Binary file not shown.

BIN
doc/Server Bedienung.pdf Normal file

Binary file not shown.

View File

@ -1,38 +1,40 @@
## 1.1 Load base functions [-> #functions]
# 1. Starte "remaster"

## 1.2 Check ...
* for updates
* for rights
## 1.1 Lade Grundfunctionen [-> #functions]

## 1.3 Load settings [-> #config]
* lade /etc/remaster/<Conf>
* verify config (Proj Exist; Mods Exist; ...)
## 1.2 Überprüfe ...
* auf Updates
* auf Rechte

## 1.4 Load Proj-Func [-> #projects]
* overload based on dependencys
## 1.3 Lade Richtige Einstellungen [-> #config]
* Lade /etc/remaster/<Conf>
* Überprüfe Conf. (Proj Exist; Mods Exist; ...)

## 1.4 Lade Proj-Func [-> #projects]
* Überlade nach Abhängigkeit
* (z.B. ubuntu.16.04 -> ubuntu -> debian)
* verify config (Proj Conform)
* Prüfe Conf. (Proj Conform)

## 1.5 Load $n Mods (optional) [-> #mods]
* check
* save in MOD_LST
## 1.5 Lade $n Mods (optional) [-> #mods]
* Überprüfen
* Spechern in MOD_LST

# 2. Init Chroot

## 2.1 Extrackt Files
## 2.1 Dateien Entpacken
* ISO
* Squashfs

## 2.2 Config for Chroot (chroot_initial)
## 2.2 Config für Chroot (chroot_initial)
* (lxc-conf / tmpdir)
* network
* Netzwerk

## 2.3 Start Chroot
## 2.3 Starte Chroot
* (lxc-start / mount ...)

# 3. Modivikationen

## 3.1 Network
## 3.1 Netzwerk

## 3.2 Proj-Spez.
* (z.B. Desinfect: conky_info)
@ -42,22 +44,22 @@
* Install
* Delete

## 3.4 Next in $MOD_LST
## 3.4 Weitere in $MOD_LST
* z.B. xrdp
* z.B. default pw

# 4. Finish

## 4.1 Clean-Up Live-System
## 4.1 Aufreumen Live-Sys
* tmpfiles
* Packet Mgr

## 4.2 Stop chroot
* Umount

## 4.3. Generate ISO/PXE
## 4.3. Gen ISO/PXE

## 4.4. Delete Chroot
## 4.4. Del Chroot

# 5. Send Log

19
doc/draft_mod-pronects Normal file
View File

@ -0,0 +1,19 @@
maddl@NB-Maddl:~$ function a() { echo null; }
maddl@NB-Maddl:~$ a
null
maddl@NB-Maddl:~$ function a_desinfect() { echo desinfect; }
maddl@NB-Maddl:~$ a_desinfect
desinfect
maddl@NB-Maddl:~$ alias a=a_desinfect
maddl@NB-Maddl:~$ a
desinfect
maddl@NB-Maddl:~$ alias --help
bash: alias: --: Ungültige Option
alias: Gebrauch: alias [-p] [Name[=Wert] ... ]
maddl@NB-Maddl:~$ man alias
Kein Handbucheintrag für alias vorhanden
maddl@NB-Maddl:~$ alias a=a
maddl@NB-Maddl:~$ a
null
maddl@NB-Maddl:~$

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

@ -9,17 +9,16 @@ date=`date +%Y-%m-%d`

#nummer
sed -i "/#@version\ /c\#@version\ $version_sed" src/remaster.sh
sed -i "/echo\ Remaster\ /c\ \ \ \ \ \ \ \ \ \ echo\ Remaster\ $version_sed" src/remaster.sh

#datum
sed -i "/#@date\ /c\#@date\ $date" src/remaster.sh
}

[ -e "Changelog.md" ] && {
[ -e "changes/remaster.md" ] && {

echo >> Changelog.md
echo $date - $version >> Changelog.md
$EDITOR Changelog.md
echo >> changes/remaster.md
echo $date - $version >> changes/remaster.md
editor changes/remaster.md
}

[ -f "DEBIAN/control" ] && {

View File

@ -11,8 +11,8 @@ iso_source="/data/local/Desinfect_Remaster/tmp/desinfect-2017.iso"
# squashfs_path="/data/local/Desinfect_Remaster/tmp/filesystem.squashfs"

## Ziel, Lable der zu erstellenden CD/DVD
iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_`date '+%Y-%m-%d'`.iso"
iso_lable="DESINFECT_`date '+%Y-%m-%d'`"
iso_aim="/data/local/Desinfect_Remaster/tmp/custom_desinfect_<date>.iso"
iso_lable="DESINFECT_<date>"


## Netzwerk Sinstellungen
@ -28,7 +28,7 @@ project="desinfect.17"

## LOG Einstellungen
## 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
# log_mail_source="desinfect@email.clocal"
# log_mail_smtp="smtp.mail.local:25"

View File

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

#check_config
function clear_config() {

## Source & Aim options
iso_source=
squashfs_path=
iso_aim=
iso_lable=

## network
proxy_host=
proxy_port=
domain=
nameserver=

## Project / Distro
project=

## LOG Settings
log_file=
log_mail_source=
log_mail_smtp=
log_mail_aim=
log_mail_subject=

}

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

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

View File

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

227
src/proj/desinfect.15 Executable file
View File

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

#desinfect.15
# . -Y ubuntu.14.04 -> ubuntu -> debian
source <LIBDIR>/proj/ubuntu.14.04
project_relation="desinfect.15 $project_relation"



#iso_create-desinfect.15 [chroot_path] [iso_extr_dir] [iso_aim] [iso_lable]
function iso_create-desinfect.15() {
echo "prepere iso folder ... "

chroot_path="$1"
iso_extr_dir="$2"
iso_aim="$3"
iso_lable="$4"

#desinfect
rm "$iso_extr_dir/casper/initrd.lz"
wget http://www.heise.de/ct/projekte/desinfect/des15/initrd.lz -O "$iso_extr_dir/casper/initrd.lz"

echo "done"

iso_create-debian "$chroot_path" "$iso_extr_dir" "$iso_aim" "$iso_lable"
}
function iso_create() { iso_create-desinfect.15 $@; }

#chroot_initial-desinfect.15 [chroot_dir]
function chroot_initial-desinfect.15() {
#$1 = chroot dir

chroot_initial-debian "$1"

echo -n "initial desinfect on chroot ... "

#check chroot dir
chroot_dir="$1"
[ -d "$chroot_dir" ] || {
echo "### ERROR ### chroot_initial_desinfect: chroot directory not exist!"
return 12
}

#mount virus definitions
#bitdefender
mount --bind $chroot_dir/opt/BitDefender-scanner/var/lib/scan{.orig,}
mount --bind $chroot_dir/var/kl/bases_rd{.orig,}

echo "done"
}
function iso_create() { iso_create-desinfect.15 $@; }

#chroot_umount-desinfect.15 [chroot_dir]
function chroot_umount-desinfect.15() {
#call main mount
chroot_umount-debian "$1"

echo -n "unmount desinfect on chroot ... "
#check chroot dir
chroot_dir="$1"
[ -d "$chroot_dir" ] || {
echo "### ERROR ### chroot_umount_desinfect: chroot directory not exist!"
return 12
}

for d in "$chroot_dir/opt/BitDefender-scanner/var/lib/scan" "$chroot_dir/var/kl/bases_rd" ; do
umount $d
retval=$?
[ "$retval" -gt 0 ] && {
echo "### ERROR ### chroot_umount_desinfect: can't umount \"$d\"!"
return 21
}
done

echo "done"
}
function chroot_umount() { chroot_umount-desinfect.15 $@; }

#proxy_enable-desinfect.15 [chroot_dir] [proxy_host] [proxy_port]
function proxy_enable-desinfect.15() {

proxy_enable-debian $1 $2 $3

echo -n "enable proxy for desinfect's av ... "

chroot_dir="$1"
proxy_host="$2"
proxy_port="$3"

#Avast AntiVirus
sed -i "s/--skip-master-file/--skip-master-file --proxy-host=$proxy_host --proxy-port=$proxy_port/g" "$chroot_dir/AntiVirUpdate/avupdate"
sed -i "s/--proxy-host=$proxy_host --proxy-port=$proxy_port --proxy-host=$proxy_host --proxy-port=$proxy_port/--proxy-host=$proxy_host --proxy-port=$proxy_port/g" "$chroot_dir/AntiVirUpdate/avupdate"

#BitDefender
echo "ProxyEnable = Yes" >> "$chroot_dir/etc/BitDefender-scanner/bdscan.conf"
echo "ProxyHost = $proxy_host:$proxy_port" >> "$chroot_dir/etc/BitDefender-scanner/bdscan.conf"

#Clam AV
echo "HTTPProxyServer $proxy_host" >> "$chroot_dir/etc/clamav/freshclam.conf"
echo "HTTPProxyPort $proxy_port" >> "$chroot_dir/etc/clamav/freshclam.conf"

#Kaspersky
sed -i "s/<tDWORD name=\"UseProxy\">0<\/tDWORD>/<tDWORD name=\"UseProxy\">1<\/tDWORD>/g" "$chroot_dir/etc/kl/config.xml"
sed -i "s/<tSTRING name=\"ProxyHost\"><\/tSTRING>/<tSTRING name=\"ProxyHost\">$proxy_host<\/tSTRING>/g" "$chroot_dir/etc/kl/config.xml"
sed -i "s/<tDWORD name=\"ProxyPort\"><\/tDWORD>/<tDWORD name=\"ProxyPort\">$proxy_port<\/tDWORD>/g" "$chroot_dir/etc/kl/config.xml"

echo "done"
}
function proxy_enable() { proxy_enable-desinfect.15 $@; }

#sourcelist_desinfect_set_nomal2015 [chroot_dir]
function sourcelist_desinfect_set_nomal2015() {
echo -n "build normal source.list ... "
#$1 = chroot directory

sourcelist="$1/etc/apt/sources.list"


echo "#### Desinfe't 2015 ####" > "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://www.heise.de/ct/projekte/desinfect/ubuntu 2015 main" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "# #### Ubuntu 14.04 (trusty) ####" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# ## This software is not part of Ubuntu, but is offered by third-party" >> "$sourcelist"
echo "# ## developers who want to ship their latest software." >> "$sourcelist"
echo "# deb http://extras.ubuntu.com/ubuntu trusty main" >> "$sourcelist"

echo "done"
}

#sourcelist_desinfect_set_extendet2015 [chroot_dir]
function sourcelist_desinfect_set_extendet2015() {
echo -n "build extendet source.list ... "

sourcelist="$1/etc/apt/sources.list"


echo "#### Desinfe't 2015 ####" > "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://www.heise.de/ct/projekte/desinfect/ubuntu 2015 main" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "#### Ubuntu 14.04 (trusty) ####" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "## This software is not part of Ubuntu, but is offered by third-party" >> "$sourcelist"
echo "## developers who want to ship their latest software." >> "$sourcelist"
echo "deb http://extras.ubuntu.com/ubuntu trusty main" >> "$sourcelist"

echo "done"
}

#os_update-desinfect.15 [chroot_dir]
function os_update-desinfect.15() {
#$1 = chroot directory

chroot_dir="$1"

#call main os_update
os_update-debian "$chroot_dir"

echo "update virus definitions ... "

#BitDefender
chroot "$chroot_dir" /bin/bash -c "bdscan --update" | grep -v "... updated"

#Avast Avira
chroot "$chroot_dir" /bin/bash -c "/AntiVirUpdate/avupdate" | grep -v " -> "

#Clam AV
chroot "$chroot_dir" /bin/bash -c "freshclam" > /dev/null
rm -f "$chroot_dir/var/lib/clamav/daily.cld"

#Karspersky
echo '#!/bin/bash' > "$chroot_dir/tmp/up_kasp"
echo 'PATH=/usr/lib/kl:$PATH' >> "$chroot_dir/tmp/up_kasp"
echo 'LD_LIBRARY_PATH=/usr/lib/kl:$LD_LIBRARY_PATH' >> "$chroot_dir/tmp/up_kasp"
echo 'KL_PLUGINS_PATH=/usr/lib/kl' >> "$chroot_dir/tmp/up_kasp"
echo 'export PATH LD_LIBRARY_PATH KL_PLUGINS_PATH' >> "$chroot_dir/tmp/up_kasp"
echo '/usr/lib/kl/kav update' >> "$chroot_dir/tmp/up_kasp"
chmod +x "$chroot_dir/tmp/up_kasp"
chroot "$chroot_dir" /bin/bash -c "/tmp/up_kasp" | grep -v ".kdc" | grep -v "File downloaded"
rm "$chroot_dir/tmp/up_kasp"


echo "done"
}
function os_update() { os_update-desinfect.15 $@; }

#tools_add-desinfect.15 [chroot_dir] [tools_list]
function tools_add-desinfect.15() {
#$1 = chroot directory
chroot_dir="$1"
tools_list="$2"

sourcelist_desinfect_set_extendet2015 "$chroot_dir"
tools_add-debian "$chroot_dir" "$tools_list"
sourcelist_desinfect_set_nomal2015 "$chroot_dir"
}
function tools_add() { tools_add-desinfect.15 $@; }

262
src/proj/desinfect.16 Executable file
View File

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

#desinfect.16
# . -Y ubuntu.14.04 -> ubuntu -> debian
source <LIBDIR>/proj/ubuntu.14.04
project_relation="desinfect.16 $project_relation"


#chroot_initial-desinfect.16 [chroot_dir]
function chroot_initial-desinfect.16() {
#$1 = chroot dir

chroot_initial-debian "$1"

echo -n "initial desinfect on chroot ... "

#check chroot dir
chroot_dir="$1"
[ -d "$chroot_dir" ] || {
echo "### ERROR ### chroot_initial_desinfect: chroot directory not exist!"
return 12
}

#mount virus definitions
mount --bind $chroot_dir/var/kl/bases_rd{.orig,}

echo "done"
}
function chroot_initial() { chroot_initial-desinfect.16 $@; }

#chroot_umount-desinfect.16 [chroot_dir]
function chroot_umount-desinfect.16() {
#call main mount
chroot_umount-debian "$1"

echo -n "unmount desinfect on chroot ... "
#check chroot dir
chroot_dir="$1"
[ -d "$chroot_dir" ] || {
echo "### ERROR ### chroot_umount_desinfect: chroot directory not exist!"
return 12
}

umount "$chroot_dir/var/kl/bases_rd"
[ "$?" -gt 0 ] && {
echo "### ERROR ### chroot_umount_desinfect: can't umount \"$chroot_dir/var/kl/bases_rd\"!"
#return 21
}

echo "done"
}
function chroot_umount() { chroot_umount-desinfect.16 $@; }

#proxy_enable-desinfect.16 [chroot_dir] [proxy_host] [proxy_port]
function proxy_enable-desinfect.16() {

proxy_enable-debian $1 $2 $3

echo -n "enable proxy for desinfect's av ... "

chroot_dir="$1"
proxy_host="$2"
proxy_port="$3"
tmp_file_344532="`mktemp`"

#Avast AntiVirus
sed -i "s/--skip-master-file/--skip-master-file --proxy-host=$proxy_host --proxy-port=$proxy_port/g" "$chroot_dir/AntiVirUpdate/avupdate"
sed -i "s/--proxy-host=$proxy_host --proxy-port=$proxy_port --proxy-host=$proxy_host --proxy-port=$proxy_port/--proxy-host=$proxy_host --proxy-port=$proxy_port/g" "$chroot_dir/AntiVirUpdate/avupdate"

#Clam AV
cat "$chroot_dir/etc/clamav/freshclam.conf" | grep -v "HTTPProxyServer" | grep -v "HTTPProxyPort" > "$tmp_file_344532"
rm "$chroot_dir/etc/clamav/freshclam.conf"
cp "$tmp_file_344532" "$chroot_dir/etc/clamav/freshclam.conf"

echo "HTTPProxyServer $proxy_host" >> "$chroot_dir/etc/clamav/freshclam.conf"
echo "HTTPProxyPort $proxy_port" >> "$chroot_dir/etc/clamav/freshclam.conf"

#Eset AV
cat "$chroot_dir/etc/opt/eset/esets/esets.cfg" | grep -v "proxy_addr" | grep -v "proxy_port" > "$tmp_file_344532"
rm "$chroot_dir/etc/opt/eset/esets/esets.cfg"
cp "$tmp_file_344532" "$chroot_dir/etc/opt/eset/esets/esets.cfg"

echo "proxy_addr = \"$proxy_host\"" >> "$chroot_dir/etc/opt/eset/esets/esets.cfg"
echo "proxy_port = $proxy_port" >> "$chroot_dir/etc/opt/eset/esets/esets.cfg"

#Kaspersky
sed -i "s/<tDWORD name=\"UseProxy\">0<\/tDWORD>/<tDWORD name=\"UseProxy\">1<\/tDWORD>/g" "$chroot_dir/etc/kl/config.xml"
sed -i "s/<tSTRING name=\"ProxyHost\"><\/tSTRING>/<tSTRING name=\"ProxyHost\">$proxy_host<\/tSTRING>/g" "$chroot_dir/etc/kl/config.xml"
sed -i "s/<tDWORD name=\"ProxyPort\"><\/tDWORD>/<tDWORD name=\"ProxyPort\">$proxy_port<\/tDWORD>/g" "$chroot_dir/etc/kl/config.xml"

rm "$tmp_file_344532"
tmp_file_344532=

echo "done"
}
function proxy_enable() { proxy_enable-desinfect.16 $@; }

#sourcelist_desinfect_set_nomal2016 [chroot_dir]
function sourcelist_desinfect_set_nomal2016() {
echo -n "build normal source.list ... "
#$1 = chroot directory

sourcelist="$1/etc/apt/sources.list"


echo "#### Desinfe't 2016 ####" > "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://www.heise.de/ct/projekte/desinfect/ubuntu 2016 main" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "# #### Ubuntu 14.04 (trusty) ####" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# deb http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "# deb-src http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "#" >> "$sourcelist"
echo "# ## This software is not part of Ubuntu, but is offered by third-party" >> "$sourcelist"
echo "# ## developers who want to ship their latest software." >> "$sourcelist"
echo "# deb http://extras.ubuntu.com/ubuntu trusty main" >> "$sourcelist"

echo "done"
}

#sourcelist_desinfect_set_extendet2016 [chroot_dir]
function sourcelist_desinfect_set_extendet2016() {
echo -n "build extendet source.list ... "

sourcelist="$1/etc/apt/sources.list"


echo "#### Desinfe't 2016 ####" > "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://www.heise.de/ct/projekte/desinfect/ubuntu 2016 main" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "#### Ubuntu 14.04 (trusty) ####" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-security main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "deb http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "deb-src http://de.archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" >> "$sourcelist"
echo "" >> "$sourcelist"
echo "## This software is not part of Ubuntu, but is offered by third-party" >> "$sourcelist"
echo "## developers who want to ship their latest software." >> "$sourcelist"
echo "deb http://extras.ubuntu.com/ubuntu trusty main" >> "$sourcelist"

echo "done"
}

#os_update-desinfect.16 [chroot_dir]
function os_update-desinfect.16() {
#$1 = chroot directory

chroot_dir="$1"

#call main os_update
os_update-debian "$chroot_dir"

echo "update virus definitions ... "

#Avast Avira
{
echo "Avira ..."
chroot "$chroot_dir" /bin/bash -c "/AntiVirUpdate/avupdate" | grep -v " -> "
echo "Avira done"
}

#Clam AV
{
echo "ClamAV..."
chroot "$chroot_dir" /bin/bash -c "freshclam" > /dev/null
rm -f "$chroot_dir/var/lib/clamav/daily.cld"
echo "ClamAV done"
}

#Eset AV
{
echo "Eset AV ..."
tmp_file_23421="`mktemp`"
cat "$chroot_dir/etc/opt/eset/esets/esets.cfg" | grep -v "av_update_username" | grep -v "av_update_password" > "$tmp_file_23421"
cat "$tmp_file_23421" > "$chroot_dir/etc/opt/eset/esets/esets.cfg"
chroot "$chroot_dir" /bin/bash -c "/usr/bin/esetrand" >> "$chroot_dir/etc/opt/eset/esets/esets.cfg"

echo "set timeout: 2min"
av_eaet_timeout=1200
tmp_var_3092="`chroot "$chroot_dir" /bin/bash -c "/opt/desinfect/conky_info.sh eset"`"

#eig. update routine
chroot "$chroot_dir" /bin/bash -c "/etc/init.d/esets restart"
sleep 2
chroot "$chroot_dir" /bin/bash -c "/opt/eset/esets/sbin/esets_daemon --update"

#warten auf daemon update ...
sleep 10m
echo "wait 10min for Eset AV update"
while [ "`chroot "$chroot_dir" /bin/bash -c "/opt/desinfect/conky_info.sh eset"`" == "$tmp_var_3092" ]; do
sleep 1
av_eaet_timeout=$((av_eaet_timeout-1))
[ $av_eaet_timeout -gt 0 ] || tmp_var_3092=
done

sleep 4

chroot "$chroot_dir" /bin/bash -c "/etc/init.d/esets stop"

cat "$tmp_file_23421" > "$chroot_dir/etc/opt/eset/esets/esets.cfg"

rm "$tmp_file_23421"
tmp_file_23421=
tmp_var_3092=
echo "Eset AV done"
}

#Karspersky
{
echo "Karspersky ..."
#gen update-scrypt
echo '#!/bin/bash' > "$chroot_dir/tmp/up_kasp"
echo 'PATH=/usr/lib/kl:$PATH' >> "$chroot_dir/tmp/up_kasp"
echo 'LD_LIBRARY_PATH=/usr/lib/kl:$LD_LIBRARY_PATH' >> "$chroot_dir/tmp/up_kasp"
echo 'KL_PLUGINS_PATH=/usr/lib/kl' >> "$chroot_dir/tmp/up_kasp"
echo 'export PATH LD_LIBRARY_PATH KL_PLUGINS_PATH' >> "$chroot_dir/tmp/up_kasp"
echo '/usr/lib/kl/kav update' >> "$chroot_dir/tmp/up_kasp"
chmod +x "$chroot_dir/tmp/up_kasp"

chroot "$chroot_dir" /bin/bash -c "/tmp/up_kasp" | grep -v ".kdc" | grep -v "File downloaded"
rm "$chroot_dir/tmp/up_kasp"
echo "Karspersky done"
}

echo "update virus definitions done"
}
function os_update() { os_update-desinfect.16 $@; }

#tools_add-desinfect.16 [chroot_dir] [tools_list]
function tools_add-desinfect.16() {
#$1 = chroot directory
chroot_dir="$1"
tools_list="$2"

sourcelist_desinfect_set_extendet2016 "$chroot_dir"
tools_add-debian "$chroot_dir" "$tools_list"
sourcelist_desinfect_set_nomal2016 "$chroot_dir"
}
function tools_add() { tools_add-desinfect.16 $@; }

View File

@ -1,11 +1,11 @@
#!/bin/bash
#@version 2.1.0
#@version 2.0.4
#@autor 6543@obermui.de
#@date 2019-09-20
#@date 2018-05-22
#@licence GNUv3

#####################################################################################
################## S e t t i n g s ##################################################
################## F u n c t i o n s ################################################
#####################################################################################

#set functions
@ -14,76 +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
}

#####################################################################################
################## H e l p & I n f o ##############################################
#####################################################################################


case $(echo $1 | tr -d '-') in
'') ;;
version|V)
echo Remaster 2.1.0
exit 0
;;
config|c)
if [ -f "$2" ]; then
source <LIBDIR>/func/clear_config
source "$2"
else
echo "ERROR Config \"$2\" not found"
exit 1
fi
else
;;
*)
echo 'Remaster update Live Systems'
echo ' more information at: https://github.com/6543/remaster/'
echo ''
echo ' --version|-V show current version'
echo ' --config|-c <config> run remaster with custom config'
exit 0
;;
esac


#####################################################################################
################## 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

@ -144,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"
@ -210,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"