Browse Source

source cant use variables (p1)

pull/19/head
6543 4 years ago
parent
commit
838a1e709a
  1. 48
      autogen.sh
  2. 12
      doc/buid_vars.md
  3. 4
      src/func/check_dependency
  4. 4
      src/func/check_user
  5. 4
      src/func/chroot_clean
  6. 4
      src/func/chroot_initial
  7. 4
      src/func/chroot_is_mounted
  8. 4
      src/func/chroot_sh
  9. 4
      src/func/chroot_umount
  10. 4
      src/func/error_code
  11. 4
      src/func/filesystem_extract
  12. 4
      src/func/filesystem_get_type
  13. 4
      src/func/filesystem_pack
  14. 4
      src/func/iso_create
  15. 4
      src/func/iso_extract
  16. 4
      src/func/on_exit
  17. 4
      src/func/workspace_erase
  18. 40
      src/proj/debian
  19. 10
      src/proj/desinfect.17
  20. 0
      src/proj/desinfect17
  21. 12
      src/proj/ubuntu
  22. 10
      src/proj/ubuntu.16.04
  23. 75
      src/remaster.sh

48
autogen.sh

@ -1,14 +1,18 @@
#!/bin/bash
# at the moment only generate dir structure in /build

#####################
## setup build dir ##
#####################
####################
## set enviroment ##
####################

rootdir=build
[ -n "$1" ] && mode=debug
# install | clean | debug

case
ROOTDIR=build
echo "clear build"
[ -d $rootdir ] && rm -v -R $rootdir
mkdir $rootdir
[ -d $ROOTDIR ] && rm -v -R $ROOTDIR
mkdir $ROOTDIR

######################
## skripte copieren ##
@ -17,20 +21,20 @@ mkdir $rootdir
echo "copy files"

# remaster
mkdir -p $rootdir/usr/bin/
cp -v src/remaster.sh $rootdir/usr/bin/remaster
chmod +x $rootdir/usr/bin/remaster
mkdir -p $ROOTDIR/usr/bin/
cp -v src/remaster.sh $ROOTDIR/usr/bin/remaster
chmod +x $ROOTDIR/usr/bin/remaster

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

# setting
mkdir -p $rootdir/etc/remaster/
cp -v src/config.sample.cfg $rootdir/etc/remaster/config.sample.cfg
mkdir -p $ROOTDIR/etc/remaster/
cp -v src/config.sample.cfg $ROOTDIR/etc/remaster/config.sample.cfg


# Pfade anpassen
@ -39,3 +43,19 @@ cp -v src/config.sample.cfg $rootdir/etc/remaster/config.sample.cfg

#mkdeb...
#not jet


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

12
doc/buid_vars.md

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

4
src/func/check_dependency

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#check_dependency
# -> 0 | -> 16

4
src/func/check_user

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#check_user
function check_user() {

4
src/func/chroot_clean

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#chroot_clean [chroot_dir]
function chroot_clean() {

4
src/func/chroot_initial

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#chroot_initial [chroot_dir]
function chroot_initial() {

4
src/func/chroot_is_mounted

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#chroot_is_mounted [chroot_dir]
#(Boolean)-> true | false

4
src/func/chroot_sh

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#chroot_sh [chroot_dir] [command]
function chroot_sh() {

4
src/func/chroot_umount

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#chroot_umount [chroot_dir]
function chroot_umount() {

4
src/func/error_code

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#error_code [error_level]
function error_code() {

4
src/func/filesystem_extract

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#filesystem_extract [filesystem_img_source] [chroot_path]
function filesystem_extract() {

4
src/func/filesystem_get_type

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#filesystem_get_type [dir]
#(String)-> ext4, ext2, btfs, fuse, ...

4
src/func/filesystem_pack

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#filesystem_pack [chroot_path] [filesystem_img_destination]
function filesystem_pack() {

4
src/func/iso_create

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#iso_create [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
function iso_create() {

4
src/func/iso_extract

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#iso_extract [iso_source] [iso_extr_dir]
function iso_extract() {

4
src/func/on_exit

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#on_exit [error_level]
function on_exit() {

4
src/func/workspace_erase

@ -1,7 +1,7 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDR"] || { echo "LIBDR not exist"; exit 1; }
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

#workspace_erase [workspace_path]
function workspace_erase() {

40
src/proj/debian

@ -0,0 +1,40 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -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"
}

TEST="ja"
TEST2="ja"

10
src/proj/desinfect.17

@ -0,0 +1,10 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

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

TEST2="na"

0
src/proj/desinfect17

12
src/proj/ubuntu

@ -0,0 +1,12 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

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

TEST2="jaUb"

10
src/proj/ubuntu.16.04

@ -0,0 +1,10 @@
#!/bin/bash
#remaster lib
[ -d "$LIBDIR"] || export LIBDIR="/usr/lib/remaster/"
[ -d "$LIBDIR"] || { echo "LIBDIR not exist"; exit 1; }

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

TEST2="jaUBU"

75
src/remaster.sh

@ -7,25 +7,19 @@
#####################################################################################
################## S e t t i n g s ##################################################
#####################################################################################
#get base dir
rootdir=`echo $0 | rev | cut -d "/" -f 2- | rev`/../../
export "rootdir=`readlink -e $rootdir`"

#set functions
if [ -p "$rootdir/usr/lib/remaster/" ]; then
#source "$rootdir/usr/lib/remaster/" ...
export LIBDIR="$rootdir/usr/lib/remaster/"
else
[ -d "<LIBDIR>" ] || {
echo "ERROR functions not found"
exit 1
fi
}

#read main setting
if [ -f "$rootdir/etc/remaster/config.cfg"]; then
source "$rootdir/etc/remaster/config.cfg"
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"
if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg"]; then
source "<ROOTDIR>/etc/remaster/config.sample.cfg"
else
echo "ERROR config not found"
exit 1
@ -483,44 +477,44 @@ function main_update() {
### Error Handlings ###

#on_exit [error_level]
source $LIBDR/func/on_exit
source <LIBDIR>/func/on_exit

#error_code [error_level]
source $LIBDR/func/error_code
source <LIBDIR>/func/error_code

#check_user
source $LIBDR/func/check_user
source <LIBDIR>/func/check_user

#check_dependency
# -> 0 | -> 16
source $LIBDR/func/check_dependency
source <LIBDIR>/func/check_dependency


### Workspace ###

#workspace_erase [workspace_path]
source $LIBDR/func/workspace_erase
source <LIBDIR>/func/workspace_erase


### Filesystem ###

#filesystem_extract [filesystem_img_source] [chroot_path]
source $LIBDR/func/filesystem_extract
source <LIBDIR>/func/filesystem_extract

#filesystem_pack [chroot_path] [filesystem_img_destination]
source $LIBDR/func/filesystem_pack
source <LIBDIR>/func/filesystem_pack

#filesystem_get_type [dir]
#(String)-> ext4, ext2, btfs, fuse, ...
source $LIBDR/func/filesystem_get_type
source <LIBDIR>/func/filesystem_get_type

### ISO ###

#iso_extract [iso_source] [iso_extr_dir]
source $LIBDR/func/iso_extract
source <LIBDIR>/func/iso_extract

#iso_create [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
source $LIBDR/func/iso_create
source <LIBDIR>/func/iso_create

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

#chroot_initial [chroot_dir]
source $LIBDR/func/chroot_initial
source <LIBDIR>/func/chroot_initial

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


#chroot_clean [chroot_dir]
source $LIBDR/func/chroot_clean
source <LIBDIR>/func/chroot_clean

#chroot_umount [chroot_dir]
source $LIBDR/func/chroot_umount
source <LIBDIR>/func/chroot_umount

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

#chroot_is_mounted [chroot_dir]
#(Boolean)-> true | false
source $LIBDR/func/chroot_is_mounted
source <LIBDIR>/func/chroot_is_mounted

#chroot_sh [chroot_dir] [command]
source $LIBDR/func/chroot_sh
source <LIBDIR>/func/chroot_sh

### Settings ###
### proxy
@ -1100,19 +1094,7 @@ function sourcelist_desinfect_set_extendet2017() {
### Update ###

#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"
}
#-> proj/debian

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

#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"
}
#-> proj/debian

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

source <LIBDIR>/proj/desinfect.17

### Handle Parameters & Modes ###


Loading…
Cancel
Save