about summary refs log tree commit diff stats
path: root/core/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'core/scripts')
-rw-r--r--core/scripts/act-chroot.sh65
-rw-r--r--core/scripts/backup-system.sh82
-rwxr-xr-x[-rw-r--r--]core/scripts/setup-install.sh234
-rw-r--r--core/scripts/setup-iso.sh50
-rwxr-xr-x[-rw-r--r--]core/scripts/setup-target.sh209
5 files changed, 408 insertions, 232 deletions
diff --git a/core/scripts/act-chroot.sh b/core/scripts/act-chroot.sh
index 7f665f0..5411bc5 100644
--- a/core/scripts/act-chroot.sh
+++ b/core/scripts/act-chroot.sh
@@ -1,50 +1,35 @@
 #!/bin/bash
 
-printf "1.1.2 EFI block; (/dev/sda1):"
-#read BLK_EFI
-BLK_EFI="/dev/sda1"
+DEV=$1
 
-printf "1.1.2 boot block; (/dev/sda2):"
-#read BLK_BOOT
-BLK_BOOT="/dev/sda2"
-
-printf "1.1.2 root block; (/dev/sda3):"
-#read BLK_ROOT
-BLK_ROOT="/dev/sda3"
-#
-printf "1.1.2 var block; (/dev/sda4):"
-#read BLK_VAR
-BLK_VAR="/dev/sda4"
-#
-printf "1.1.2 usr block; (/dev/sda6):"
-#read BLK_USR
-BLK_USR="/dev/sda6"
-#
-printf "1.1.2 home block; (/dev/sda7):"
-#read BLK_HOME
-BLK_HOME="/dev/sda7"
-#
-printf "1.1.2 ports block; (/dev/sda8):\n"
-#read BLK_PRT
-BLK_PRT="/dev/sda8"
-
-printf "1.1.2 swap block; (/dev/sda9):\n"
-#read BLK_SWP
-BLK_SWP="/dev/sda9"
+CHROOT="/mnt"
+##read BLK_EFI
+BLK_EFI="${DEV}2"
+##read BLK_BOOT
+BLK_BOOT="${DEV}3"
+##read BLK_ROOT
+BLK_ROOT="${DEV}4"
+##read BLK_VAR
+BLK_VAR="${DEV}5"
+##read BLK_USR
+BLK_USR="${DEV}6"
+##read BLK_SWP
+BLK_SWP="${DEV}7"
+##read BLK_HOME
+BLK_HOME="${DEV}8"
 
-printf "1.1.3 mount point to chroot (/mnt):"
 #read CHROOT
 CHROOT="/mnt"
 
-mount $BLK_ROOT $CHROOT
-
-mount $BLK_BOOT $CHROOT/boot
-mount $BLK_EFI $CHROOT/boot/efi
-
-mount $BLK_VAR $CHROOT/var
-mount $BLK_USR $CHROOT/usr
-mount $BLK_PRT $CHROOT/usr/ports
-mount $BLK_HOME $CHROOT/home
+#mount $BLK_ROOT $CHROOT
+#
+#mount $BLK_BOOT $CHROOT/boot
+#mount $BLK_EFI $CHROOT/boot/efi
+#
+#mount $BLK_VAR $CHROOT/var
+#mount $BLK_USR $CHROOT/usr
+#mount $BLK_PRT $CHROOT/usr/ports
+#mount $BLK_HOME $CHROOT/home
 
 #mount -vt devpts devpts $CHROOT/dev/pts
 #mount -vt tmpfs shm $CHROOT/dev/shm
diff --git a/core/scripts/backup-system.sh b/core/scripts/backup-system.sh
index bc94f7e..379e449 100644
--- a/core/scripts/backup-system.sh
+++ b/core/scripts/backup-system.sh
@@ -6,23 +6,65 @@ read ROOT_DIR
 echo -n "where you want to save (/home/user): "
 read DEST_DIR
 
-echo -n "backup name (system_name): "
-read BCK_NAME
-
-echo $DES_DIR
-echo $ROOT_DIR
-
-tar --xattrs -zcpf $DEST_DIR/$BCK_NAME-`date '+%Y-%j-%H-%M-%S'`.tar.gz \
-    --directory=$ROOT_DIR \
-    --exclude=usr/ports \
-    --exclude=usr/src \
-    --exclude=var/run \
-    --exclude=var/lock \
-    --exclude=srv \
-    --exclude=mnt \
-    --exclude=home \
-    --exclude=dev \
-    --exclude=run \
-    --exclude=tmp \
-    --exclude=proc \
-    --exclude=sys .
+bk_coll() {
+    col=$1
+    # make copy of packages
+    mkdir ${BKDIR}/${col}
+    while read line; do
+            if [ ! -f /usr/ports/packages/${line} ]; then
+                echo "Building package: ${line};\n"
+                name=$(echo ${line} | cut -d "#" -f 1)
+                sudo prt-get update -fr ${name}
+            fi
+
+            if [ -f /usr/ports/packages/${line} ]; then
+                echo "Backing up package: ${line}"
+                echo ${line} >> ${BKDIR}/backup.pkg
+                cp /usr/ports/packages/${line} ${BKDIR}/${col}/
+            else
+                echo "Package not found: ${line}"
+                echo ${line} >> ${BKDIR}/${col}-notfound.pkg
+            fi
+    done < $BKDIR/${col}.pkg
+}
+
+# Temporary directory
+BKDIR=$(pwd)/bkdir
+mkdir -p ${BKDIR}
+
+# must be using gwak instead of sed, xargs and echo
+prt-get listinst -v | sed -s s/" "/#/g | xargs -i echo {}.pkg.tar.gz > ${BKDIR}/installed.pkg
+
+# make list and copy installed core packages
+prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/core" | cut -d " " -f 3 > ${BKDIR}/core.pkg
+bk_coll "core"
+
+
+prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/opt" | cut -d " " -f 3 > $BKDIR/opt.pkg
+bk_coll "opt"
+
+prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/contrib" | cut -d " " -f 3 > $BKDIR/contrib.pkg
+bk_coll "contrib"
+
+prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep "yes /usr/ports/xorg" | cut -d " " -f 3 > $BKDIR/xorg.pkg
+bk_coll "xorg"
+
+prt-get printf "%i %p %n#%v-%r.pkg.tar.gz\n" | grep -v "yes /usr/ports/core" | grep -v "yes /usr/ports/opt" | grep -v "yes /usr/ports/contrib" | grep -v "yes /usr/ports/xorg" | grep "yes " | cut -d " " -f 3 > $BKDIR/other.pkg
+
+#echo $DES_DIR
+#echo $ROOT_DIR
+#
+#tar --xattrs -zcpf $DEST_DIR/system-backup-`date '+%Y-%j-%H-%M-%S'`.tar.gz \
+#    --directory=$ROOT_DIR \
+#    --exclude=usr/ports \
+#    --exclude=usr/src \
+#    --exclude=var/run \
+#    --exclude=var/lock \
+#    --exclude=srv \
+#    --exclude=mnt \
+#    --exclude=home \
+#    --exclude=dev \
+#    --exclude=run \
+#    --exclude=tmp \
+#    --exclude=proc \
+#    --exclude=sys .
diff --git a/core/scripts/setup-install.sh b/core/scripts/setup-install.sh
index 4ca01ff..c1d2765 100644..100755
--- a/core/scripts/setup-install.sh
+++ b/core/scripts/setup-install.sh
@@ -1,35 +1,28 @@
-#!/bin/sh
+#!/bin/bash
 
 # Set Global Vars
 ADMIN_USER=c9admin
 DEV=$1
-CHROOT="/mnt"
-##read BLK_SWP
-BLK_SWP="/dev/sda9"
-
-##read BLK_EFI
-BLK_EFI="${DEV}1"
-##read BLK_BOOT
-BLK_BOOT="${DEV}2"
-##read BLK_ROOT
-BLK_ROOT="${DEV}3"
-##read BLK_VAR
-BLK_VAR="${DEV}4"
-
-# Absolute path to this script, e.g. /home/user/bin/foo.sh
+CHROOT=$2
+
+# Absolute path to this script,
+# e.g. /home/user/c9-doc/core/scripts/foo.sh
 SCRIPT=$(readlink -f "$0")
-# Absolute path this script is in, thus /home/user/bin
+# Absolute path this script is in, 
+# e.g. /home/user/c9-doc/core/scripts
 SCRIPTPATH=$(dirname "$SCRIPT")
-
+# Absolute path to doc section,
+# e.g /home/user/c9-doc/core
 DIR=$(dirname "$SCRIPTPATH");
+# Absolute path to local data,
+# e.g /home/user/local
 DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
 
+
 DIR_CONF="${DIR}/conf"
 DIR_PRT="${DIR}/ports";
+ISO_FILE="${DIR_LOCAL}/crux-3.3.iso"
 
-ISO_FILE="${DIR_LOCAL}/crux-3.2.iso"
-
-# First we define the function
 ConfirmOrExit ()
 {
     while true
@@ -48,137 +41,47 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
-setup_target () {
-    echo "1.1.2 Creating File System on $BLK_EFI with fat32:"
-    mkfs.fat -F 32 $BLK_EFI
-    echo "1.1.2 Creating File System on $BLK_BOOT with ext4:"
-    mkfs.ext4 $BLK_BOOT
-    echo "1.1.2 Creating File System on $BLK_ROOT with ext4:"
-    mkfs.ext4 $BLK_ROOT
-    echo "1.1.2 Creating File System on $BLK_VAR with ext4:"
-    mkfs.ext4 $BLK_VAR
-    #echo "1.1.2 Creating Swap File System on $BLK_SWP:"
-    #mkswap $BLK_SWP
-
-    echo "1.1.3 mount point to chroot (/mnt):\n"
-    mount $BLK_ROOT $CHROOT
-
-    mkdir -p $CHROOT/boot
-    mount $BLK_BOOT $CHROOT/boot
-    mkdir -p $CHROOT/boot/efi
-    mount $BLK_EFI $CHROOT/boot/efi
-    mkdir -p $CHROOT/var
-    mount $BLK_VAR $CHROOT/var
-
-    mkdir -p $CHROOT/dev
-    mkdir -p $CHROOT/tmp
-    mkdir -p $CHROOT/proc
-    mkdir -p $CHROOT/sys
-
-    mkdir -p $CHROOT/var/lib/pkg
-    mkdir -p $CHROOT/usr/ports
-
-    mkdir -p $CHROOT/media
-    mkdir -p $CHROOT/home
-
-    mount --bind /dev $CHROOT/dev
-    mount -vt devpts devpts $CHROOT/dev/pts
-    mount -vt tmpfs shm $CHROOT/dev/shm
-    mount -vt proc proc $CHROOT/proc
-    mount -vt sysfs sysfs $CHROOT/sys
-
-    modprobe isofs
-    modprobe loop
-    mount -o loop $ISO_FILE $CHROOT/media
-}
 
-setup_bin() {
+install_core() {
 
     echo "1.1.4 Create core.lst and install pkgadd"
-    for p in $CHROOT/media/crux/core/*; do echo $p >> $CHROOT/core.lst; done
+    for p in ${CHROOT}mnt/media/crux/core/*; do echo $p >> ${CHROOT}core.lst; done
 
-    tar xf "$CHROOT/media/crux/core/pkgutils#5.36-2.pkg.tar.xz" usr/bin/pkgadd -O > $CHROOT/pkgadd
+    tar xf "${CHROOT}mnt/media/crux/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}pkgadd
 
-    chmod +x $CHROOT/pkgadd
+    chmod +x ${CHROOT}pkgadd
 
     echo "1.1.4 File core.lst complete, review list of packages before continue..."
     read PAUSE
-    vim $CHROOT/core.lst
+    vim ${CHROOT}core.lst
 
     echo "1.1.4 Starting install"
-    touch $CHROOT/var/lib/pkg/db
+    touch ${CHROOT}/var/lib/pkg/db
 
     cd $CHROOT
     while read line; do
         echo "Installing $line;\n"
-        $CHROOT/pkgadd -f -r $CHROOT $line
-    done < core.lst
+        ${CHROOT}pkgadd -u -f -r ${CHROOT} ${line}
+    done < ${CHROOT}core.lst
 
-    rm $CHROOT/pkgadd
-    rm $CHROOT/core.lst
-
-    echo "1.1.5. Install extra packages;"
-
-    mkdir $CHROOT/usr/ports/packages
-    cp $CHROOT/media/crux/core/* $CHROOT/usr/ports/packages
-    cp $CHROOT/media/crux/opt/* $CHROOT/usr/ports/packages
-    cp $CHROOT/media/crux/xorg/* $CHROOT/usr/ports/packages
+    rm ${CHROOT}pkgadd
+    rm ${CHROOT}core.lst
 
-    echo "Installing $CHROOT/usr/ports/packages/fakeroot#1.20.2-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/fakeroot#1.20.2-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/dbus#1.10.2-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/dbus#1.10.2-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/expat#2.1.0-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/expat#2.1.0-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/libnl#3.2.27-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libnl#3.2.27-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/libpng#1.6.19-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libpng#1.6.19-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/freetype#2.6.1-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/freetype#2.6.1-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/libffi#3.2.1-2.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/libffi#3.2.1-2.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/sqlite3#3.9.2-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/sqlite3#3.9.2-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/python#2.7.10-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/python#2.7.10-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/glib#2.46.2-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/glib#2.46.2-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/grub2#2.00-7.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/grub2#2.00-7.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/grub2-efi#2.00-4.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/grub2-efi#2.00-4.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/wireless-tools#29-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/wireless-tools#29-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/wpa_supplicant#2.5-2.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/wpa_supplicant#2.5-2.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/lvm2#2.02.133-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/lvm2#2.02.133-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/mdadm#3.3.4-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/mdadm#3.3.4-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/efivar#0.21-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/efivar#0.21-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/efibootmgr#0.12-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/efibootmgr#0.12-1.pkg.tar.xz"
-    echo "Installing $CHROOT/usr/ports/packages/dosfstools#3.0.26-1.pkg.tar.xz"
-    $CHROOT/usr/bin/pkgadd -f -r $CHROOT "$CHROOT/usr/ports/packages/dosfstools#3.0.26-1.pkg.tar.xz"
+    mkdir ${CHROOT}usr/ports/packages
+    cp ${CHROOT}media/crux/core/* ${CHROOT}usr/ports/packages
 
-    echo "1.1.6. Install extra ports;\n"
+}
 
-    mkdir $CHROOT/usr/ports/c9-ports
-    cp -r $DIR_PRT/* $CHROOT/usr/ports/c9-ports/
+setup_core() {
 
     echo "1.1.7. dns resolver, copy resolv.conf;\n"
     cp /etc/resolv.conf $CHROOT/etc
 
     echo "1.1.8. Install Handbook\n"
-    cp /media/crux/handbook.txt $CHROOT/root/
+    cp $CHROOT/media/crux/handbook.txt $CHROOT/root/
 
     echo "1.1.9. Install Skeletons\n"
     cp -r $DIR_CONF/skel $CHROOT/etc/
-}
-
-setup_crux() {
 
     echo "1.2.1. Set hostname and hosts;"
     cp $DIR_CONF/hosts $CHROOT/etc/
@@ -189,7 +92,6 @@ setup_crux() {
 
     echo "1.2.3. Set locale;"
     chroot $CHROOT /bin/bash -c "localedef -i en_US -f UTF-8 en_US.UTF-8"
-
     echo "1.2.4.2. Create Administrator $ADMIN_USER;"
 
     chroot $CHROOT /usr/bin/env -i \
@@ -205,7 +107,7 @@ setup_crux() {
 
     echo "1.2.5. File system table;"
     cp $DIR_CONF/fstab $CHROOT/etc/
-    blkid >> $CHROOT/etc/fstab
+    chroot $CHROOT /bin/bash -c "mount >> /etc/fstab"
     vim $CHROOT/etc/fstab
 
     echo "1.2.6. Initialization Scripts;"
@@ -213,15 +115,12 @@ setup_crux() {
     cp $DIR_CONF/rc.conf $CHROOT/etc/
     vim $CHROOT/etc/rc.conf
 
-}
-
-setup_ports() {
     echo "1.3.1. Build as unprivileged user;"
 
     chroot $CHROOT /usr/bin/env -i \
         HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
         PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "useradd -U -m -d /usr/ports -s /bin/false pkgmk"
+        /bin/bash -c "useradd -U -M -d /usr/ports -s /bin/false pkgmk"
 
     chroot $CHROOT /usr/bin/env -i \
         HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
@@ -252,9 +151,9 @@ setup_ports() {
     chroot $CHROOT /usr/bin/env -i \
         HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
         PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "id pkgmk"
+        /bin/bash -c "id pkgmk >> /etc/fstab"
 
-    read PAUSE
+    echo "pkgmk                                           /usr/ports/work tmpfs size=30G,gid=102,uid=101,defaults,mode=0750 0    0" >> $CHROOT/etc/fstab
 
     vim $CHROOT/etc/fstab
 
@@ -268,16 +167,59 @@ setup_ports() {
     #vim $CHROOT/etc/prt-get.conf
 }
 
-echo "SCRIPT=$SCRIPT";
-echo "SCRIPTPATH=$SCRIPTPATH";
+install_packages() {
 
-echo "Device: $DEV\n"
+    echo "1.1.5. Install extra packages;"
+    cp $CHROOT/media/crux/opt/* $CHROOT/usr/ports/packages
+    cp $CHROOT/media/crux/xorg/* $CHROOT/usr/ports/packages
 
-echo "1.1.2 EFI block; ($BLK_EFI)"
-echo "1.1.2 boot block; ($BLK_BOOT)"
-echo "1.1.2 root block; ($BLK_ROOT)"
-echo "1.1.2 var block; ($BLK_VAR)"
-#echo "1.1.2 swap block; ($BLK_SWP)\n"
+    echo "Installing $CHROOT/usr/ports/packages/fakeroot"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/fakeroot#*
+    echo "Installing $CHROOT/usr/ports/packages/dbus"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/dbus#*
+    echo "Installing $CHROOT/usr/ports/packages/expat"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/expat#*
+    echo "Installing $CHROOT/usr/ports/packages/libnl"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libnl#*
+    echo "Installing $CHROOT/usr/ports/packages/libpng"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libpng#*
+    echo "Installing $CHROOT/usr/ports/packages/freetype"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/freetype#*
+    echo "Installing $CHROOT/usr/ports/packages/libffi"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libffi#*
+    echo "Installing $CHROOT/usr/ports/packages/sqlite3"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/sqlite3#*
+    echo "Installing $CHROOT/usr/ports/packages/python"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/python#*
+    echo "Installing $CHROOT/usr/ports/packages/glib"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/glib#*
+    echo "Installing $CHROOT/usr/ports/packages/grub2"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/grub2#*
+    echo "Installing $CHROOT/usr/ports/packages/grub2-efi"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/grub2-efi#*
+    echo "Installing $CHROOT/usr/ports/packages/wireless-tools"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/wireless-tools#*
+    echo "Installing $CHROOT/usr/ports/packages/wpa_supplicant"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/wpa_supplicant#*
+    echo "Installing $CHROOT/usr/ports/packages/lvm2"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/lvm2#*
+    echo "Installing $CHROOT/usr/ports/packages/mdadm"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/mdadm#*
+    echo "Installing $CHROOT/usr/ports/packages/efivar"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/efivar#*
+    echo "Installing $CHROOT/usr/ports/packages/efibootmgr"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/efibootmgr#*
+    echo "Installing $CHROOT/usr/ports/packages/dosfstools"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/dosfstools#*
+
+    echo "1.1.6. Install extra ports;\n"
+
+    mkdir $CHROOT/usr/ports/c9-ports
+    cp -r $DIR_PRT/* $CHROOT/usr/ports/c9-ports/
+
+}
+echo "SCRIPT=$SCRIPT";
+echo "SCRIPTPATH=$SCRIPTPATH";
 
 echo "ADMIN_USER="$ADMIN_USER"\n"
 echo "CHROOT=$CHROOT";
@@ -287,10 +229,10 @@ echo "DIR_PRT=$DIR_PRT";
 
 echo "ISO_FILE=$ISO_FILE";
 ConfirmOrExit
-
-setup_target
-setup_bin
-setup_crux
-setup_ports
+echo "press enter to continue"
+read
+install_core
+#setup_core
+#install_packages
 
 echo "Ready to chroot $CHROOT /bin/bash \n"
diff --git a/core/scripts/setup-iso.sh b/core/scripts/setup-iso.sh
index 93858d6..e208378 100644
--- a/core/scripts/setup-iso.sh
+++ b/core/scripts/setup-iso.sh
@@ -1,17 +1,5 @@
 #!/bin/sh
 
-# Absolute path to this script, e.g. /home/user/bin/foo.sh
-SCRIPT=$(readlink -f "$0")
-# Absolute path this script is in, thus /home/user/bin
-SCRIPTPATH=$(dirname "$SCRIPT")
-
-DIR=$(dirname "$SCRIPTPATH");
-DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
-
-ISO_URL="https://serverop.de/crux/crux-3.2/iso/crux-3.2.iso"
-ISO_FILE="${DIR_LOCAL}/crux-3.2.iso"
-
-
 # First we define the function
 ConfirmOrExit ()
 {
@@ -31,9 +19,26 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
-echo "1.1.1 Path/to crux-3.2.iso:"
-echo $ISO_FILE
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+
+DIR=$(dirname "$SCRIPTPATH");
+DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
+
+ISO_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.iso"
+MD5_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.md5"
+
+ISO_FILE="${DIR_LOCAL}/crux-3.3.iso"
+MD5_FILE="${DIR_LOCAL}/crux-3.3.md5"
+
+echo "1.1.1 Paths to iso and md5 files:"
+echo "dir: ${DIR_LOCAL}"
+echo "iso url: ${ISO_URL}"
+echo "md5 url: ${MD5_URL}"
 ConfirmOrExit
+mkdir -p ${DIR_LOCAL}
 
 #prepare_iso() {
 
@@ -42,7 +47,22 @@ ConfirmOrExit
         echo "File $ISO_FILE exists."
     else
         echo "File $ISO_FILE does not exist."
-        cd $ISO_PATH && { curl -k -O $ISO_URL ; cd -; }
+        cd $DIR_LOCAL && { curl -k -O $ISO_URL ; cd -; }
+    fi
+
+    if [ -f $MD5_FILE ];
+    then
+        echo "File ${MD5_FILE} exists."
+    else
+        echo "File ${MD5_FILE} does not exist."
+        cd ${DIR_LOCAL} && { curl -k -O ${MD5_URL} ; cd -; }
+    fi
+
+    if  cd ${DIR_LOCAL} && md5sum -c ${MD5_FILE} ;
+    then
+        echo "Valid iso md5sum"
+    else
+        echo "Invalid iso md5sum"
     fi
 
 #}
diff --git a/core/scripts/setup-target.sh b/core/scripts/setup-target.sh
index e64bfe1..d46d4bb 100644..100755
--- a/core/scripts/setup-target.sh
+++ b/core/scripts/setup-target.sh
@@ -1,5 +1,36 @@
 #!/bin/sh
 
+DEV=/dev
+
+SETUP_TARGET="print"
+CHROOT="/mnt"
+
+# Absolute path to this script, e.g. /home/user/bin/foo.sh
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
+
+DIR=$(dirname "$SCRIPTPATH");
+DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
+
+ISO_FILE="${DIR_LOCAL}/crux-3.3.iso"
+
+##read BLK_EFI
+BLK_EFI="${DEV}2"
+##read BLK_BOOT
+BLK_BOOT="${DEV}3"
+##read BLK_ROOT
+BLK_ROOT="${DEV}4"
+##read BLK_VAR
+BLK_VAR="${DEV}5"
+##read BLK_USR
+BLK_USR="${DEV}6"
+##read BLK_SWP
+BLK_SWP="${DEV}7"
+##read BLK_HOME
+BLK_HOME="${DEV}8"
+
+
 # First we define the function
 ConfirmOrExit ()
 {
@@ -19,17 +50,173 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
-DEV=$1
 
-echo "Device: $DEV\n"
-ConfirmOrExit
+partition_target () {
+
+    parted --script $DEV \
+        mklabel gpt \
+        unit mib \
+        mkpart primary 1 3 \
+        name 1 grub \
+        set 1 bios_grub on \
+        mkpart ESP fat32 3 125 \
+        name 2 efi \
+        set 2 boot on \
+        mkpart primary ext4 125 1128 \
+        name 3 boot \
+        mkpart primary ext4 1128 5128 \
+        name 4 root \
+        mkpart primary ext4 5128 6128 \
+        name 5 var \
+        mkpart primary ext4 6128 14128 \
+        name 6 usr \
+        mkpart primary linux-swap 14128 18128 \
+        name 7 swap \
+        mkpart primary ext4 18128 100% \
+        name 8 home
+}
+
+mount_target () {
+    echo "1.1.2 Creating File System on $BLK_EFI with fat32:"
+    mkfs.fat -F 32 $BLK_EFI
+    echo "1.1.2 Creating File System on $BLK_BOOT with ext4:"
+    mkfs.ext4 $BLK_BOOT
+    echo "1.1.2 Creating File System on $BLK_ROOT with ext4:"
+    mkfs.ext4 $BLK_ROOT
+    echo "1.1.2 Creating File System on $BLK_VAR with ext4:"
+    mkfs.ext4 $BLK_VAR
+    echo "1.1.2 Creating File System on $BLK_USR with ext4:"
+    mkfs.ext4 $BLK_USR
+    echo "1.1.2 Creating Swap File System on $BLK_SWP:"
+    mkswap $BLK_SWP
+    echo "1.1.2 Creating File System on $BLK_HOME with ext4:"
+    mkfs.ext4 $BLK_HOME
+
+    echo "1.1.3 mount point to chroot (/mnt):\n"
+    mount $BLK_ROOT $CHROOT
+
+    mkdir -p $CHROOT/boot
+    mount $BLK_BOOT $CHROOT/boot
+
+    mkdir -p $CHROOT/boot/efi
+    mount $BLK_EFI $CHROOT/boot/efi
+
+    mkdir -p $CHROOT/var
+    mount $BLK_VAR $CHROOT/var
+
+    mkdir -p $CHROOT/usr
+    mount $BLK_USR $CHROOT/usr
+
+    mkdir -p $CHROOT/home
+    mount $BLK_HOME $CHROOT/home
+
+    mkdir -p $CHROOT/var/lib/pkg
+    mkdir -p $CHROOT/usr/ports
+
+    mkdir -p $CHROOT/media
+
+    mkdir -p $CHROOT/dev
+    mkdir -p $CHROOT/tmp
+    mkdir -p $CHROOT/proc
+    mkdir -p $CHROOT/sys
+
+}
+
+directory_target () {
+
+    mkdir -p $CHROOT/home
+    mkdir -p $CHROOT/boot/efi
+    mkdir -p $CHROOT/var/lib/pkg
+    mkdir -p $CHROOT/usr/ports
+
+    mkdir -p $CHROOT/media
+
+    mkdir -p $CHROOT/dev
+    mkdir -p $CHROOT/tmp
+    mkdir -p $CHROOT/proc
+    mkdir -p $CHROOT/sys
+
+}
+
+
+enable_target () {
+
+    mount --bind /dev $CHROOT/dev
+    mount -vt devpts devpts $CHROOT/dev/pts
+    mount -vt tmpfs shm $CHROOT/dev/shm
+    mount -vt proc proc $CHROOT/proc
+    mount -vt sysfs sysfs $CHROOT/sys
+
+    modprobe isofs
+    modprobe loop
+    mount -o loop $ISO_FILE $CHROOT/media
+}
+
+print_target() {
+    echo "Device: $DEV"
+    echo "CHROOT: $CHROOT"
+    echo "ISO_FILE: $ISO_FILE"
+    echo "Option Selected: $SETUP_TARGET\n"
+
+    echo "1.1.2 EFI block; ($BLK_EFI)"
+    echo "1.1.2 boot block; ($BLK_BOOT)"
+    echo "1.1.2 root block; ($BLK_ROOT)"
+    echo "1.1.2 var block; ($BLK_VAR)"
+    echo "1.1.2 usr block; ($BLK_USR)"
+    echo "1.1.2 swap block; ($BLK_SWP)"
+    echo "1.1.2 home block; ($BLK_HOME)\n"
+
+
+}
+
+print_help() {
+	echo "usage: setup_target [options]"
+	echo "options:"
+	echo "  -p,   --partition           create partitions and file systems"
+	echo "  -m,   --mount               mount partitions on chroot"
+	echo "  -d,   --directory           keep temporary working directory"
+        echo "  -e,   --enable              enable chroot (proc,dev, sys...)"
+	echo "  -v,   --view                view environment vars and exit"
+	echo "  -h,   --help                print help and exit"
+}
 
-parted --script $DEV \
-    mklabel gpt \
-    mkpart ESP fat32 1MiB 120MiB \
-    mkpart primary ext4 120MiB 376MiB \
-    mkpart primary ext4 376MiB 4376MiB \
-    mkpart primary ext4 4376MiB 5000MiB \
-    set 1 boot on
 
-exit 0;
+while [ "$1" ]; do
+            case $1 in
+                    -p|--partition)
+                            SETUP_TARGET="partition"
+                            print_target
+                            ConfirmOrExit
+                            partition_target
+                            exit 0 ;;
+                    -m|--mount)
+                            SETUP_TARGET="mount"
+                            print_target
+                            ConfirmOrExit
+                            mount_target
+                            exit 0 ;;
+                    -d|--directory)
+                            SETUP_TARGET="directory"
+                            print_target
+                            ConfirmOrExit
+                            directory_target
+                            exit 0 ;;
+                    -e|--enable)
+                            SETUP_TARGET="enable"
+                            print_target
+                            ConfirmOrExit
+                            enable_target
+                            exit 0 ;;
+                    -v|--view)
+                            SETUP_TARGET="view"
+                            print_target
+                            exit 0 ;;
+                    -h|--help)
+                            print_help
+                            exit 0 ;;
+                    *)
+                            echo "setup-target: invalid option $1"
+                            exit 1 ;;
+            esac
+            shift
+done