source cant use variables (p1)

This commit is contained in:
6543 2018-05-06 19:26:21 +02:00
parent f2b3b5f530
commit 838a1e709a
23 changed files with 172 additions and 95 deletions

View File

@ -1,14 +1,18 @@
#!/bin/bash #!/bin/bash
# at the moment only generate dir structure in /build # 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" echo "clear build"
[ -d $rootdir ] && rm -v -R $rootdir [ -d $ROOTDIR ] && rm -v -R $ROOTDIR
mkdir $rootdir mkdir $ROOTDIR


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


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


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


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




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


#mkdeb... #mkdeb...
#not jet #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 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

View File

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


#check_dependency #check_dependency
# -> 0 | -> 16 # -> 0 | -> 16

View File

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


#check_user #check_user
function check_user() { function check_user() {

View File

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


#chroot_clean [chroot_dir] #chroot_clean [chroot_dir]
function chroot_clean() { function chroot_clean() {

View File

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


#chroot_initial [chroot_dir] #chroot_initial [chroot_dir]
function chroot_initial() { function chroot_initial() {

View File

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


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

View File

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


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

View File

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


#chroot_umount [chroot_dir] #chroot_umount [chroot_dir]
function chroot_umount() { function chroot_umount() {

View File

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


#error_code [error_level] #error_code [error_level]
function error_code() { function error_code() {

View File

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


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

View File

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


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

View File

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


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

View File

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


#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() { function iso_create() {

View File

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


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

View File

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


#on_exit [error_level] #on_exit [error_level]
function on_exit() { function on_exit() {

View File

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


#workspace_erase [workspace_path] #workspace_erase [workspace_path]
function workspace_erase() { function workspace_erase() {

40
src/proj/debian Normal file
View File

@ -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 Normal file
View File

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

View File

12
src/proj/ubuntu Normal file
View File

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

View File

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

View File

@ -7,25 +7,19 @@
##################################################################################### #####################################################################################
################## S e t t i n g s ################################################## ################## 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 #set functions
if [ -p "$rootdir/usr/lib/remaster/" ]; then [ -d "<LIBDIR>" ] || {
#source "$rootdir/usr/lib/remaster/" ...
export LIBDIR="$rootdir/usr/lib/remaster/"
else
echo "ERROR functions not found" echo "ERROR functions not found"
exit 1 exit 1
fi }


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


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


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


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


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




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


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




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


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


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


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


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


#iso_extract [iso_source] [iso_extr_dir] #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] #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] #iso_create_desinfect2015 [chroot_path] [iso_extr_dir] [iso_destination] [iso_lable]
function iso_create_desinfect2015() { function iso_create_desinfect2015() {
@ -573,7 +567,7 @@ function iso_create_desinfect2017() {
### chroot ### ### chroot ###


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


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




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


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


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


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


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


### Settings ### ### Settings ###
### proxy ### proxy
@ -1100,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() {
@ -1332,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() {
@ -1377,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 ###