about summary refs log tree commit diff stats
path: root/core
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2018-02-25 17:33:12 +0000
committerSilvino Silva <silvino@bk.ru>2018-02-25 17:33:12 +0000
commitef1f1f61daaf59d3e07d41ddd0ea713834f35e38 (patch)
tree5a34c6b419adc87a7887db8d2e6d25119e5434c3 /core
parent080558ffff535c438d6244ff17a5d106622c754e (diff)
downloaddoc-ef1f1f61daaf59d3e07d41ddd0ea713834f35e38.tar.gz
core install revision
Diffstat (limited to 'core')
-rw-r--r--core/conf/pkgmk.conf21
-rw-r--r--core/conf/pkgmk.conf.harden94
-rw-r--r--core/conf/ports.conf1
-rw-r--r--core/conf/ports/c9-ports.git7
-rw-r--r--core/conf/ports/compat-32.pub2
-rw-r--r--core/conf/ports/contrib.git7
-rw-r--r--core/conf/ports/contrib.pub2
-rw-r--r--core/conf/ports/core.git7
-rw-r--r--core/conf/ports/core.pub2
-rwxr-xr-xcore/conf/ports/drivers/git47
-rwxr-xr-xcore/conf/ports/drivers/httpup27
-rwxr-xr-xcore/conf/ports/drivers/rsync143
-rw-r--r--core/conf/ports/opt.git6
-rw-r--r--core/conf/ports/opt.pub2
-rw-r--r--core/conf/ports/xorg.git6
-rw-r--r--core/conf/ports/xorg.pub2
-rw-r--r--core/conf/prt-get.conf6
-rw-r--r--core/conf/skel/.tmux.conf6
-rw-r--r--core/index.html4
-rw-r--r--core/install.html4
-rw-r--r--core/ports.html63
-rw-r--r--core/scripts/act-chroot.sh36
-rw-r--r--core/scripts/backup-system.sh189
-rw-r--r--core/scripts/install-core.sh131
-rw-r--r--core/scripts/setup-core.sh154
-rwxr-xr-xcore/scripts/setup-install.sh296
-rw-r--r--core/scripts/setup-iso.sh52
-rwxr-xr-xcore/scripts/setup-target.sh3
28 files changed, 854 insertions, 466 deletions
diff --git a/core/conf/pkgmk.conf b/core/conf/pkgmk.conf
index 047ebc0..94bc9df 100644
--- a/core/conf/pkgmk.conf
+++ b/core/conf/pkgmk.conf
@@ -1,21 +1,11 @@
 #
 # /etc/pkgmk.conf: pkgmk(8) configuration
 #
-# ONLY FOR x86 64 PROCESSORS
-
-export CFLAGS="-Wall -Wextra -Wno-inline -Wundef -Wformat=2 -Wformat-security -Wformat-nonliteral -Wlogical-op -Wsign-compare -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wsuggest-attribute=noreturn -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Wno-long-long -Wno-overlength-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Werror=overflow -Wdate-time -Wnested-externs"
-
-#-ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -ffunction-sections -fdata-sections -ffat-lto-objects"
-
-CFLAGS="${CFLAGS} -fPIC -fPIE -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt -fstack-check -g -O2 -march=x86-64 -pipe"
 
+export CFLAGS="-O2 -g -march=x86-64 -pipe"
 export CXXFLAGS="${CFLAGS}"
-export CPPFLAGS="-Wp,-D_FORTIFY_SOURCE=2"
-
-#export LDFLAGS="-fPIE -pie -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
-export LDFLAGS="-Wl,--as-needed -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now -pie"
 
-export MAKEFLAGS="-j$(nproc)"
+# export MAKEFLAGS="-j2"
 
 case ${PKGMK_ARCH} in
 	"64"|"")
@@ -32,11 +22,12 @@ case ${PKGMK_ARCH} in
 		;;
 esac
 
-#PKGMK_SOURCE_MIRRORS=(https://crux.nu/distfiles/)
-#PKGMK_SOURCE_MIRRORS=(https://crux.ster.zone/distfiles/)
-PKGMK_SOURCE_MIRRORS=(https://c9.root.sx/ports/distfiles/)
+#PKGMK_SOURCE_MIRRORS=(http://c9.root.sx/ports/distfiles/)
+# PKGMK_SOURCE_DIR="$PWD"
 PKGMK_SOURCE_DIR="/usr/ports/distfiles"
+# PKGMK_PACKAGE_DIR="$PWD"
 PKGMK_PACKAGE_DIR="/usr/ports/packages"
+# PKGMK_WORK_DIR="$PWD/work"
 PKGMK_WORK_DIR="/usr/ports/work/$name"
 # PKGMK_DOWNLOAD="no"
 # PKGMK_IGNORE_FOOTPRINT="no"
diff --git a/core/conf/pkgmk.conf.harden b/core/conf/pkgmk.conf.harden
new file mode 100644
index 0000000..ad95d65
--- /dev/null
+++ b/core/conf/pkgmk.conf.harden
@@ -0,0 +1,94 @@
+#
+# /etc/pkgmk.conf: pkgmk(8) configuration
+#
+# ONLY FOR x86 64 PROCESSORS
+CUSTOMVERSION=8
+
+W_CFLAGS="-Wall -Wextra -Wno-inline -Wundef -Wformat=2 -Wformat-security -Wformat-nonliteral -Wlogical-op -Wsign-compare -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wsuggest-attribute=noreturn -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Wno-long-long -Wno-overlength-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Werror=overflow -Wdate-time -Wnested-externs"
+
+#-ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -ffunction-sections -fdata-sections -ffat-lto-objects
+H_CFLAGS="-g -O1 -march=x86-64 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt -fstack-check"
+
+CFLAGS="${W_CFLAGS} ${H_CFLAGS} -fPIC -fPIE -pie"
+CXXFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
+CPPFLAGS="-O1 -Wp,-D_FORTIFY_SOURCE=2"
+#--as-needed -Wl,--no-undefined -Wl,--gc-sections -Wl
+LDFLAGS="-fPIC -fPIE -pie -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
+
+
+PIC_CFLAGS="${W_FLAGS} ${H_CFLAGS} -fPIC"
+PIC_CXXFLAGS="${PIC_CFLAGS} -D_FORTIFY_SOURCE=2"
+PIC_LDFLAGS="-fPIC -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
+
+export MAKEFLAGS="-j$(nproc)"
+
+case ${name} in
+
+	"keyutils")
+                export CFLAGS=" ${H_CFLAGS} -fPIC -fPIE -pie -g -O1 -march=x86-64 -pipe"
+                export CXXFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
+        ;;
+	"grub2")
+                export CFLAGS="${W_CFLAGS} -g -O1 -march=x86-64 -pipe"
+                export CXXFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
+                export LDFLAGS=""
+                ;;
+        "grub2-efi")
+                export CFLAGS="${W_CFLAGS} -g -O1 -march=x86-64 -pipe"
+                export CXXFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
+                export LDFLAGS=""
+                ;;
+	"gcc")
+    		export CFLAGS="-g -O2 -march=x86-64 -pipe -fPIC -fstack-protector-strong --param=ssp-buffer-size=4 -fno-plt -fstack-check"
+    		export CXXFLAGS="${CFLAGS}"
+    		export CPPFLAGS="${H_CPPFLAGS}"
+    		export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
+		;;
+	"glibc")
+       		export CFLAGS="${CFLAGS} -fno-plt -fstack-check"
+		export CXXFLAGS="${CFLAGS}"
+		export CPPFLAGS="-O1"
+		export LDFLAGS=""
+		;;
+        "libcap")
+                export CFLAGS="${PIC_CFLAGS}"
+		export CXXFLAGS="${PIC_CXXFLAGS}"
+		export LDFLAGS="${PIC_LDFLAGS}"
+                ;;
+        "mdadm")
+                export CFLAGS="${PIC_CFLAGS}"
+		export CXXFLAGS="${PIC_CXXFLAGS}"
+		export LDFLAGS="${PIC_LDFLAGS}"
+                ;;
+	"openssl")
+         	export CFLAGS="${PIC_CFLAGS}"
+		export CXXFLAGS="${PIC_CXXFLAGS}"
+		export LDFLAGS="${PIC_LDFLAGS}"
+		;;
+esac
+
+case ${PKGMK_ARCH} in
+	"64"|"")
+		;;
+	*)
+		echo "Unknown architecture selected! Exiting."
+		exit 1
+		;;
+esac
+
+#PKGMK_SOURCE_MIRRORS=(https://crux.nu/distfiles/)
+#PKGMK_SOURCE_MIRRORS=(https://crux.ster.zone/distfiles/)
+PKGMK_SOURCE_MIRRORS=(https://c9.root.sx/ports/distfiles/)
+PKGMK_SOURCE_DIR="/srv/ports/distfiles"
+PKGMK_PACKAGE_DIR="/srv/ports/packages"
+PKGMK_WORK_DIR="/srv/ports/work/$name"
+# PKGMK_DOWNLOAD="no"
+# PKGMK_IGNORE_FOOTPRINT="no"
+# PKGMK_IGNORE_NEW="no"
+# PKGMK_NO_STRIP="no"
+# PKGMK_DOWNLOAD_PROG="wget"
+# PKGMK_WGET_OPTS=""
+# PKGMK_CURL_OPTS=""
+# PKGMK_COMPRESSION_MODE="gz"
+
+# End of file
diff --git a/core/conf/ports.conf b/core/conf/ports.conf
new file mode 100644
index 0000000..4420813
--- /dev/null
+++ b/core/conf/ports.conf
@@ -0,0 +1 @@
+PORTS_DIR=/usr/ports
diff --git a/core/conf/ports/c9-ports.git b/core/conf/ports/c9-ports.git
new file mode 100644
index 0000000..392f77f
--- /dev/null
+++ b/core/conf/ports/c9-ports.git
@@ -0,0 +1,7 @@
+# Collection core
+#
+NAME=c9-ports
+URL=git://c9.root.sx/c9-ports.git
+BRANCH=develop
+destination=/usr/ports/c9-ports
+PORTS_DIR="/usr/ports"
diff --git a/core/conf/ports/compat-32.pub b/core/conf/ports/compat-32.pub
new file mode 100644
index 0000000..4ef53cc
--- /dev/null
+++ b/core/conf/ports/compat-32.pub
@@ -0,0 +1,2 @@
+untrusted comment: compat-32 public key
+RWSwxGo/zH7eXV9L7s9BhT4ZBQ6YLE+iWPkJ190GTTiP6IBBTC0XJOrM
diff --git a/core/conf/ports/contrib.git b/core/conf/ports/contrib.git
new file mode 100644
index 0000000..d9c0a7d
--- /dev/null
+++ b/core/conf/ports/contrib.git
@@ -0,0 +1,7 @@
+# Collection core
+#
+NAME=contrib
+URL=git://c9.root.sx/c9-contrib.git
+BRANCH=develop
+destination=/usr/ports/contrib
+PORTS_DIR="/usr/ports"
diff --git a/core/conf/ports/contrib.pub b/core/conf/ports/contrib.pub
new file mode 100644
index 0000000..81d31e5
--- /dev/null
+++ b/core/conf/ports/contrib.pub
@@ -0,0 +1,2 @@
+untrusted comment: contrib public key
+RWSagIOpLGJF3/J2edPyOdE4VWoyvvVvt3gdvOArUkvBrgSHjsBEdmrS
diff --git a/core/conf/ports/core.git b/core/conf/ports/core.git
new file mode 100644
index 0000000..3e23528
--- /dev/null
+++ b/core/conf/ports/core.git
@@ -0,0 +1,7 @@
+# Collection core
+#
+NAME=core
+URL=git://c9.root.sx/c9-core.git
+BRANCH=develop
+destination=/usr/ports/core
+PORTS_DIR="/usr/ports"
diff --git a/core/conf/ports/core.pub b/core/conf/ports/core.pub
new file mode 100644
index 0000000..a09d3ac
--- /dev/null
+++ b/core/conf/ports/core.pub
@@ -0,0 +1,2 @@
+untrusted comment: core public key
+RWRJc1FUaeVeqsGlEPc66dguintWWomCSORUNseged62IATuMVCK0zu6
diff --git a/core/conf/ports/drivers/git b/core/conf/ports/drivers/git
new file mode 100755
index 0000000..654a8c7
--- /dev/null
+++ b/core/conf/ports/drivers/git
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# /etc/ports/drivers/git: git driver script for ports(8)
+#
+
+if [ $# -ne 1 ]; then
+	echo "usage: $0 <file>" >&2
+	exit 1
+fi
+
+. $1
+
+if [ -z "$URL" ]; then
+	echo "URL not set in '$1'" >&2
+	exit 2
+fi
+if [ -z "$NAME" ]; then
+	echo "NAME not set in '$1'" >&2
+	exit 2
+fi
+if [ -z "$BRANCH" ]; then
+	echo "BRANCH not set in '$1'" >&2
+	exit 2
+fi
+
+REPOSITORY="$PORTS_DIR/$NAME"
+if [ -n "$LOCAL_REPOSITORY" ]; then
+	REPOSITORY="$LOCAL_REPOSITORY"
+fi
+
+echo "Fetching updates from $URL"
+echo "Updating collection $NAME"
+
+cd "$REPOSITORY" 2> "/dev/null"
+
+if [ $? -lt 1 ]; then
+	git checkout -q "$BRANCH"
+	git fetch -q
+	git diff --pretty=format: --name-status "$BRANCH" origin/"$BRANCH" | sed "s/M\t/ Edit /g; s/A\t/ Checkout /g; s/D\t/ Delete /g" | sort
+	git clean -q -f
+	git reset -q --hard origin/"$BRANCH"
+else
+	git clone -q -b "$BRANCH" "$URL" "$REPOSITORY"
+	ls -1 $REPOSITORY | sed "s/^/ Checkout /"
+fi
+
+echo "Finished successfully"
diff --git a/core/conf/ports/drivers/httpup b/core/conf/ports/drivers/httpup
new file mode 100755
index 0000000..5c8db84
--- /dev/null
+++ b/core/conf/ports/drivers/httpup
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# /etc/ports/drivers/httpup: httpup driver script for ports(8)
+# 
+
+if [ $# -ne 1 ]; then
+        echo "usage: $0 <file>" >&2
+        exit 1
+fi
+
+. $1
+
+if [ -z "$ROOT_DIR" ]; then
+	echo "ROOT_DIR not set in '$1'" >&2
+	exit 2
+fi
+if [ -z "$URL" ]; then
+	echo "URL not set in '$1'" >&2
+	exit 2
+fi
+
+for REPO in $URL; do
+    PORT=`echo $REPO | sed -n '/#.*$/s|^.*#||p'`
+    httpup sync $REPO $ROOT_DIR/$PORT
+done
+
+# End of file.
diff --git a/core/conf/ports/drivers/rsync b/core/conf/ports/drivers/rsync
new file mode 100755
index 0000000..14dd3e5
--- /dev/null
+++ b/core/conf/ports/drivers/rsync
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+#
+# /etc/ports/drivers/rsync: rsync(1) driver script for ports(8)
+#
+
+use warnings;
+use strict;
+use File::Basename;
+
+my $host = '';
+my $collection = '';
+my $destination = '';
+my %new_checkouts;
+my %old_checkouts;
+
+sub error
+{
+	my $message = shift;
+	print "Error: $message ($!)\nUpdating failed\n";
+	exit 1;
+}
+
+sub warning
+{
+	my $message = shift;
+	print "Warning: $message ($!)\n";
+}
+
+if ($#ARGV < 0)
+{
+	print "Usage: $0 <file>\n";
+	exit 1;
+}
+
+open(FILE, $ARGV[0]) or error("Couldn't open $ARGV[0]");
+while (<FILE>)
+{
+	chomp;
+	if    (/^host=(.*)/)        { $host = $1; }
+	elsif (/^collection=(.*)/)  { $collection = $1; }
+	elsif (/^destination=(.*)/) { $destination = $1; }
+}
+close(FILE);
+
+if ($host eq '')        { error("Host field not set in $ARGV[0]");        }
+if ($collection eq '')  { error("Collection field not set in $ARGV[0]");  }
+if ($destination eq '') { error("Destination field not set in $ARGV[0]"); }
+
+if (-e "$destination/.checkouts")
+{
+	# read the old .checkouts file into memory
+	open(FILE, "$destination/.checkouts") or error("Couldn't read checkouts from $destination/.checkouts");
+	while (<FILE>)
+	{
+		chomp;
+		$old_checkouts{$_} = 1;
+	}
+	close(FILE);
+}
+
+print "Updating file list from " . $host . "::$collection\n";
+
+# get the remote file list (new .checkouts)
+open(PIPE, 'rsync -crz --no-human-readable ' . $host . '::' . $collection . '|') or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+	chomp;
+
+	next if /^MOTD:/;	# ignore MOTD lines
+	s/^(.{43})//;		# ignore the first 43 characters (mode, date etc...)
+	next if /^.$/;		# ignore the . directory
+
+	$new_checkouts{$_} = 1;
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+print "Updating collection " . basename($destination) . "\n";
+
+# now really run rsync
+open(PIPE, 'rsync -crz --no-human-readable --log-format "%o %n" ' . $host . "::$collection $destination|") or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+	chomp;
+
+	if (/^recv (.*)/)
+	{
+		if ($old_checkouts{$1})
+		{
+			s/^recv/ Edit/;
+		}
+		else
+		{
+			s/^recv/ Checkout/;
+		}
+	}
+
+	print $_ . "\n";
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+# save new checkouts into .checkouts
+open(FILE, ">$destination/.checkouts") or error("Couldn't save checkouts to $destination/.checkouts");
+foreach my $checkout (sort keys %new_checkouts)
+{
+	print FILE "$checkout\n";
+}
+close(FILE);
+
+# use chroot as an additional safety measure when removing files
+chroot($destination) or error("Couldn't chroot into $destination");
+chdir('/');
+
+# iterate through old checkouts, remove obsolete files
+foreach my $checkout (sort keys %old_checkouts)
+{
+	if (!$new_checkouts{$checkout})
+	{
+		if (-f $checkout)
+		{
+			print " Delete $checkout\n";
+			unlink($checkout) or warning("Couldn't delete $checkout");
+		}
+	}
+}
+
+# iterate through old checkouts, remove obsolete directories
+foreach my $checkout (sort keys %old_checkouts)
+{
+	if (!$new_checkouts{$checkout})
+	{
+		if (-d $checkout)
+		{
+			print " Delete $checkout\n";
+			rmdir($checkout) or warning("Couldn't delete $checkout");
+		}
+	}
+}
+
+print "Finished successfully\n";
+
+# End of file
diff --git a/core/conf/ports/opt.git b/core/conf/ports/opt.git
new file mode 100644
index 0000000..bedc00c
--- /dev/null
+++ b/core/conf/ports/opt.git
@@ -0,0 +1,6 @@
+# Collection core
+#
+NAME=opt
+URL=git://c9.root.sx/c9-opt.git
+BRANCH=develop
+destination=/usr/ports/opt
diff --git a/core/conf/ports/opt.pub b/core/conf/ports/opt.pub
new file mode 100644
index 0000000..346b688
--- /dev/null
+++ b/core/conf/ports/opt.pub
@@ -0,0 +1,2 @@
+untrusted comment: opt public key
+RWSE3ohX2g5d/Zmwm/W4S8ZzNNTjXE7bI8XmnpawKOnQ+MiVa7TD0YC9
diff --git a/core/conf/ports/xorg.git b/core/conf/ports/xorg.git
new file mode 100644
index 0000000..5123db5
--- /dev/null
+++ b/core/conf/ports/xorg.git
@@ -0,0 +1,6 @@
+# Collection core
+#
+NAME=xorg
+URL=git://c9.root.sx/c9-xorg.git
+BRANCH=develop
+destination=/usr/ports/xorg
diff --git a/core/conf/ports/xorg.pub b/core/conf/ports/xorg.pub
new file mode 100644
index 0000000..983eb51
--- /dev/null
+++ b/core/conf/ports/xorg.pub
@@ -0,0 +1,2 @@
+untrusted comment: xorg public key
+RWTSGWF5Q7TndIlWcgmz/x/4xBWLbyPRmI3LyI8rsN/iahlpFpgNIwSR
diff --git a/core/conf/prt-get.conf b/core/conf/prt-get.conf
index e210ca8..9683cfe 100644
--- a/core/conf/prt-get.conf
+++ b/core/conf/prt-get.conf
@@ -16,8 +16,8 @@ prtdir /usr/ports/xorg
 #prtdir /usr/ports/compat-32
 
 # the following line enables the user maintained contrib collection
-prtdir /usr/ports/6c37-dropin
-prtdir /usr/ports/6c37
+# prtdir /usr/ports/6c37-dropin
+# prtdir /usr/ports/6c37
 
 ### use mypackage form local directory
 # prtdir /home/packages/build:mypackage
@@ -50,7 +50,7 @@ runscripts yes            # (no|yes)
 ### EXPERT SECTION ###
 
 ### alternative commands
-makecommand      sudo -H -u pkgmk -g users fakeroot pkgmk
+makecommand      sudo -H -u pkgmk fakeroot pkgmk
 addcommand       sudo pkgadd
 removecommand    sudo pkgrm
 runscriptcommand sudo sh
diff --git a/core/conf/skel/.tmux.conf b/core/conf/skel/.tmux.conf
index a68ccb2..4feb9a4 100644
--- a/core/conf/skel/.tmux.conf
+++ b/core/conf/skel/.tmux.conf
@@ -1,6 +1,9 @@
 set -g default-terminal "screen-256color"
 
 set-window-option -g mode-keys vi
+bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
+bind-key -T copy-mode-vi 'y' send-keys -X copy-selection-and-cancel
+
 
 # Vim style
 # copy tmux's selection buffer into the primary X selection with PREFIX+CTRL+Y
@@ -8,9 +11,6 @@ bind-key u run "tmux save-buffer - | xsel -ib"
 # copy primary X selection into tmux's selection buffer with PREFIX+CTRL+P
 bind-key e run "xsel -o | tmux load-buffer -"
 
-bind-key -t vi-copy 'v' begin-selection
-bind-key -t vi-copy 'y' copy-selection
-
 set-option -g set-titles on
 set-option -g set-titles-string '#S> #I.#P #W'
 
diff --git a/core/index.html b/core/index.html
index 2a8e4b9..7a1d21e 100644
--- a/core/index.html
+++ b/core/index.html
@@ -51,8 +51,8 @@
 
             <li><a href="ports.html">1.3. Ports</a>
                 <ul>
-                    <li><a href="ports.html#fakeroot">1.3.1. Build as user</a></li>
-                    <li><a href="ports.html#filesystem">1.3.2. Ports Layout</a></li>
+                    <li><a href="ports.html#filesystem">1.3.1. Ports Layout</a></li>
+                    <li><a href="ports.html#fakeroot">1.3.2. Build as user</a></li>
                     <li><a href="ports.html#pkgmk">1.3.3. Configure pkgmk</a></li>
                     <li><a href="ports.html#prtget">1.3.4. Configure prt-get</a></li>
                 </ul>
diff --git a/core/install.html b/core/install.html
index 4a7a46b..12921bf 100644
--- a/core/install.html
+++ b/core/install.html
@@ -63,7 +63,7 @@
         <p>Partition used by grub boot loader. Partition size 2M;</p>
 
         <pre>
-        mkpart primary 1 3
+        mkpart primary 2 4
         name 1 grub
         set 1 bios_grub on
         </pre>
@@ -75,7 +75,7 @@
         installations. Partition size 128M;</p>
 
         <pre>
-        (parted) mkpart ESP fat32 3 125
+        (parted) mkpart ESP fat32 4 125
         (parted) name 2 efi
         (parted) set 2 boot on
         </pre>
diff --git a/core/ports.html b/core/ports.html
index 2d1a17d..d724d76 100644
--- a/core/ports.html
+++ b/core/ports.html
@@ -13,7 +13,16 @@
         <p>This instructions are done
         <a href="configure.html#chroot">inside chroot</a>.</p>
 
-        <h2 id="fakeroot">1.3.1. Build as user</h2>
+        <h2 id="filesystem">1.3.1. Ports Layout</h2>
+
+	<p>Make sure follow directories exist;</p>
+
+	<pre>
+	#  mkdir /usr/ports
+	#  mkdir -p /usr/ports/{distfiles,packages,work,pkgbuild}
+	</pre>
+
+        <h2 id="fakeroot">1.3.2. Build as user</h2>
 
         <p>For more information read
 	<a href="https://crux.nu/Wiki/FakerootPorts">Fakeroot Ports</a>.
@@ -31,22 +40,9 @@
         </pre>
 
         <pre>
-        # chmod -R 774 /usr/ports
-        # chmod 775    /usr/ports
-        </pre>
-
-        <h2 id="filesystem">1.3.2. Ports Layout</h2>
-
-        <p>This configuration will build and save files
-        inside home directory of the user pkgmk. Work directory
-        will be mounted on ram to speed up the build process and
-        added to fstab. Let's start by creating layout directories</p>
-
-        <pre>
-        # sudo -u pkgmk mkdir /usr/ports/distfiles
-        # sudo -u pkgmk mkdir /usr/ports/packages
-        # sudo -u pkgmk mkdir /usr/ports/work
-        # sudo -u pkgmk mkdir /usr/ports/pkgbuild
+	#  chown pkgmk /usr/ports/{distfiles,packages,work,pkgbuild}
+	#  chown pkgmk:pkgmk /usr/ports/pkgbuild
+	#  chmod g+w /usr/ports/pkgbuild
         </pre>
 
         <p>Configure to
@@ -65,7 +61,6 @@
         pkgmk /usr/ports/work tmpfs size=30G,uid=102,defaults,mode=0750 0 0
         </pre>
 
-
         <h2 id="pkgmk">1.3.3. Configure pkgmk</h2>
 
         <p>Read <a href="https://crux.nu/Handbook3-3#ntoc22">4.5. Adjust/Configure the Package Build Process</a>
@@ -81,10 +76,10 @@
         # /etc/pkgmk.conf: pkgmk(8) configuration
         #
 
-        export CFLAGS="-O2 -march=x86-64"
+        export CFLAGS="-O2 -g -march=x86-64 -pipe"
         export CXXFLAGS="${CFLAGS}"
 
-        # export MAKEFLAGS="-j$(nproc)"
+        # export MAKEFLAGS="-j2"
 
         case ${PKGMK_ARCH} in
                 "64"|"")
@@ -101,13 +96,14 @@
                         ;;
         esac
 
-        # PKGMK_SOURCE_MIRRORS=()
+        #PKGMK_SOURCE_MIRRORS=(http://c9.root.sx/ports/distfiles/)
         # PKGMK_SOURCE_DIR="$PWD"
+        PKGMK_SOURCE_DIR="/usr/ports/distfiles"
         # PKGMK_PACKAGE_DIR="$PWD"
+        PKGMK_PACKAGE_DIR="/usr/ports/packages"
         # PKGMK_WORK_DIR="$PWD/work"
+        PKGMK_WORK_DIR="/usr/ports/work/$name"
         # PKGMK_DOWNLOAD="no"
-        # PKGMK_IGNORE_SIGNATURE="no"
-        # PKGMK_IGNORE_MD5SUM="no"
         # PKGMK_IGNORE_FOOTPRINT="no"
         # PKGMK_IGNORE_NEW="no"
         # PKGMK_NO_STRIP="no"
@@ -139,23 +135,20 @@
 
         # note: the order matters: the package found first is used
         prtdir /usr/ports/core
-
-        # ports described on this documentation
+        prtdir /usr/ports/opt
+        prtdir /usr/ports/contrib
         prtdir /usr/ports/c9-ports
+        prtdir /usr/ports/xorg
 
         # 6c37 team provides a collection with freetype-iu, fontconfig-iu
         # and cairo-iu ports.
-        prtdir /usr/ports/6c37
-        prtdir /usr/ports/6c37-dropin
-
-        prtdir /usr/ports/opt
-        prtdir /usr/ports/xorg
 
         # the following line enables the multilib compat-32 collection
         #prtdir /usr/ports/compat-32
 
         # the following line enables the user maintained contrib collection
-        prtdir /usr/ports/contrib
+        # prtdir /usr/ports/6c37-dropin
+        # prtdir /usr/ports/6c37
 
         ### use mypackage form local directory
         # prtdir /home/packages/build:mypackage
@@ -171,11 +164,11 @@
         ### use alternate cache file (default: /var/lib/pkg/prt-get.cache
         # cachefile /mnt/nfs/cache
 
-        ### print README information:
+        ### print readme information:
         readme verbose           # (verbose|compact|disabled)
 
         ### prefer higher versions in sysup / diff
-        preferhigher yes      # (yes|no)
+        preferhigher no     # (yes|no)
 
         ### use regexp search
         # useregex no        # (yes|no)
@@ -185,10 +178,10 @@
         runscripts yes            # (no|yes)
 
 
-        ### EXPERT SECTION ###
+        ### expert section ###
 
         ### alternative commands
-        makecommand      sudo -H -u pkgmk -g pkgmk fakeroot pkgmk
+        makecommand      sudo -h -u pkgmk fakeroot pkgmk
         addcommand       sudo pkgadd
         removecommand    sudo pkgrm
         runscriptcommand sudo sh
diff --git a/core/scripts/act-chroot.sh b/core/scripts/act-chroot.sh
index 317b5b7..29103b1 100644
--- a/core/scripts/act-chroot.sh
+++ b/core/scripts/act-chroot.sh
@@ -1,37 +1,15 @@
 #!/bin/bash
 
-
 CHROOT="/mnt"
 
-#DEV=$1
-#
-###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"
-#
-#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
+mkdir -p $CHROOT/boot/efi
+mkdir -p $CHROOT/media
+
+mkdir -p $CHROOT/dev
+mkdir -p $CHROOT/tmp
+mkdir -p $CHROOT/proc
+mkdir -p $CHROOT/sys
 
-#mount -vt devpts devpts $CHROOT/dev/pts
-#mount -vt tmpfs shm $CHROOT/dev/shm
 mount -t proc proc $CHROOT/proc
 mount -t sysfs sys $CHROOT/sys
 mount --bind /dev $CHROOT/dev
diff --git a/core/scripts/backup-system.sh b/core/scripts/backup-system.sh
index 2bced8a..49b9873 100644
--- a/core/scripts/backup-system.sh
+++ b/core/scripts/backup-system.sh
@@ -18,8 +18,47 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
+mkbk_coll_pkg() {
+    col=$1
+    # make copy of packages
+    mkdir ${PORT_PKG}/${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} >> ${DEST_DIR}/backup.pkg
+            cp /usr/ports/packages/${line} ${PORT_PKG}/${col}/
+        else
+            echo "Package not found: ${line}"
+            echo ${line} >> ${DEST_DIR}/${col}-notfound.pkg
+        fi
+    done < $DEST_DIR/${col}.pkg
+}
+
+mkbk_coll_ports() {
+    col=$1
+
+    #    tar --xattrs -zcpf $PORT_PRT/${col}-`date '+%Y-%j-%H-%M-%S'`.tar.gz \
+        #    --directory=$ROOT_DIR/usr/ports/${col} \
+        #    .
+    tar --xattrs -zcpf $PORT_PRT/${col}.tar.gz \
+        --directory=$ROOT_DIR/usr/ports/${col} \
+        --exclude=.git/ \
+        .
+
+}
+
 mkbk_metadata() {
 
+    # archive pkgutils data
+    tar --xattrs -zcpf $DATA_CNF/pkg-db.tar.gz \
+        /var/lib/pkg/db
+
     # must be using gwak instead of sed, xargs and echo
     prt-get listinst -v | sed -s s/" "/#/g | xargs -i echo {}.pkg.tar.gz > ${DEST_DIR}/installed.pkg
 
@@ -36,80 +75,141 @@ mkbk_metadata() {
 
 }
 
-mkbk_coll_pkg() {
-    col=$1
-    # make copy of packages
-    mkdir ${PORT_PKG}/${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
+mkbk_etc_conf() {
 
-            if [ -f /usr/ports/packages/${line} ]; then
-                echo "Backing up package: ${line}"
-                echo ${line} >> ${DEST_DIR}/backup.pkg
-                cp /usr/ports/packages/${line} ${PORT_PKG}/${col}/
-            else
-                echo "Package not found: ${line}"
-                echo ${line} >> ${DEST_DIR}/${col}-notfound.pkg
+    tar --xattrs -zcpf $DATA_CNF/etc.tar.gz \
+        --directory=$ROOT_DIR/etc \
+        .
+
+    tar --xattrs -zcpf $DATA_CNF/usr_etc.tar.gz \
+        --directory=$ROOT_DIR/usr/etc \
+        .
+}
+
+mkbk_srv_www() {
+
+    # backup web data first stop php and nginx
+
+    for pkg_www in ${ROOT_DIR}/srv/www/*; do
+        if [[ ! $(ls ${pkg_www} | grep -v "backup_deploy") = "" ]]; then
+            pkg_back="${DATA_SRV}/www"
+            if [ ! -d ${pkg_back} ]; then
+                mkdir -p ${pkg_back}
             fi
-    done < $DEST_DIR/${col}.pkg
+            bck_file="${pkg_back}/$(basename ${pkg_www}).tar.gz"
+            exc="${pkg_www}/backup_deploy"
+            tar --exclude ${exc} --xattrs -zcpf ${bck_file} ${pkg_www}
+        fi
+    done
 }
 
-mkbk_coll_ports() {
-    col=$1
+mkbk_srv_pgsql() {
 
-#    tar --xattrs -zcpf $PORT_PRT/${col}-`date '+%Y-%j-%H-%M-%S'`.tar.gz \
-#    --directory=$ROOT_DIR/usr/ports/${col} \
-#    .
-    tar --xattrs -zcpf $PORT_PRT/${col}.tar.gz \
-    --directory=$ROOT_DIR/usr/ports/${col} \
-    --exclude=.git/ \
-    .
+    # backup database data first dump all databases
+
+    pkg_back="${DATA_SRV}/pgsql"
+    if [ ! -d ${pkg_back} ]; then
+        mkdir -p ${pkg_back}
+    fi
+    pg_dumpall -U postgres | gzip > ${pkg_back}/cluster_dump.gz
 
+    tar --xattrs -zcpf "${pkg_back}/pgsql-conf.tar.gz" \
+        ${ROOT_DIR}/srv/pgsql/data/pg_hba.conf \
+        ${ROOT_DIR}/srv/pgsql/data/pg_ident.conf \
+        ${ROOT_DIR}/srv/pgsql/data/postgresql.conf
 }
 
-mkbk_data_conf() {
+mkbk_srv_gitolite() {
 
-    tar --xattrs -zcpf $DATA_CNF/etc.tar.gz \
-        --directory=$ROOT_DIR/etc \
-        .
+    # backup gitolite repositories
 
-    tar --xattrs -zcpf $DATA_CNF/usr_etc.tar.gz \
-        --directory=$ROOT_DIR/usr/etc \
+    pkg_back="${DATA_SRV}/gitolite"
+    if [ ! -d ${pkg_back} ]; then
+        mkdir -p ${pkg_back}
+    fi
+
+    tar --xattrs -zcpf "${pkg_back}/gitolite.tar.gz" \
+        --directory=${ROOT_DIR}/srv/gitolite \
         .
 }
 
+mkbk_user_metadata() {
+
+    for dir in /home/*; do
+        if [ "${dir}" != "/home/lost+found" ]; then
+            user=$(basename $dir)
+            tar --xattrs -zcpf "${DATA_USR}/meta-${user}.tar.gz" \
+                $dir/.bash_profile \
+                $dir/.bashrc \
+                $dir/.config \
+                $dir/.gitconfig \
+                $dir/.gnupg \
+                $dir/.irssi \
+                $dir/.lynxrc \
+                $dir/.mutt \
+                $dir/.netrc \
+                $dir/.profile \
+                $dir/.spectrwm.conf \
+                $dir/.ssh \
+                $dir/.tmux.conf \
+                $dir/.vim \
+                $dir/.vimrc \
+                $dir/.xinitrc
+
+            # encript data
+            #gpg --output "${DATA_USR}/meta-${user}.tar.gz.gpg" \
+            #    --encrypt --recipient user@host \
+            #    "${DATA_USR}/meta-${user}.tar.gz"
+
+            tar --xattrs -zcpf "${DATA_USR}/gitolite-${user}.tar.gz" \
+                $dir/gitolite-admin
+        fi
+    done
+}
 
-echo -n "root directory you want backup (/mnt/): "
+echo -n "root directory you want backup (/mnt/):\n "
 #read ROOT_DIR
 ROOT_DIR=$1
 
-echo -n "where you want to save (/home/user): "
+echo -n "where you want to save (/home/user):\n "
 DEST_DIR=$2
 
 # Temporary directory
 PORT_PKG="${DEST_DIR}/crux"
 PORT_PRT="${DEST_DIR}/ports"
 DATA_CNF="${DEST_DIR}/conf"
+DATA_USR="${DEST_DIR}/user"
+DATA_SRV="${DEST_DIR}/srv"
 
 echo "ROOT_DIR=${ROOT_DIR}"
 echo "DEST_DIR=${DEST_DIR}"
 echo "PORT_PKG=${PORT_PKG}"
 echo "PORT_PRT=${PORT_PRT}"
 echo "DATA_CNF=${DATA_CNF}"
+echo "DATA_USR=${DATA_USR}"
+echo "DATA_SRV=${DATA_SRV}"
 
 ConfirmOrExit
 
+if [ ${ROOT_DIR} == "/" ]; then
+    ROOT_DIR=""
+fi
+
 mkdir -p ${PORT_PKG}
 mkdir -p ${PORT_PRT}
 mkdir -p ${DATA_CNF}
+mkdir -p ${DATA_USR}
+mkdir -p ${DATA_SRV}
 
+# Light backup data
 mkbk_metadata
-mkbk_data_conf
+mkbk_etc_conf
+mkbk_user_metadata
+mkbk_srv_www
+mkbk_srv_pgsql
+mkbk_srv_gitolite
 
+# Port system
 mkbk_coll_ports "core"
 mkbk_coll_pkg "core"
 mkbk_coll_ports "opt"
@@ -121,20 +221,3 @@ mkbk_coll_pkg "xorg"
 
 mkbk_coll_pkg "other"
 
-#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/install-core.sh b/core/scripts/install-core.sh
new file mode 100644
index 0000000..8e61448
--- /dev/null
+++ b/core/scripts/install-core.sh
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+CHROOT="/mnt"
+PORT_PKG="${CHROOT}/media/crux"
+
+#echo "1.1.8. Install Handbook\n"
+#cp ${PORT_PKG}/handbook.txt $CHROOT/root/
+
+ConfirmOrExit()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
+
+
+install_core() {
+
+    mkdir -p ${CHROOT}/var/lib/pkg
+    touch ${CHROOT}/var/lib/pkg/db
+
+    CORE_LS="${DATA_DIR}/core.pkg"
+
+    if [ ! -f ${CORE_LS} ]; then
+        CORE_LS=${CHROOT}/core.pkg
+        echo "1.1.4 Create core.pkg and install pkgadd"
+        for p in ${PORT_PKG}/core/*;
+        do
+            echo $(basename $p) >> ${CORE_LS};
+        done
+    fi
+
+    tar xf "${PORT_PKG}/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}/pkgadd
+
+    chmod +x ${CHROOT}/pkgadd
+
+    echo "1.1.4 File core.pkg complete, review list of packages before continue..."
+    read PAUSE
+    vim ${CORE_LS}
+
+    echo "1.1.4 Starting install"
+
+    #cd $CHROOT
+    while read line; do
+        pkg=${PORT_PKG}/core/${line}
+        echo "Installing ${pkg};\n"
+        ${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg}
+    done < ${CORE_LS}
+
+    rm ${CHROOT}/pkgadd
+
+    if [ -f ${CHROOT}/core.pkg ]; then
+        rm ${CHROOT}/core.pkg;
+    fi
+}
+
+install_packages() {
+    echo "Installing $CHROOT/media/crux/opt/fakeroot"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/fakeroot#*
+    echo "Installing $CHROOT/media/crux/opt/dbus"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/dbus#*
+    echo "Installing $CHROOT/media/crux/opt/expat"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/expat#*
+    echo "Installing $CHROOT/media/crux/opt/libnl"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libnl#*
+    echo "Installing $CHROOT/media/crux/opt/libpng"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libpng#*
+    echo "Installing $CHROOT/media/crux/opt/freetype"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/freetype#*
+    echo "Installing $CHROOT/media/crux/opt/libffi"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libffi#*
+    echo "Installing $CHROOT/media/crux/opt/sqlite3"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/sqlite3#*
+    echo "Installing $CHROOT/media/crux/opt/python"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/python#*
+    echo "Installing $CHROOT/media/crux/opt/glib"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/glib#*
+    echo "Installing $CHROOT/media/crux/opt/grub2"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/grub2#*
+    echo "Installing $CHROOT/media/crux/opt/grub2-efi"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/grub2-efi#*
+    echo "Installing $CHROOT/media/crux/opt/wireless-tools"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/wireless-tools#*
+    echo "Installing $CHROOT/media/crux/opt/wpa_supplicant"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/wpa_supplicant#*
+    echo "Installing $CHROOT/media/crux/opt/lvm2"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/lvm2#*
+    echo "Installing $CHROOT/media/crux/opt/mdadm"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/mdadm#*
+    echo "Installing $CHROOT/media/crux/opt/efivar"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/efivar#*
+    echo "Installing $CHROOT/media/crux/opt/efibootmgr"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/efibootmgr#*
+    echo "Installing $CHROOT/media/crux/opt/dosfstools"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/dosfstools#*
+    echo "Installing $CHROOT/media/crux/opt/parted"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/parted#*
+    echo "Installing $CHROOT/media/crux/opt/libgcrypt"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libgcrypt#*
+    echo "Installing $CHROOT/media/crux/opt/cryptsetup"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/cryptsetup#*
+    echo "Installing $CHROOT/media/crux/opt/popt"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/popt#*
+    echo "Installing $CHROOT/media/crux/opt/libgpg-error"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libgpg-error#*
+    echo "Installing $CHROOT/media/crux/opt/libevent"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libevent#*
+    echo "Installing $CHROOT/media/crux/opt/libtirpc"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/libtirpc#*
+    echo "Installing $CHROOT/media/crux/opt/git"
+    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/media/crux/opt/git#*
+
+}
+
+echo "PORT_PKG=${PORT_PKG}";
+echo "CHROOT=$CHROOT";
+
+ConfirmOrExit
+install_core
+install_packages
diff --git a/core/scripts/setup-core.sh b/core/scripts/setup-core.sh
new file mode 100644
index 0000000..8a85d4a
--- /dev/null
+++ b/core/scripts/setup-core.sh
@@ -0,0 +1,154 @@
+#!/bin/bash
+
+# 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,
+# e.g. /home/user/c9-doc/core/scripts
+SCRIPTPATH=$(dirname "$SCRIPT")
+# Absolute path to doc section,
+# e.g /home/user/c9-doc/core
+DIR_DATA=$(dirname "$SCRIPTPATH");
+
+CHROOT="/mnt"
+DATA_CNF="${DIR_DATA}/conf"
+ADMIN_USER="c9admin"
+
+ConfirmOrExit()
+{
+    while true
+    do
+	echo -n "Please confirm (y or n) :"
+	read CONFIRM
+	case $CONFIRM in
+	    y|Y|YES|yes|Yes) break ;;
+	    n|N|no|NO|No)
+		echo "Aborting - you entered $CONFIRM"
+		exit
+		;;
+	    *) echo "Please enter only y or n"
+	esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
+
+setup_core() {
+
+    echo "1.1. Copying configuration data;\n"
+    if [ -f "${DATA_CNF}/etc.tar.gz" ]; then
+	echo "1.1. Extracting configuration data;\n"
+	tar --xattrs -xpvf $DATA_CNF/etc.tar.gz --directory=$CHROOT/etc
+	tar --xattrs -xpvf $DATA_CNF/usr_etc.tar.gz --directory=$CHROOT/usr/etc
+    else
+	echo "1.1.7. dns resolver, copy resolv.conf;\n"
+	cp /etc/resolv.conf $CHROOT/etc
+
+	echo "1.1.9. Install Skeletons\n"
+	cp -r $DATA_CNF/skel $CHROOT/etc/
+
+	cp $DATA_CNF/sudoers $CHROOT/etc/
+
+	echo "1.2.1. Set hostname and hosts;"
+	cp $DATA_CNF/hosts $CHROOT/etc/
+
+	echo "1.2.5. File system table;"
+	cp $DATA_CNF/fstab $CHROOT/etc/
+	chroot $CHROOT /bin/bash -c "mount >> /etc/fstab"
+
+	echo "1.2.6. Initialization Scripts;"
+	cp $DATA_CNF/rc.d/* $CHROOT/etc/rc.d/
+	cp $DATA_CNF/rc.conf $CHROOT/etc/
+
+	echo "1.3 Install Ports;"
+	rm -fr $CHROOT/etc/ports
+	cp -r $DATA_CNF/ports $CHROOT/etc/ports
+	cp $DATA_CNF/ports.conf $CHROOT/etc/ports.conf
+
+	echo "1.3.3 Configure pkgmk;"
+	cp $DATA_CNF/pkgmk.conf $CHROOT/etc/pkgmk.conf
+	cp $DATA_CNF/pkgmk.conf.harden $CHROOT/etc/pkgmk.conf.harden
+
+	echo "1.3.4 Configure prt-get;"
+	cp $DATA_CNF/prt-get.conf $CHROOT/etc/
+
+    fi
+
+    echo "1.2.2. Set timezone;"
+    chroot $CHROOT /bin/bash -c tzselect
+
+    echo "1.2.3. Set locale;"
+    chroot $CHROOT /bin/bash -c "localedef -i en_US -f UTF-8 en_US.UTF-8"
+}
+
+setup_users(){
+    echo "1.2.4.2. Create Administrator $ADMIN_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 -k /etc/skel -s /bin/bash $ADMIN_USER"
+
+    echo "1.2.4.3. Add Administrator $ADMIN_USER to wheel group;"
+    chroot $CHROOT /bin/bash -c "usermod -a -G wheel $ADMIN_USER"
+    echo "1.2.4.3. Uncomment to allow members of group wheel to execute any command\n
+    #    %wheel ALL=(ALL) ALL"
+
+    echo "1.3.1. Ports Layout;"
+
+    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/{work,distfiles,packages,work,pkgbuild}"
+
+    echo "1.3.2. 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"
+
+    chroot $CHROOT /usr/bin/env -i \
+	HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+	/bin/bash -c "usermod -a -G pkgmk $ADMIN_USER"
+
+    chroot $CHROOT /usr/bin/env -i \
+	HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+	/bin/bash -c "chown pkgmk /usr/ports/{distfiles,packages,work,pkgbuild}"
+
+    chroot $CHROOT /usr/bin/env -i \
+	HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+	/bin/bash -c "chown pkgmk:pkgmk /usr/ports/pkgbuild"
+
+    chroot $CHROOT /usr/bin/env -i \
+	HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+	/bin/bash -c "chmod g+w /usr/ports/pkgbuild"
+
+    PKGMK_WRK="pkgmk   /usr/ports/work tmpfs size=30G,gid=$(id -g pkgmk),uid=$(id -u pkgmk),defaults,mode=0750 0    0 >> /etc/fstab"
+
+    chroot $CHROOT /usr/bin/env -i \
+	HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
+	PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+	/bin/bash -c "echo ${PKGMK_WRK} >> /etc/fstab"
+}
+
+setup_config(){
+    vim $CHROOT/etc/rc.conf
+    vim $CHROOT/etc/hosts
+    vim $CHROOT/etc/resolv.conf
+    vim $CHROOT/etc/fstab
+
+    vim $CHROOT/etc/pkgmk.conf
+    vim $CHROOT/etc/prt-get.conf
+}
+
+echo "ADMIN_USER=${ADMIN_USER}";
+echo "CHROOT=${CHROOT}";
+echo "DATA_CNF=${DATA_CNF}";
+
+ConfirmOrExit
+
+setup_core
+setup_users
+setup_config
diff --git a/core/scripts/setup-install.sh b/core/scripts/setup-install.sh
deleted file mode 100755
index aca0115..0000000
--- a/core/scripts/setup-install.sh
+++ /dev/null
@@ -1,296 +0,0 @@
-#!/bin/bash
-
-# 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,
-# e.g. /home/user/c9-doc/core/scripts
-SCRIPTPATH=$(dirname "$SCRIPT")
-# Absolute path to doc section,
-# e.g /home/user/c9-doc/core
-DIR_SCRIPT=$(dirname "$SCRIPTPATH");
-# Absolute path to local data,
-# e.g /home/user/local
-DIR_LOCAL="$(dirname $(dirname ${DIR_SCRIPT}))/local";
-
-# Set Global Vars
-ADMIN_USER=c9admin
-CHROOT=$1
-
-# DATA_DIR directory with data to
-# to be installed, can be mounted
-# iso file or backup directory from
-# backup-system script
-# from iso monted;
-DATA_DIR=$(dirname "$SCRIPTPATH");
-PORT_PKG="${CHROOT}/media/crux"
-# from backup;
-#DATA_DIR=$2
-#PORT_PKG="${DATA_DIR}/crux"
-
-ConfirmOrExit()
-{
-    while true
-    do
-        echo -n "Please confirm (y or n) :"
-        read CONFIRM
-        case $CONFIRM in
-            y|Y|YES|yes|Yes) break ;;
-            n|N|no|NO|No)
-                echo "Aborting - you entered $CONFIRM"
-                exit
-                ;;
-            *) echo "Please enter only y or n"
-        esac
-    done
-    echo "You entered $CONFIRM. Continuing ..."
-}
-
-
-install_core() {
-
-    mkdir -p ${CHROOT}/usr/ports/packages
-    mkdir -p ${CHROOT}/var/lib/pkg
-    touch ${CHROOT}/var/lib/pkg/db
-
-    CORE_LS="${DATA_DIR}/core.pkg"
-
-    if [ ! -f ${CORE_LS} ]; then
-        CORE_LS=${CHROOT}/core.pkg
-        echo "1.1.4 Create core.pkg and install pkgadd"
-        for p in ${PORT_PKG}/core/*;
-        do
-            echo $(basename $p) >> ${CORE_LS};
-        done
-    fi
-
-    tar xf "${PORT_PKG}/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}/pkgadd
-
-    chmod +x ${CHROOT}/pkgadd
-
-    echo "1.1.4 File core.pkg complete, review list of packages before continue..."
-    read PAUSE
-    vim ${CORE_LS}
-
-    echo "1.1.4 Starting install"
-
-    #cd $CHROOT
-    while read line; do
-        pkg=${PORT_PKG}/core/${line}
-        echo "Installing ${pkg};\n"
-        ${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg}
-    done < ${CORE_LS}
-
-    rm ${CHROOT}/pkgadd
-
-    if [ -f ${CHROOT}/core.pkg ]; then
-        rm ${CHROOT}/core.pkg;
-    fi
-}
-
-install_ports()
-{
-
-    echo "1.1.5. Install core packages and ports;"
-    cp ${PORT_PKG}/core/* ${CHROOT}/usr/ports/packages
-    if [ -f "${PORT_PRT}/core.tar.gz" ]; then
-        mkdir -p ${CHROOT}/usr/ports/core
-        tar --xattrs -xpvf $PORT_PRT/core.tar.gz --directory=$CHROOT/usr/ports/core
-    fi
-
-    echo "1.1.5. Install opt packages and ports;"
-    cp ${PORT_PKG}/opt/* $CHROOT/usr/ports/packages
-    if [ -f "${PORT_PRT}/opt.tar.gz" ]; then
-        mkdir -p ${CHROOT}/usr/ports/opt
-        tar --xattrs -xpvf $PORT_PRT/opt.tar.gz --directory=$CHROOT/usr/ports/opt
-    fi
-
-    echo "1.1.5. Install contrib packages and ports;"
-    cp ${PORT_PKG}/contrib/* $CHROOT/usr/ports/packages
-    if [ -f "${PORT_PRT}/contrib.tar.gz" ]; then
-        mkdir -p ${CHROOT}/usr/ports/contrib
-        tar --xattrs -xpvf $PORT_PRT/contrib.tar.gz --directory=$CHROOT/usr/ports/contrib
-    fi
-
-
-    echo "1.1.5. Install xorg packages and ports;"
-    cp ${PORT_PKG}/xorg/* $CHROOT/usr/ports/packages
-    if [ -f "${PORT_PRT}/xorg.tar.gz" ]; then
-        mkdir -p ${CHROOT}/usr/ports/xorg
-        tar --xattrs -xpvf $PORT_PRT/xorg.tar.gz --directory=$CHROOT/usr/ports/xorg
-    fi
-
-    echo "1.1.6. Install extra packages;"
-    cp ${PORT_PKG}/other/* $CHROOT/usr/ports/packages
-}
-
-setup_core() {
-
-    if [ -f "${DATA_CNF}/etc.tar.gz" ]; then
-        echo "1.1. Extracting configuration data;\n"
-        tar --xattrs -xpvf $DATA_CNF/etc.tar.gz --directory=$CHROOT/etc
-        tar --xattrs -xpvf $DATA_CNF/usr_etc.tar.gz --directory=$CHROOT/usr/etc
-    else
-        echo "1.1. Copying configuration data;\n"
-        cp -r $DATA_CNF/skel $CHROOT/etc/
-        cp ${PORT_PKG}/handbook.txt $CHROOT/root/
-        cp /etc/resolv.conf $CHROOT/etc
-        cp $DATA_CNF/fstab $CHROOT/etc/
-        cp $DATA_CNF/prt-get.conf $CHROOT/etc/
-        cp $DATA_CNF/sudoers $CHROOT/etc/
-        cp $DATA_CNF/rc.d/* $CHROOT/etc/rc.d/
-        cp $DATA_CNF/rc.conf $CHROOT/etc/
-        cp $DATA_CNF/pkgmk.conf $CHROOT/etc/
-        cp $DATA_CNF/hosts $CHROOT/etc/
-
-    fi
-
-    echo "1.1.7. dns resolver, copy resolv.conf;\n"
-    vim /etc/resolv.conf
-
-    echo "1.1.8. Install Handbook\n"
-
-    echo "1.1.9. Install Skeletons\n"
-
-    echo "1.2.1. Set hostname and hosts;"
-    vim $CHROOT/etc/hosts
-
-    echo "1.2.2. Set timezone;"
-    chroot $CHROOT /bin/bash -c tzselect
-
-    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 \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "useradd -U -m -k /etc/skel -s /bin/bash $ADMIN_USER"
-
-    echo "1.2.4.3. Add Administrator $ADMIN_USER to wheel group;"
-    chroot $CHROOT /bin/bash -c "usermod -a -G wheel $ADMIN_USER"
-    echo "1.2.4.3. Uncomment to allow members of group wheel to execute any command\n
-    #    %wheel ALL=(ALL) ALL"
-
-    echo "1.2.5. File system table;"
-
-    chroot $CHROOT /bin/bash -c "mount >> /etc/fstab"
-
-    chroot $CHROOT /usr/bin/env -i \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "pkgmk   /usr/ports/work tmpfs size=30G,gid=$(id -g pkgmk),uid=$(id pkgmk),defaults,mode=0750 0    0 >> /etc/fstab"
-
-    vim $CHROOT/etc/fstab
-
-    echo "1.2.6. Initialization Scripts;"
-    vim $CHROOT/etc/rc.conf
-
-    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"
-
-    chroot $CHROOT /usr/bin/env -i \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "usermod -a -G pkgmk $ADMIN_USER"
-
-    chroot $CHROOT /usr/bin/env -i \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "chown -R pkgmk:pkgmk /usr/ports"
-
-    chroot $CHROOT /usr/bin/env -i \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "chmod -R 774 /usr/ports"
-
-    chroot $CHROOT /usr/bin/env -i \
-        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
-        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-        /bin/bash -c "chmod 775 /usr/ports"
-
-    echo "1.3.2. Ports Layout;"
-
-    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/work"
-    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/pkgbuild"
-    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/distfiles"
-
-    echo "1.3.3 Configure pkgmk;"
-    #vim $CHROOT/etc/pkgmk.conf
-
-    echo "1.3.4 Configure prt-get;"
-    mv $CHROOT/etc/ports/contrib.rsync.inactive $CHROOT/etc/ports/contrib.rsync
-    #vim $CHROOT/etc/prt-get.conf
-}
-
-
-install_packages() {
-
-    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#*
-
-}
-
-
-DATA_CNF="${DATA_DIR}/conf"
-PORT_PRT="${DATA_DIR}/ports";
-
-#echo "SCRIPT=$SCRIPT";
-echo "SCRIPTPATH=$SCRIPTPATH";
-
-echo "ADMIN_USER=${ADMIN_USER}"
-echo "CHROOT=$CHROOT";
-
-echo "DATA_DIR=$DATA_DIR";
-echo "DATA_CNF=$DATA_CNF";
-echo "PORT_PKG=${PORT_PKG}";
-echo "PORT_PRT=${PORT_PRT}";
-
-ConfirmOrExit
-
-install_core
-install_ports
-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 e208378..11a38bc 100644
--- a/core/scripts/setup-iso.sh
+++ b/core/scripts/setup-iso.sh
@@ -1,5 +1,16 @@
 #!/bin/sh
 
+ISO_DIR=$1
+CHROOT="/mnt"
+
+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="${ISO_DIR}/crux-3.3.iso"
+MD5_FILE="${ISO_DIR}/crux-3.3.md5"
+
+
+
 # First we define the function
 ConfirmOrExit ()
 {
@@ -19,35 +30,16 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
-# 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"
+prepare_iso() {
 
-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() {
+    mkdir -p ${ISO_DIR}
 
     if [ -f $ISO_FILE ];
     then
         echo "File $ISO_FILE exists."
     else
         echo "File $ISO_FILE does not exist."
-        cd $DIR_LOCAL && { curl -k -O $ISO_URL ; cd -; }
+        cd $ISO_DIR && { curl -k -O $ISO_URL ; cd -; }
     fi
 
     if [ -f $MD5_FILE ];
@@ -55,15 +47,25 @@ mkdir -p ${DIR_LOCAL}
         echo "File ${MD5_FILE} exists."
     else
         echo "File ${MD5_FILE} does not exist."
-        cd ${DIR_LOCAL} && { curl -k -O ${MD5_URL} ; cd -; }
+        cd ${ISO_DIR} && { curl -k -O ${MD5_URL} ; cd -; }
     fi
 
-    if  cd ${DIR_LOCAL} && md5sum -c ${MD5_FILE} ;
+    if  cd ${ISO_DIR} && md5sum -c ${MD5_FILE} ;
     then
         echo "Valid iso md5sum"
     else
         echo "Invalid iso md5sum"
     fi
 
-#}
+    modprobe isofs
+    modprobe loop
+    mount -o loop $ISO_FILE $CHROOT/media
+}
 
+echo "1.1.1 Paths to iso and md5 files:"
+echo "dir: ${ISO_DIR}"
+echo "iso url: ${ISO_URL}"
+echo "md5 url: ${MD5_URL}"
+
+ConfirmOrExit
+prepare_iso
diff --git a/core/scripts/setup-target.sh b/core/scripts/setup-target.sh
index d46d4bb..b0828e5 100755
--- a/core/scripts/setup-target.sh
+++ b/core/scripts/setup-target.sh
@@ -147,9 +147,6 @@ enable_target () {
     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() {