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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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