Merge branch 'release-2.0.0'

This commit is contained in:
6543 2018-05-12 23:06:43 +02:00
commit c9116e1cfd
38 changed files with 1757 additions and 1269 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/build /build
/release

1
DEBIAN/conffiles Normal file
View File

@ -0,0 +1 @@
/etc/remaster/config.sample.cfg

12
DEBIAN/control Normal file
View File

@ -0,0 +1,12 @@
Package: remaster
Source: remaster
Version: 2.0.0
Architecture: all
Maintainer: 6543 <6543@obermui.de>
Installed-Size: <SIZE>
Depends: squashfs-tools, xorriso, wget, sed (>= 4.2), sendemail, bash (>= 4.3)
Suggests: nfs-kernel-server, isc-dhcp-server
Section: utils
Priority: optional
Homepage: https://github.com/6543/remaster
Description: The aim of this Project is to create a daemon for a server, witch update live systems.

1
DEBIAN/postinst Executable file
View File

@ -0,0 +1 @@
#!/bin/sh

1
DEBIAN/postrm Executable file
View File

@ -0,0 +1 @@
#!/bin/sh

1
DEBIAN/preinst Executable file
View File

@ -0,0 +1 @@
#!/bin/sh

1
DEBIAN/prerm Executable file
View File

@ -0,0 +1 @@
#!/bin/sh

View File

@ -1,23 +1,31 @@
# remaster # remaster


in restructure at the moment ...


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


# To-do 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)
* general structure
* split into modules
* more OS
* make it more flexible
* ... (look at issues)


# At the Moment ## Dependencys
* Ubuntu/Debian
* Desinfect17 - squashfs-tools
* no config file (all settings in script header) - xorriso
- wget
- sed
- sendemail

## To Do

- Support more Projects

- Debian
- Ubuntu
- Desinfect17
- CentOS

- Add Job-Scheduler

## At the Moment

- Ubuntu/Debian
- Desinfect17
- one config file

130
autogen.sh Executable file
View File

@ -0,0 +1,130 @@
#!/bin/bash
# install | clean | debug | build-deb

function clean() {
echo "clear build"
[ -d build ] && rm -v -R build
mkdir build
}
function copy() {
echo "copy files ..."
# remaster
mkdir -p build/usr/bin/
cp -v src/remaster.sh build/usr/bin/remaster
chmod +x build/usr/bin/remaster

# modules
mkdir -p build/usr/lib/remaster/
for i in proj func mods; do
mkdir -p build/usr/lib/remaster/$i
cp -v src/$i/* build/usr/lib/remaster/$i/
done

# setting
mkdir -p build/etc/remaster/
cp -v src/config.sample.cfg build/etc/remaster/config.sample.cfg

#changelog
mkdir -p build/usr/share/doc/remaster
cp -v changes/remaster.md build/usr/share/doc/remaster/changelog
gzip --best build/usr/share/doc/remaster/changelog
}

#config ...
function set_rootdir() {
sed -i "s#<ROOTDIR>#$1#g" build/usr/bin/remaster
for i in proj func mods; do
sed -i "s#<ROOTDIR>#$1#g" build/usr/lib/remaster/$i/*
done
}
function set_libdir() {
sed -i "s#<LIBDIR>#$1#g" build/usr/bin/remaster
for i in proj func mods; do
sed -i "s#<LIBDIR>#$1#g" build/usr/lib/remaster/$i/*
done
}

#modes
function debug() {
clean

#prebuild
copy
set_rootdir "`pwd`/build"
set_libdir "`pwd`/build/usr/lib/remaster"
}
function install() {
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }

#lösche alltes build dir
clean

#prebuild
copy
set_rootdir ""
set_libdir "/usr/lib/remaster"

#set owner
chown -r root:root build/

#install
cp -f -r build/* /
}
function build-deb() {
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }

#lösche alltes build dir
clean

#prebuild
copy
set_rootdir ""
set_libdir "/usr/lib/remaster"
####
## changes for deb file
####
cp -v -r -f DEBIAN build/
#create md5sums
find ./build -type f -exec md5sum {} \; | grep -v './build/DEBIAN' | sed 's/\.\/build\///g' > build/DEBIAN/md5sums
chmod 0644 build/DEBIAN/md5sums

#set size
SIZE="`du --exclude=build/DEBIAN -c build/ | cut -f 1 | tail -n 1`"
sed -i "s/<SIZE>/$SIZE/g" build/DEBIAN/control

#set owner
chown -r root:root build/

##
#build deb
##
dpkg -b build/
version="`cat build/DEBIAN/control | grep Version | cut -d " " -f 2`"
arch="`cat build/DEBIAN/control | grep Arch | cut -d " " -f 2`"
[ -f "release/remaster_"$version"_"$arch".deb" ] && rm "release/remaster_"$version"_"$arch".deb"
mv -v "build.deb" "release/remaster_"$version"_"$arch".deb"
}


case "$1" in
install)
install || exit 1
;;
clean)
clean || exit 1
;;
debug)
debug || exit 1
;;
copy)
copy || exit 1
;;
build-deb)
build-deb || exit 1
;;
*)
echo "Usage: install | clean | debug | build-deb"
exit 1
esac

15
changes/remaster.md Normal file
View File

@ -0,0 +1,15 @@
2018-04-26 - 1.9.1
* seperate script and config

2018-05-10 - 1.9.2
* exec singel func

2018-05-10 - 1.9.3
* hotfix-1.9.3

2018-05-12 - 2.0.0
* add feature build debian packages
* add Doc "Server Bedienung"
* split functions
* seperte config into /etc/remaster/

28
doc/Strukture.md Normal file
View File

@ -0,0 +1,28 @@
# Src

raw scripts ..

## functions

- creat iso
- burn cd ...
- clean workspace ...


## distros

scripts vor distros
- update
- set network settings
- set OS settings

## mods
- for example: install & enable xrdp
- set default passwd
- ...

## web
placeholder for webfiles ...

## pxe
placeholder for pxefiles ...

12
doc/buid_vars.md Normal file
View File

@ -0,0 +1,12 @@
variablen, welche um zu funktionieren mit statischen pfaden
ausgetauscht werden müssen:

remaster.sh
* <ROOTDIR>
-(install)> ""
-(debug)> 'pwd'/build

remaster.sh; <LIBDIR>/*/*;
* <LIBDIR>
-(install)> /usr/lib/remaster
-(debug)> 'pwd'/build/usr/lib/remaster

5
doc/lib-header.txt Normal file
View File

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

#beginn func

26
script/set_version.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash

version=$1
date=`date +%Y-%m-%d`

[ -e "src/remaster.sh" ] && {

version_sed=`echo $version | sed 's/\./\\./g'`

#nummer
sed -i "s/@version\ .\..\../@version\ $version_sed/g" src/remaster.sh

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

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

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

[ -f "DEBIAN/control" ] && {
sed -i "s/Version:\ .\..\../Version:\ $version_sed/g" "DEBIAN/control"
}

39
src/config.sample.cfg Normal file
View File

@ -0,0 +1,39 @@
#cfg

#########################################################
## sample-config rename it to config.cfg after changes ##
#########################################################

## MODUS
modus_default="update_pxe"

#CD/DVD
#entweder iso_source oder filesystem_source alls quelle
# -> bei iso gen erforderlich!
iso_source="/data/remaster/desinfect-2017.iso"
#destination optinal
iso_destination="/data/remaster/result/custom_desinfect_`date '+%Y-%m-%d'`.iso"
iso_lable="DESINFECT_`date '+%Y-%m-%d'`"

#Filesystem (for pxe)
#entweder iso_source oder filesystem_source alls quelle
filesystem_source="/data/remaster/result/filesystem.squashfs"

#Network
proxy_host="proxy.local"
proxy_port="8080"
domain="local"
nameserver="10.x.x.2,10.x.x.1"

#remaster_script
distro="desinfect2017"

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

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

20
src/func/check_dependency Executable file
View File

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

#check_dependency
# -> 0 | -> 16
function check_dependency() {
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
}
done
return 0
}

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

17
src/func/check_user Executable file
View File

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

#check_user
function check_user() {
#check root
[ "`whoami`" == "root" ] || {
echo "### ERROR ### Remaster need ROOT permision!"
return 10
}
}

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

22
src/func/chroot_clean Executable file
View File

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

#chroot_clean [chroot_dir]
function chroot_clean() {
echo "clean chroot ... "

chroot_dir="$1"

chroot "$chroot_dir" /bin/bash -c "apt-get clean"
chroot "$chroot_dir" /bin/bash -c "rm -r /var/cache/apt/*"
chroot "$chroot_dir" /bin/bash -c "apt-get update"
chroot "$chroot_dir" /bin/bash -c "apt-get check"

echo "done"
}

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

31
src/func/chroot_initial Executable file
View File

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

#chroot_initial [chroot_dir]
function chroot_initial() {
echo -n "initial chroot ... "

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

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

echo "done"
}

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

22
src/func/chroot_is_mounted Executable file
View File

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

#chroot_is_mounted [chroot_dir]
#(Boolean)-> true | false
function chroot_is_mounted() {
#$1 = chroot directory

if [ "`mount | grep "$1"`" != "" ] ; then
#ther is smething mounted
echo "true"
else
#nothing mounted
echo "false"
fi
}

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

29
src/func/chroot_sh Executable file
View File

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

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

command="$2"

[ -f "$chroot_dir/tmp/env.sh" ] || {
#if not exist create environment skript
cat "$chroot_dir/etc/environment" | grep -v "#" | grep "=" > "$chroot_dir/tmp/env"
while read line; do echo export $line; done < "$chroot_dir/tmp/env" > "$chroot_dir/tmp/env.sh"
chmod +x "$chroot_dir/tmp/env.sh" && rm "$chroot_dir/tmp/env"
}

chroot "$chroot_dir" /bin/bash --login -c ". /tmp/env.sh; $command"
}

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

31
src/func/chroot_umount Executable file
View File

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

#chroot_umount [chroot_dir]
function chroot_umount() {
echo -n "unmount chroot ... "

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

for d in "$chroot_dir/tmp" "$chroot_dir/root" "$chroot_dir/proc" "$chroot_dir/dev" ; do
umount $d
retval=$?
[ "$retval" -gt 0 ] && {
echo "### ERROR ### chroot_umount: can't umount \"$d\"!"
return 21
}
done

echo "done"
}

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

68
src/func/error_code Executable file
View File

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

#error_code [error_level]
function error_code() {
code="$1"
case $code in
"")
echo $'ID:\tDescription\n----------------------------------------------------\n1\tAllgemeiner Fehler\n2\tNo Paramters / wrong parameters'
echo $'3\tWrong Settings\n4\tProgramm missing\n\n10\tno root\n11\tfile no found\n12\tdir not found\n13\tcant create/delete file/dir'
echo $'14\tcorrupt file (unsquashfs, mount iso, ...)\n15\twrong file (iso has no squashfs-file ...)\n16\trequired Packet not found\n\n20\tmount error\n21\tunmoun error\n22\twrong filesystem'
;;
1)
echo "Allgemeiner Fehler"
;;
2)
echo "No Paramters / wrong parameters"
;;
3)
echo "Wrong Settings"
;;
4)
echo "Programm missing"
;;
10)
echo "not executed as Root"
;;
11)
echo "file no found"
;;
12)
echo "dir not found"
;;
13)
echo "cant create/delete file/dir"
;;
14)
echo "corrupt file (unsquashfs, mount iso, ...)"
;;
15)
echo "wrong file (iso has no squashfs-file ...)"
;;
16)
echo "required Packet not found"
;;
20)
echo "tmount error"
;;
21)
echo "unmoun error"
;;
22)
echo "wrong filesystem"
;;
all)
error_code
;;
*)
echo $'No Defined Error Code.\nPerhaps an Error ocure on a Command wich was started by this Skritp.'
;;
esac
}

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

48
src/func/filesystem_extract Executable file
View File

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

#filesystem_extract [filesystem_img_source] [chroot_path]
function filesystem_extract() {
echo "extract filesystem ..."

#$1 = filesystem_img_source
#$2 = chroot_path
filesystem_img_source="$1"
chroot_path="$2"
filesystem_log="`mktemp`"

#Überfrüfen der Parameter
[ -f "$filesystem_img_source" ] || {
echo "### ERROR ### filesystem_extract: squashfs \"$filesystem_img_source\" not exist!"
return 11
}

[ "`mkdir -p "$chroot_path"`" != "" ] && {
echo "### ERROR ### filesystem_extract: chroot_path \"$chroot_path\" can't create!"
return 13
}

[ "`filesystem_get_type $chroot_path`" != "ext4" ] && [ "`filesystem_get_type $chroot_path`" != "btrfs" ] && {
echo "### ERROR ### filesystem_extract: wrong filesystem (`filesystem_get_type $chroot_path`)!"
return 22
}

rm -r "$chroot_path"

#eigendliches entpacken
unsquashfs -d "$chroot_path" "$filesystem_img_source" > "$filesystem_log" || {
echo "### ERROR ### filesystem_extract: unsquashfs failed!"
return 14
}

grep -v "\[" "$filesystem_log"
rm "$filesystem_log"

echo "done"
}

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

15
src/func/filesystem_get_type Executable file
View File

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

#filesystem_get_type [dir]
#(String)-> ext4, ext2, btfs, fuse, ...
function filesystem_get_type() {
fs_aTemp=(`df -T "$1"`)
echo ${fs_aTemp[9]}
}

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

37
src/func/filesystem_pack Executable file
View File

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

#filesystem_pack [chroot_path] [filesystem_img_destination]
function filesystem_pack() {
echo "pack filesystem ..."

#$1 = chroot_path
#$2 = filesystem_img_destination
chroot_path="$1"
filesystem_img_destination="$2"
filesystem_log="`mktemp`"

#Überfrüfen der Parameter
[ -d "$chroot_path" ] || {
echo "### ERROR ### filesystem_extract: chroot_path \"$chroot_path\" not exist!"
return 12
}

#loslegen ...
rm -f "$filesystem_img_destination"
mksquashfs "$chroot_path" "$filesystem_img_destination" > "$filesystem_log" || {
echo "### ERROR ### filesystem_pack: mksquashfs failed!"
return 13
}

grep -v "\[" "$filesystem_log"
rm "$filesystem_log"

echo "done"
}

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

31
src/func/iso_create Executable file
View File

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

#iso_create [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
function iso_create() {
echo -n "create iso ..."

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

[ -e "$iso_destination" ] && rm "$iso_destination"

xorriso -as mkisofs -graft-points -c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-info-table -boot-load-size 4 -isohybrid-mbr \
"$iso_extr_dir/isolinux/isolinux.bin" \
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
-isohybrid-gpt-basdat -V "$iso_lable" \
-o "$iso_destination" \
-r -J "$iso_extr_dir" \
--sort-weight 0 / --sort-weight 2 /boot --sort-weight 1 /isolinux

echo "done"
}

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

52
src/func/iso_extract Executable file
View File

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

#iso_extract [iso_source] [iso_extr_dir]
function iso_extract() {
echo -n "extract iso ... "

#$1 = iso_source
#$2 = iso_extr_dir

#check root
[ "`whoami`" == "root" ] || {
echo "### ERROR ### iso_extract: need root permision!"
return 10
}

iso_source="$1"
[ -f "$iso_source" ] || {
echo "### ERROR ### iso_extract: ISO \"$iso_source\" not exist!"
return 11
}

iso_extr_dir="$2"
[ -d "$iso_extr_dir" ] || {
echo "### ERROR ### iso_extract: aim directory not exist!"
return 12
}

#mace tmp mountpoint
tmpdir="`mktemp -d`"
[ -d "$iso_extr_dir" ] && {
rm -r "$iso_extr_dir/"
mkdir "$iso_extr_dir"
}

#copy files ...
mount -o loop,ro "$iso_source" "$tmpdir"
cp -f -r "$tmpdir/"* "$iso_extr_dir"

#clear tmp mountpoint
umount "$iso_source"
rm -r "$tmpdir"
tmpdir=

echo "done"
}

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

34
src/func/on_exit Executable file
View File

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

#on_exit [error_level]
function on_exit() {
#send log and errorlevel[success/errorr xy]

if [ "$1" != "0" ]; then
log_mail_subject="$log_mail_subject [ERROR]"
else
log_mail_subject="$log_mail_subject [Success]"
fi

#Mail Body:
for mail_aim in `echo "$log_mail_aim" | tr "," " "`; do
{
echo "$log_mail_subject"
echo $'####################################################################################\n\n'
cat "$log_file"
} | sendemail -s "$log_mail_smtp" -f "$log_mail_source" -t "$mail_aim" -u "$log_mail_subject" -o tls=no
done

[ "$1" != "0" ] && {
chroot_umount$distro "$chroot_path" 2> /dev/null
workspace_erase "$iso_extr_dir/" "$chroot_path/" 2> /dev/null
}
exit $1
}

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

19
src/func/workspace_erase Executable file
View File

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

#workspace_erase [workspace_path]
function workspace_erase() {
echo -n "erase workspace ... "

for dir in "$@"; do
[ -d "$dir" ] && rm -r -f "$dir"
done

echo "done"
}

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

16
src/mods/xrdp Executable file
View File

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



## ...





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

37
src/proj/debian Executable file
View File

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

####################################
##### Base Template D E B I A N ####
####################################
# .


#tools_add [chroot_dir] [tools_list]
function tools_add() {
echo "add tools ... "
#$1 = chroot directory
chroot_dir="$1"
tools_list="$2"

chroot "$chroot_dir" /bin/bash -c "apt-get update" > /dev/null
[ "$?" == "0" ] && echo "apt-get update: success"
chroot "$chroot_dir" /bin/bash -c "apt-get install -y $tools_list" | grep -v "wird eingerichtet ..." | grep -v "Vormals nicht ausgewähltes Paket" | grep -v "Entpacken von" | grep -v "Holen: " | grep -v "Trigger für" | grep -v "update-alternatives:"
echo "done"
}

#os_update [chroot_dir]
function os_update() {
echo "updating os ... "
#$1 = chroot directory

chroot_dir="$1"

chroot "$chroot_dir" /bin/bash -c "apt-get update" > /dev/null
[ "$?" == "0" ] && echo "apt-get update: success"
chroot "$chroot_dir" /bin/bash -c "apt-get dist-upgrade -y" | grep -v "wird eingerichtet ..." | grep -v "Vormals nicht ausgewähltes Paket" | grep -v "Entpacken von" | grep -v "Holen: " | grep -v "Trigger für" | grep -v "update-alternatives:"
chroot "$chroot_dir" /bin/bash -c "apt-get clean"

echo "done"
}

9
src/proj/desinfect.17 Executable file
View File

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

#desinfect.17
# . -Y ubuntu.16.04 -> ubuntu -> debian
source <LIBDIR>/proj/ubuntu.16.04

TEST2="na"

9
src/proj/ubuntu Executable file
View File

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

####################################
##### Base Template U B U N T U ####
####################################
# . -> debian
source <LIBDIR>/proj/debian

7
src/proj/ubuntu.16.04 Executable file
View File

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

#ubuntu.16.04
# . -> ubuntu -> debian
source <LIBDIR>/proj/ubuntu

0
src/pxe/pxe.cfg Normal file
View File

View File

@ -1,48 +1,30 @@
#!/bin/bash #!/bin/bash
#@version 1.9.0 #@version 2.0.0
#@autor 6543@obermui.de #@autor 6543@obermui.de
#@date 2018-03-26 #@date 2018-05-12
#@licence GNUv3 #@licence GNUv3


##################################################################################### #####################################################################################
################## S e t t i n g s ################################################## ################## S e t t i n g s ##################################################
##################################################################################### #####################################################################################


#set functions
[ -d "<LIBDIR>" ] || {
echo "ERROR Librarys not found"
exit 1
}


## MODUS #read main setting
modus_default="update_pxe" if [ -f "<ROOTDIR>/etc/remaster/config.cfg" ]; then

source "<ROOTDIR>/etc/remaster/config.cfg"
#CD/DVD else
#entweder iso_source oder filesystem_source alls quelle if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg" ]; then
# -> bei iso gen erforderlich! source "<ROOTDIR>/etc/remaster/config.sample.cfg"
iso_source="/data/remaster/desinfect-2017.iso" else
#destination optinal echo "ERROR config not found"
iso_destination="/data/remaster/result/custom_desinfect_`date '+%Y-%m-%d'`.iso" exit 1
iso_lable="DESINFECT_`date '+%Y-%m-%d'`" fi

fi
#Filesystem (for pxe)
#entweder iso_source oder filesystem_source alls quelle
filesystem_source="/data/remaster/result/filesystem.squashfs"

#Network
proxy_host="proxy.local"
proxy_port="8080"
domain="local"
nameserver="10.x.x.2,10.x.x.1"

#remaster_script
distro="desinfect2017"

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

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



##################################################################################### #####################################################################################
################## M o d e s ######################################################## ################## M o d e s ########################################################
@ -488,11 +470,6 @@ function main_update() {
main_update_pxe main_update_pxe
} }


#remaster.sh error_code [error_level]
function main_error_code() {
error_code $1
}

##################################################################################### #####################################################################################
################## F u n c t i o n s ################################################ ################## F u n c t i o n s ################################################
##################################################################################### #####################################################################################
@ -500,268 +477,44 @@ function main_error_code() {
### Error Handlings ### ### Error Handlings ###


#on_exit [error_level] #on_exit [error_level]
function on_exit() { source <LIBDIR>/func/on_exit
#send log and errorlevel[success/errorr xy]

if [ "$1" != "0" ]; then
log_mail_subject="$log_mail_subject [ERROR]"
else
log_mail_subject="$log_mail_subject [Success]"
fi

#Mail Body:
for mail_aim in `echo "$log_mail_aim" | tr "," " "`; do
{
echo "$log_mail_subject"
echo $'####################################################################################\n\n'
cat "$log_file"
} | sendemail -s "$log_mail_smtp" -f "$log_mail_source" -t "$mail_aim" -u "$log_mail_subject" -o tls=no
done

[ "$1" != "0" ] && {
chroot_umount$distro "$chroot_path" 2> /dev/null
workspace_erase "$iso_extr_dir/" "$chroot_path/" 2> /dev/null
}
exit $1
}


#error_code [error_level] #error_code [error_level]
function error_code() { source <LIBDIR>/func/error_code
code="$1"
case $code in
"")
echo $'ID:\tDescription\n----------------------------------------------------\n1\tAllgemeiner Fehler\n2\tNo Paramters / wrong parameters'
echo $'3\tWrong Settings\n4\tProgramm missing\n\n10\tno root\n11\tfile no found\n12\tdir not found\n13\tcant create/delete file/dir'
echo $'14\tcorrupt file (unsquashfs, mount iso, ...)\n15\twrong file (iso has no squashfs-file ...)\n16\trequired Packet not found\n\n20\tmount error\n21\tunmoun error\n22\twrong filesystem'
;;
1)
echo "Allgemeiner Fehler"
;;
2)
echo "No Paramters / wrong parameters"
;;
3)
echo "Wrong Settings"
;;
4)
echo "Programm missing"
;;
10)
echo "not executed as Root"
;;
11)
echo "file no found"
;;
12)
echo "dir not found"
;;
13)
echo "cant create/delete file/dir"
;;
14)
echo "corrupt file (unsquashfs, mount iso, ...)"
;;
15)
echo "wrong file (iso has no squashfs-file ...)"
;;
16)
echo "required Packet not found"
;;
20)
echo "tmount error"
;;
21)
echo "unmoun error"
;;
22)
echo "wrong filesystem"
;;
*)
echo $'No Defined Error Code.\nPerhaps an Error ocure on a Command wich was started by this Skritp.'
;;
esac
}


#check_user #check_user
function check_user() { source <LIBDIR>/func/check_user
#check root
[ "`whoami`" == "root" ] || {
echo "### ERROR ### Remaster need ROOT permision!"
return 10
}
}


#check_dependency #check_dependency
function check_dependency() { # -> 0 | -> 16
for packet in squashfs-tools xorriso wget sed sendemail; do source <LIBDIR>/func/check_dependency
[ "`dpkg -l $packet 2>&1`" == "dpkg-query: Kein Paket gefunden, das auf $packet passt" ] && {
echo "### ERROR ### Packet $packet not installed"
return 16
}
done
return 0
}




### Workspace ### ### Workspace ###


#workspace_erase [workspace_path] #workspace_erase [workspace_path]
function workspace_erase() { source <LIBDIR>/func/workspace_erase
echo -n "erase workspace ... "


for dir in "$@"; do
[ -d "$dir" ] && rm -r -f "$dir"
done

echo "done"
}


### Filesystem ### ### Filesystem ###


#filesystem_extract [filesystem_img_source] [chroot_path] #filesystem_extract [filesystem_img_source] [chroot_path]
function filesystem_extract() { source <LIBDIR>/func/filesystem_extract
echo "extract filesystem ..."

#$1 = filesystem_img_source
#$2 = chroot_path
filesystem_img_source="$1"
chroot_path="$2"
filesystem_log="`mktemp`"

#Überfrüfen der Parameter
[ -f "$filesystem_img_source" ] || {
echo "### ERROR ### filesystem_extract: squashfs \"$filesystem_img_source\" not exist!"
return 11
}

[ "`mkdir -p "$chroot_path"`" != "" ] && {
echo "### ERROR ### filesystem_extract: chroot_path \"$chroot_path\" can't create!"
return 13
}

[ "`filesystem_get_type $chroot_path`" != "ext4" ] && [ "`filesystem_get_type $chroot_path`" != "btrfs" ] && {
echo "### ERROR ### filesystem_extract: wrong filesystem (`filesystem_get_type $chroot_path`)!"
return 22
}

rm -r "$chroot_path"

#eigendliches entpacken
unsquashfs -d "$chroot_path" "$filesystem_img_source" > "$filesystem_log" || {
echo "### ERROR ### filesystem_extract: unsquashfs failed!"
return 14
}

grep -v "\[" "$filesystem_log"
rm "$filesystem_log"

echo "done"
}


#filesystem_pack [chroot_path] [filesystem_img_destination] #filesystem_pack [chroot_path] [filesystem_img_destination]
function filesystem_pack() { source <LIBDIR>/func/filesystem_pack
echo "pack filesystem ..."

#$1 = chroot_path
#$2 = filesystem_img_destination
chroot_path="$1"
filesystem_img_destination="$2"
filesystem_log="`mktemp`"

#Überfrüfen der Parameter
[ -d "$chroot_path" ] || {
echo "### ERROR ### filesystem_extract: chroot_path \"$chroot_path\" not exist!"
return 12
}

#loslegen ...
rm -f "$filesystem_img_destination"
mksquashfs "$chroot_path" "$filesystem_img_destination" > "$filesystem_log" || {
echo "### ERROR ### filesystem_pack: mksquashfs failed!"
return 13
}

grep -v "\[" "$filesystem_log"
rm "$filesystem_log"

echo "done"
}


#filesystem_get_type [dir] #filesystem_get_type [dir]
#(String)-> ext4, ext2, btfs, fuse, ... #(String)-> ext4, ext2, btfs, fuse, ...
function filesystem_get_type() { source <LIBDIR>/func/filesystem_get_type
fs_aTemp=(`df -T "$1"`)
echo ${fs_aTemp[9]}
}


### ISO ### ### ISO ###


#iso_extract [iso_source] [iso_extr_dir] #iso_extract [iso_source] [iso_extr_dir]
function iso_extract() { source <LIBDIR>/func/iso_extract
echo -n "extract iso ... "

#$1 = iso_source
#$2 = iso_extr_dir

#check root
[ "`whoami`" == "root" ] || {
echo "### ERROR ### iso_extract: need root permision!"
return 10
}

iso_source="$1"
[ -f "$iso_source" ] || {
echo "### ERROR ### iso_extract: ISO \"$iso_source\" not exist!"
return 11
}

iso_extr_dir="$2"
[ -d "$iso_extr_dir" ] || {
echo "### ERROR ### iso_extract: aim directory not exist!"
return 12
}

#mace tmp mountpoint
tmpdir="`mktemp -d`"
[ -d "$iso_extr_dir" ] && {
rm -r "$iso_extr_dir/"
mkdir "$iso_extr_dir"
}

#copy files ...
mount -o loop,ro "$iso_source" "$tmpdir"
cp -f -r "$tmpdir/"* "$iso_extr_dir"

#clear tmp mountpoint
umount "$iso_source"
rm -r "$tmpdir"
tmpdir=

echo "done"
}


#iso_create [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable] #iso_create [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
function iso_create() { source <LIBDIR>/func/iso_create
echo -n "create iso ..."

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

[ -e "$iso_destination" ] && rm "$iso_destination"

xorriso -as mkisofs -graft-points -c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-info-table -boot-load-size 4 -isohybrid-mbr \
"$iso_extr_dir/isolinux/isolinux.bin" \
-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
-isohybrid-gpt-basdat -V "$iso_lable" \
-o "$iso_destination" \
-r -J "$iso_extr_dir" \
--sort-weight 0 / --sort-weight 2 /boot --sort-weight 1 /isolinux

echo "done"
}


#iso_create_desinfect2015 [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable] #iso_create_desinfect2015 [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
function iso_create_desinfect2015() { function iso_create_desinfect2015() {
@ -814,27 +567,7 @@ function iso_create_desinfect2017() {
### chroot ### ### chroot ###


#chroot_initial [chroot_dir] #chroot_initial [chroot_dir]
function chroot_initial() { source <LIBDIR>/func/chroot_initial
echo -n "initial chroot ... "

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

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

echo "done"
}


#chroot_initial_desinfect2015 [chroot_dir] #chroot_initial_desinfect2015 [chroot_dir]
function chroot_initial_desinfect2015() { function chroot_initial_desinfect2015() {
@ -890,41 +623,10 @@ function chroot_initial_desinfect2017() {




#chroot_clean [chroot_dir] #chroot_clean [chroot_dir]
function chroot_clean() { source <LIBDIR>/func/chroot_clean
echo "clean chroot ... "

chroot_dir="$1"

chroot "$chroot_dir" /bin/bash -c "apt-get clean"
chroot "$chroot_dir" /bin/bash -c "rm -r /var/cache/apt/*"
chroot "$chroot_dir" /bin/bash -c "apt-get update"
chroot "$chroot_dir" /bin/bash -c "apt-get check"

echo "done"
}


#chroot_umount [chroot_dir] #chroot_umount [chroot_dir]
function chroot_umount() { source <LIBDIR>/func/chroot_umount
echo -n "unmount chroot ... "

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

for d in "$chroot_dir/tmp" "$chroot_dir/root" "$chroot_dir/proc" "$chroot_dir/dev" ; do
umount $d
retval=$?
[ "$retval" -gt 0 ] && {
echo "### ERROR ### chroot_umount: can't umount \"$d\"!"
return 21
}
done

echo "done"
}


#chroot_umount_desinfect2015 [chroot_dir] #chroot_umount_desinfect2015 [chroot_dir]
function chroot_umount_desinfect2015() { function chroot_umount_desinfect2015() {
@ -981,38 +683,10 @@ function chroot_umount_desinfect2017() {


#chroot_is_mounted [chroot_dir] #chroot_is_mounted [chroot_dir]
#(Boolean)-> true | false #(Boolean)-> true | false
function chroot_is_mounted() { source <LIBDIR>/func/chroot_is_mounted
#$1 = chroot directory

if [ "`mount | grep "$1"`" != "" ] ; then
#ther is smething mounted
echo "true"
else
#nothing mounted
echo "false"
fi
}


#chroot_sh [chroot_dir] [command] #chroot_sh [chroot_dir] [command]
function chroot_sh() { source <LIBDIR>/func/chroot_sh
#check chroot dir
chroot_dir="$1"
[ -d "$chroot_dir" ] || {
echo "### ERROR ### chroot_sh: chroot directory not exist!"
return 12
}

command="$2"

[ -f "$chroot_dir/tmp/env.sh" ] || {
#if not exist create environment skript
cat "$chroot_dir/etc/environment" | grep -v "#" | grep "=" > "$chroot_dir/tmp/env"
while read line; do echo export $line; done < "$chroot_dir/tmp/env" > "$chroot_dir/tmp/env.sh"
chmod +x "$chroot_dir/tmp/env.sh" && rm "$chroot_dir/tmp/env"
}

chroot "$chroot_dir" /bin/bash --login -c ". /tmp/env.sh; $command"
}


### Settings ### ### Settings ###
### proxy ### proxy
@ -1179,7 +853,7 @@ function proxy_enable_desinfect2017() {
#Sophos #Sophos
if [ -f ""$chroot_dir/opt/sophos-av/etc/savd.cfg"" ]; then if [ -f ""$chroot_dir/opt/sophos-av/etc/savd.cfg"" ]; then
echo "Sophos: Found" echo "Sophos: Found"
echo "<Source>sophos:</Source><Proxy><Address>http://www-proxy.bybn.de:80</Proxy></Address>" >> "$chroot_dir/opt/sophos-av/etc/savd.cfg" echo "<Source>sophos:</Source><Proxy><Address>http://$proxy_host:$proxy_port</Proxy></Address>" >> "$chroot_dir/opt/sophos-av/etc/savd.cfg"
else else
eco "Sophos: NOT Found" eco "Sophos: NOT Found"
fi fi
@ -1420,19 +1094,7 @@ function sourcelist_desinfect_set_extendet2017() {
### Update ### ### Update ###


#os_update [chroot_dir] #os_update [chroot_dir]
function os_update() { #-> proj/debian
echo "updating os ... "
#$1 = chroot directory

chroot_dir="$1"

chroot "$chroot_dir" /bin/bash -c "apt-get update" > /dev/null
[ "$?" == "0" ] && echo "apt-get update: success"
chroot "$chroot_dir" /bin/bash -c "apt-get dist-upgrade -y" | grep -v "wird eingerichtet ..." | grep -v "Vormals nicht ausgewähltes Paket" | grep -v "Entpacken von" | grep -v "Holen: " | grep -v "Trigger für" | grep -v "update-alternatives:"
chroot "$chroot_dir" /bin/bash -c "apt-get clean"

echo "done"
}


#os_update_desinfect2015 [chroot_dir] #os_update_desinfect2015 [chroot_dir]
function os_update_desinfect2015() { function os_update_desinfect2015() {
@ -1652,17 +1314,7 @@ function os_update_desinfect2017() {
### Tools ### ### Tools ###


#tools_add [chroot_dir] [tools_list] #tools_add [chroot_dir] [tools_list]
function tools_add() { #-> proj/debian
echo "add tools ... "
#$1 = chroot directory
chroot_dir="$1"
tools_list="$2"

chroot "$chroot_dir" /bin/bash -c "apt-get update" > /dev/null
[ "$?" == "0" ] && echo "apt-get update: success"
chroot "$chroot_dir" /bin/bash -c "apt-get install -y $tools_list" | grep -v "wird eingerichtet ..." | grep -v "Vormals nicht ausgewähltes Paket" | grep -v "Entpacken von" | grep -v "Holen: " | grep -v "Trigger für" | grep -v "update-alternatives:"
echo "done"
}


#tools_add_desinfect2015 [chroot_dir] [tools_list] #tools_add_desinfect2015 [chroot_dir] [tools_list]
function tools_add_desinfect2015() { function tools_add_desinfect2015() {
@ -1697,6 +1349,7 @@ function tools_add_desinfect2017() {
sourcelist_desinfect_set_nomal2017 "$chroot_dir" sourcelist_desinfect_set_nomal2017 "$chroot_dir"
} }


source <LIBDIR>/proj/desinfect.17


### Handle Parameters & Modes ### ### Handle Parameters & Modes ###



0
src/web/index.html Normal file
View File