summaryrefslogtreecommitdiffstats
path: root/core/rootfs
diff options
context:
space:
mode:
authorSebastian2016-04-25 12:01:08 +0200
committerSebastian2016-04-25 12:01:08 +0200
commit5acda3eaeabae9045609539303a8c12c4ce401f1 (patch)
tree7e71975f8570b05aafe2ea6ec0e242a8912387bb /core/rootfs
parentinitial commit (diff)
downloadmltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.gz
mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.xz
mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.zip
merge with latest dev version
Diffstat (limited to 'core/rootfs')
-rw-r--r--core/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf5
-rw-r--r--core/rootfs/rootfs-stage31/data/etc/modules68
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/activate_sysconfig98
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/drm.functions80
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/functions84
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/network.functions23
-rwxr-xr-xcore/rootfs/rootfs-stage31/data/inc/ntp_sync26
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/parse_kcl58
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/setup_network84
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/setup_network_retry33
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/setup_stage3268
-rw-r--r--core/rootfs/rootfs-stage31/data/inc/setup_stage469
-rwxr-xr-xcore/rootfs/rootfs-stage31/data/inc/udhcpc-trigger93
-rwxr-xr-xcore/rootfs/rootfs-stage31/data/init166
-rw-r--r--core/rootfs/rootfs-stage31/module.build74
-rw-r--r--core/rootfs/rootfs-stage31/module.conf74
-rw-r--r--core/rootfs/rootfs-stage31/module.conf.centos3
-rw-r--r--core/rootfs/rootfs-stage31/module.conf.debian3
-rw-r--r--core/rootfs/rootfs-stage31/module.conf.fedora3
-rw-r--r--core/rootfs/rootfs-stage31/module.conf.ubuntu3
-rw-r--r--core/rootfs/rootfs-stage31/templates/drm.cfg19
-rw-r--r--core/rootfs/rootfs-stage32/TODO4
l---------core/rootfs/rootfs-stage32/data/bin/ash1
l---------core/rootfs/rootfs-stage32/data/bin/sh1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/conf.d/nfs-common.conf7
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/hosts8
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/keymaps/de_DEbin0 -> 2823 bytes
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/modprobe.d/50-mltk-blacklist.conf11
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/nsswitch.conf19
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/profile56
l---------core/rootfs/rootfs-stage32/data/etc/resolv.conf1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/early-network-triggers.service13
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/graphical.target.wants/killsplash.service1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service9
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service11
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/network-dns.target4
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/network-gateway.target4
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/rpc-statd.service9
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/rpcbind.service11
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service11
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service10
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addons.service11
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target5
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/early-network-triggers.service1
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service1
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service1
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service1
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/update-etc_issue.service1
l---------core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/zram-swap.service1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/tmp.target5
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service9
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/systemd/system/zram-swap.service10
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/terminfo/l/linuxbin0 -> 1790 bytes
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/terminfo/x/xtermbin0 -> 3371 bytes
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm-256colorbin0 -> 3437 bytes
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/network.conf1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/openslx-log.conf1
-rw-r--r--core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf2
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/bin/penv7
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog76
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue25
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-early_network_triggers29
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver22
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage471
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions168
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons94
-rwxr-xr-xcore/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap60
-rw-r--r--core/rootfs/rootfs-stage32/data/root/.bashrc48
-rw-r--r--core/rootfs/rootfs-stage32/module.build146
-rw-r--r--core/rootfs/rootfs-stage32/module.conf261
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.centos16
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.debian19
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.fedora16
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.opensuse22
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.opensuse.13.120
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.opensuse.13.220
-rw-r--r--core/rootfs/rootfs-stage32/module.conf.ubuntu21
-rw-r--r--core/rootfs/rootfs-stage32/rdns.c28
-rw-r--r--core/rootfs/rootfs-stage32/templates/issue.template9
80 files changed, 2554 insertions, 0 deletions
diff --git a/core/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf b/core/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf
new file mode 100644
index 00000000..ebc4b49c
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/etc/modprobe.d/vmwgfx-fbdev.conf
@@ -0,0 +1,5 @@
+# when vmwgfx is loaded via modprobe in stage31, this conf file is read,
+# enables fbdev support for vmware so that
+# fb doesnt break when switching tty's in minilinux running inside vmware
+options vmwgfx enable_fbdev=1
+
diff --git a/core/rootfs/rootfs-stage31/data/etc/modules b/core/rootfs/rootfs-stage31/data/etc/modules
new file mode 100644
index 00000000..e728c600
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/etc/modules
@@ -0,0 +1,68 @@
+8139cp
+8139too
+acenic
+adp8860_bl
+adp8870_bl
+atl1
+atl1c
+atl1e
+atl2
+atp
+b44
+bna
+bnx2
+bnx2x
+cnic
+cxgb
+cxgb3
+cxgb4
+cxgb4vf
+de2104x
+dl2k
+dmfe
+dnet
+e100
+e1000
+e1000e
+forcedeth
+hid-generic
+hp100
+igb
+igbvf
+ipg
+ixgb
+ixgbe
+ixgbevf
+jme
+ksz884x
+myri10ge
+nbd
+ne2k-pci
+parport
+pcnet32
+qla3xxx
+qlge
+r6040
+r8169
+s2io
+sc92031
+sfc
+sis190
+sis900
+skge
+sky2
+smsc9420
+squashfs
+sunhme
+tg3
+tlan
+tulip
+typhoon
+uli526x
+usbhid
+via-rhine
+via-velocity
+vmxnet3
+vxge
+xfs
+xircom_cb
diff --git a/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig b/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig
new file mode 100644
index 00000000..c9b74791
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/activate_sysconfig
@@ -0,0 +1,98 @@
+#!/bin/ash
+
+echo "Configuring stage 3.2 ..."
+
+# first a few variables
+CONFIG="${FUTURE_ROOT}/opt/openslx/config"
+
+#########################################################################
+#
+# This function downloads the config containing environment variables
+#
+fetch_sysconfig() {
+ [ -e "$CONFIG" ] && grep -E '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \
+ && echo "Config already fetched." && return 0
+
+ download "${SLX_BASE_PATH}/config" "${CONFIG}-remote" || return 1
+
+ echo "# Config fetched from $URL" >> "$CONFIG"
+ echo "#_RCONFIG_TAG" >> "$CONFIG"
+ cat "${CONFIG}-remote" >> "$CONFIG"
+}
+#########################################################################
+#
+# This function downloads the config.tgz and unpacks it to $TARGET_PATH <-- no it doesn't!
+#
+fetch_config_files() {
+ [ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && return 0
+
+ download "${SLX_BASE_PATH}/config.tgz" "${CONFIG}.tgz"
+}
+
+
+#########################################################################
+#
+# This function updates the downloaded config with the IP information
+# received from /inc/setup_network <-- plus 500 other things
+update_sysconfig() {
+ # sanity checks
+ [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; }
+
+ # write IP and SLX_SERVER configuration to $CONFIG
+cat >> "$CONFIG" <<HEREEND
+# IP Config written in stage31
+SLX_PXE_CLIENT_IP='$CLIENTIP'
+SLX_PXE_SERVER_IP='$SERVERIP'
+SLX_PXE_GATEWAY='$GATEWAY'
+SLX_PXE_DNS='$DNS_SERVER'
+SLX_PXE_MAC='$BRIDGEMAC'
+HEREEND
+
+ [ ! -e "${CONFIG}.tgz" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; }
+
+ # setup hardware clock
+ . "${CONFIG}"
+ if [ "x$SLX_BIOS_CLOCK" == "xlocal" ]; then
+ hwclock -s -l
+ elif [ "x$SLX_BIOS_CLOCK" == "xutc" ]; then
+ hwclock -s -u
+ fi
+
+ local TEMP_EXTRACT_DIR="/tmp/config.tgz.tmp"
+ # TODO perserve existing directories permissions (but overwrite the permissions of files!)
+ mkdir -p "${TEMP_EXTRACT_DIR}"
+ tar xf "${CONFIG}.tgz" -C "${TEMP_EXTRACT_DIR}" || { echo "Could not untar ${CONFIG}.tgz to ${TEMP_EXTRACT_DIR}"; return 1; }
+ chown -R 0:0 "${TEMP_EXTRACT_DIR}" 2>/dev/null
+ cd "${TEMP_EXTRACT_DIR}"
+ # first we look for local config.tgz files, which we merge with the common
+ # config.tgz files
+ local LOCAL_CONFIG_DIR="openslx-configs/${SLX_LOCAL_CONFIG}"
+ if [ -n "${SLX_LOCAL_CONFIG}" -a -d "${LOCAL_CONFIG_DIR}" ]; then
+ tarcopy "${LOCAL_CONFIG_DIR}" "${TEMP_EXTRACT_DIR}"
+ echo "Merged local configuration files for '${SLX_LOCAL_CONFIG}'"
+ fi
+ # purge openslx-configs/*
+ rm -rf -- "openslx-configs/"
+ # now just tarcopy them to future root
+ tarcopy "${TEMP_EXTRACT_DIR}" "${FUTURE_ROOT}"
+ # cleanup the downloaded stuff
+ cd /
+ rm -rf -- "${TEMP_EXTRACT_DIR}"
+ [ $DEBUG -eq 0 ] && rm -f -- "${CONFIG}.tgz"
+ # Display branding logo if splash screen is shown
+ [ "x${MUTED_OUTPUT}" = "x1" ] && [ -e "${FUTURE_ROOT}/etc/branding.ppm" ] && fbsplash -s "${FUTURE_ROOT}/etc/branding.ppm" &
+ return 0
+}
+
+
+#########################################################################
+#
+# MAIN PART
+#
+
+fetch_sysconfig || drop_shell "Could not download remote config"
+. "${CONFIG}-remote" || drop_shell "Could not source remote config"
+fetch_config_files || drop_shell "Could not download config.tgz"
+update_sysconfig || drop_shell "Could not update sysconfig"
+true
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/drm.functions b/core/rootfs/rootfs-stage31/data/inc/drm.functions
new file mode 100644
index 00000000..c62c562b
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/drm.functions
@@ -0,0 +1,80 @@
+
+# pass module name(s) relative path in /lib/modules with .ko extension, or special like @nvidia or @amd
+load_gfx () {
+ local MOD FILES OFFSET RETVAL
+ RETVAL=1 # default: failure
+ while [ $# -gt 0 ]; do
+ MOD=$(echo $1) # trim :)
+ shift
+ [ -z "$MOD" ] && continue
+ if [ "x${MOD}" != "x${MOD#@}" ]; then
+ # starts with '@' - special
+ OFFSET=$(( ${#MOD} + 2 ))
+ FILES=$( grep "^$MOD\s" "/drm.cfg" | cut -c ${OFFSET}- )
+ [ -z "$FILES" ] && drop_shell "Could not find entry for special $MOD"
+ if load_gfx $FILES; then
+ RETVAL=0
+ else
+ # loading special case failed, try fallback if found
+ MOD="${MOD}_fallback"
+ OFFSET=$(( ${#MOD} + 2 ))
+ FILES=$( grep "^$MOD\s" "/drm.cfg" | cut -c ${OFFSET}- )
+ [ -n "$FILES" ] && load_gfx $FILES && RETVAL=0
+ fi
+ else # regular module name or filename
+ if [ "x${MOD%.ko}" == "x${MOD}" ]; then
+ # regular module name
+ modprobe "$MOD" && RETVAL=0
+ else
+ # a .ko file
+ insmod "/lib/modules/$MOD" && RETVAL=0
+ fi
+ fi
+ done
+ return $RETVAL
+}
+
+setup_gfx () {
+ local KERN RETVAL CARD CARDS SUCCESS FILES DRM
+ # check if forced by KCL
+ if [ "x$GFX" == "xnvidia" ]; then
+ load_gfx @nvidia
+ return
+ fi
+ if [ "x$GFX" == "xamd" ]; then
+ load_gfx @amd
+ return
+ fi
+ # not forced - check which driver to load
+ CARDS=$(lspci | grep 'Class 0300' | awk '{print $4}')
+ if [ -e "/drm.cfg" ] && [ -n "$CARDS" ]; then
+ SUCCESS="yes"
+ for CARD in $CARDS; do
+ # look up exact pci id of this card
+ [ $DEBUG -ge 1 ] && echo Trying exact matching for drm drivers for $CARD
+ FILES=$(grep "^$CARD\s" "/drm.cfg" | cut -c 11-)
+ load_gfx $FILES && continue
+ # failed... try vendor id only
+ CARD=$(echo $CARD | cut -c 1-4)
+ [ $DEBUG -ge 1 ] && echo Trying vendor matching for drm drivers for $CARD
+ FILES=$(grep "^$CARD\s" "/drm.cfg" | cut -c 6-)
+ load_gfx $FILES && continue
+ # everything failed for this card
+ echo Unknown PCI vendor id: $CARD
+ SUCCESS="no"
+ done
+ [ "x$SUCCESS" == "xyes" ] && return 0
+ fi
+ # braindead fallback
+ echo "At least one gfx card has no known drm drivers.... will load them all :/"
+ KERN=$(uname -r)
+ RETVAL=1
+ [ -z "$KERN" ] && KERN=$(ls '/lib/modules' | grep '\.' | tail -n 1)
+ for DRM in $(find "/lib/modules/$KERN/kernel/drivers/gpu/drm" -name "*.ko"); do
+ DRM="$(basename "$DRM")"
+ DRM="${DRM%.ko}"
+ modprobe "$DRM" && RETVAL=0
+ done
+ return $RETVAL
+}
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/functions b/core/rootfs/rootfs-stage31/data/inc/functions
new file mode 100644
index 00000000..248d0149
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/functions
@@ -0,0 +1,84 @@
+#########################################################################
+#
+# COMMON HELPER FUNCTIONS
+#
+
+#########################################################################
+#
+# Function to drop a debug shell with an error message.
+#
+# Usage:
+# drop_shell "This is your error message."
+#
+drop_shell() {
+ if [ -n "$MUTED_OUTPUT" ]; then
+ exec 1>&4 2>&5
+ reset
+ fi
+ [ $# -gt 0 ] && echo $@
+ echo "CTRL + D will continue booting."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+}
+
+#########################################################################
+#
+# Helper function to download given FILE_URL from servers in 'slxsrv'
+# as given through the kernel command line. File will be saved under TARGET_PATH
+#
+# Usage:
+# download FILE_URL TARGET_PATH
+#
+# Example:
+# download "config" "/opt/openslx/config"
+#
+# Note:
+# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config"
+#
+download() {
+ [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1
+
+ if [ -z "$SLX_KCL_SERVERS" ]; then
+ . "/opt/openslx/config" || echo "Error - could not source '/opt/openslx/config'"
+ fi
+
+ local FILE_URL="$1"
+ local TARGET_PATH="$2"
+
+ # Shuffle server list
+ local SERVERS=$(for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //')
+
+ for TIMEOUT in 1 1 2 END; do
+ for SERVER in $SERVERS; do
+ rm -f -- "${TARGET_PATH}"
+ wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}"
+ RET=$?
+ if [ "x$RET" != "x0" -o ! -e "$TARGET_PATH" ]; then
+ echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET"
+ usleep 50000 # 50ms
+ else
+ echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'."
+ return 0
+ fi
+ done
+ [ "$TIMEOUT" = "END" ] && break
+ echo "Trying again in $(($TIMEOUT * 250)) ms..."
+ usleep $(($TIMEOUT * 250000))
+ done
+ # Max retries reached, no success :-(
+ return 1
+}
+
+# Add benchmark event to var, including uptime as prefix
+bench_event() {
+ bench_result="${bench_result}$(cut -f 1 -d ' ' "/proc/uptime") $@
+"
+}
+
+# mini tarcopy <3
+# tarcopy <source_dir> <target_dir>
+tarcopy() {
+ [ -d "$1" -a -d "$2" ] || return 1
+ cd "$1"
+ tar -cp * | tar -xp -C "$2"
+ cd - &>/dev/null
+}
diff --git a/core/rootfs/rootfs-stage31/data/inc/network.functions b/core/rootfs/rootfs-stage31/data/inc/network.functions
new file mode 100644
index 00000000..641f4f55
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/network.functions
@@ -0,0 +1,23 @@
+wait_for_iface() {
+ local DEVICE=$1
+ local TIMEOUT=10
+ echo -n "Waiting for interface $DEVICE: "
+ # Some systems don't have operstate. Seems to be hardware dependent
+ [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 10000
+ if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
+ while true; do
+ # check linkstate
+ [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
+ TIMEOUT=$(( $TIMEOUT - 1 )) # don't wait forever, the pcnet iface of vmware will never be "up" although it's working
+ [ "$TIMEOUT" -le 0 ] && break
+ # else
+ echo -n "."
+ usleep 500000
+ done
+ else
+ # we really don't have a operstate .. then just wait a sec and hope for the best.
+ sleep 1
+ fi
+ echo ".$(cat "/sys/class/net/${DEVICE}/operstate" 2>/dev/null)"
+}
+true
diff --git a/core/rootfs/rootfs-stage31/data/inc/ntp_sync b/core/rootfs/rootfs-stage31/data/inc/ntp_sync
new file mode 100755
index 00000000..940af366
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/ntp_sync
@@ -0,0 +1,26 @@
+# Sync time via network
+
+func_sync_net_time() {
+ local SERVER
+ if [ -n "$SLX_NTP_SERVER" ]; then
+ for SERVER in $SLX_NTP_SERVER; do
+ if ntpdate -u -p 2 "$SERVER"; then
+ echo "Successfully queried $SERVER for time."
+ if [ "x$SLX_BIOS_CLOCK" = "xlocal" ]; then
+ usleep 100000
+ hwclock -l -w || echo "... but could not set BIOS clock to localtime"
+ elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then
+ usleep 100000
+ hwclock -u -w || echo "... but could not set BIOS clock to UTC"
+ fi
+ break
+ fi
+ echo "Error querying $SERVER for current time."
+ done
+ fi
+}
+
+func_sync_net_time &
+
+true
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/parse_kcl b/core/rootfs/rootfs-stage31/data/inc/parse_kcl
new file mode 100644
index 00000000..4a69ac25
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/parse_kcl
@@ -0,0 +1,58 @@
+#!/bin/ash
+
+getip () {
+ echo "${IPINFO}" | awk -F ':' "{print \$$1}"
+}
+parse_ip () {
+ local IPINFO=$1
+ CLIENTIP="$(getip 1)"
+ SERVERIP="$(getip 2)"
+ GATEWAY="$(getip 3)"
+ SUBNET_MASK="$(getip 4)"
+ BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)"
+ [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255"
+ # we might have an idea of the dns server via preboot
+ DNS_SERVER="$(getip 5)"
+}
+
+# read kernel command line
+DEBUG=0
+SPLASH=0
+read KCL < "/proc/cmdline"
+for opts in ${KCL}; do
+ case "${opts}" in
+ debug=*)
+ DEBUG=${opts#debug=}
+ DEBUG_SHELL=set
+ ;;
+ ip=*)
+ # process IP info
+ parse_ip ${opts#ip=} ;;
+ nfs=*) # TODO: Still working? Still needed? Also see related code in setup_stage32
+ NFS=${opts#nfs=}
+ NFSPATH=${NFS#*:}
+ NFSSERVER=${NFS%:/*}
+ ;;
+ BOOTIF=*)
+ MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network)
+ slxsrv=*)
+ SLX_KCL_SERVERS=$( echo "${opts#slxsrv=}" | tr ',' " " ) ;;
+ slxbase=*)
+ SLX_BASE_PATH=${opts#slxbase=} ;;
+ splash)
+ SPLASH=1 ;;
+ nvidia)
+ GFX=nvidia ;;
+ ati|amd)
+ GFX=amd ;;
+ esac
+done
+
+# If slxsrv was not given on command line, just use the PXE server's address
+[ -z "$SLX_KCL_SERVERS" ] && [ -n "$SERVERIP" ] && SLX_KCL_SERVERS="$SERVERIP"
+# Now save to config file
+echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config"
+echo "SLX_BASE_PATH='$SLX_BASE_PATH'" >> "${FUTURE_ROOT}/opt/openslx/config"
+
+true
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_network b/core/rootfs/rootfs-stage31/data/inc/setup_network
new file mode 100644
index 00000000..13c52289
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/setup_network
@@ -0,0 +1,84 @@
+#!/bin/ash
+
+echo "Setting up network..."
+
+echo "Main MAC address is '$MAC'"
+
+# setup network
+source /inc/network.functions
+
+# set up loopback networking
+echo "Setting up loopback"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+
+echo "Setting up bridge"
+BRIDGE="br0"
+
+# Following was supposed to prevent scripts from getting confused by multiple interfaces with same MAC - does not work though
+## Flip mac address of original interface - this var is not local so init sees the changes too
+#MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')"
+#ip link set addr "$MAC" "$SLAVE"
+
+mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d"
+
+#IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':')
+IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#')
+
+if ! echo "$IP_OUT" | grep -q -- "$MAC"; then
+ drop_shell "Boot interface not found in interface list. NIC driver missing?"
+fi
+
+for LINE in $IP_OUT; do
+ IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}')
+ IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm
+ echo "${IFACE} = ${IFMAC}"
+
+ if [ "x$IFMAC" == "x$MAC" ]; then
+ brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE"
+ brctl stp "$BRIDGE" 0
+ brctl setfd "$BRIDGE" 0.000000000001
+ ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE"
+ ip link set dev "$IFACE" up
+ wait_for_iface "$IFACE"
+ brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE"
+
+ # save our variables for retry on fail
+ echo "IFACE=$IFACE" > /run/network.conf
+
+ # analyze ip information from the kernel command line and put parts
+ # of it into several variables
+ if [ -n "$CLIENTIP" ] ; then
+ # set static ip address
+ ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE"
+ ip link set dev "$BRIDGE" up
+ [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE"
+ else
+ NOIPYET="yes"
+ fi
+ # Ignore this device later on when systemd handles network interfaces (see hacked 99-systemd.rules in systemd data dir)
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNEL==\"eth*\", ATTR{address}==\"$IFMAC\", TAG+=\"openslxignore\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/01-ignore-boot-interface.rules"
+ fi
+ # youdev
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$IFMAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$IFACE\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/70-net-boot-nic-name.rules"
+ # continue...
+ IFACE=""
+done
+
+wait_for_iface "$BRIDGE"
+
+# udhcpc
+PARAM=
+if [ -n "$CLIENTIP" ]; then
+ PARAM="-r $CLIENTIP"
+fi
+echo -n "$CLIENTIP" > "/run/firstip"
+echo -n "$GATEWAY" > "/run/firstgw"
+
+# save our variables for retry on fail ff.
+echo "CLIENTIP=$CLIENTIP" >> /run/network.conf
+echo "GATEWAY=$GATEWAY" >> /run/network.conf
+echo "BRIDGE=$BRIDGE" >> /run/network.conf
+
+udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
+# udhcpc return value will be return value of this script
diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_network_retry b/core/rootfs/rootfs-stage31/data/inc/setup_network_retry
new file mode 100644
index 00000000..0578d9b2
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/setup_network_retry
@@ -0,0 +1,33 @@
+#!/bin/ash
+
+source /inc/network.functions
+source /run/network.conf
+
+for i in 1 2 3 4 5 6 7 8; do
+ echo "<$i> Try to fix broken network"
+ echo -n "Take interface $IFACE down .. "
+
+ ip link set dev $IFACE down
+ usleep 1000
+
+ echo "and up again.."
+ ip link set dev $IFACE up
+ usleep 1000
+
+ wait_for_iface "$IFACE"
+
+ udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
+
+ if [ $? -eq 0 ]; then
+ echo "Finally fixed IP config. Continue boot."
+ RET=0
+ break
+ else
+ RET=1
+ fi
+done
+
+[ $RET -gt 0 ] && drop_shell "Something is really broken.. Please check your network cable and reset your computer."
+
+# create correct return value
+[ $RET -eq 0 ]
diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_stage32 b/core/rootfs/rootfs-stage31/data/inc/setup_stage32
new file mode 100644
index 00000000..5ec5a69d
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/setup_stage32
@@ -0,0 +1,68 @@
+#!/bin/ash
+#
+# This script sets up the stage 3.2.
+# - downloads/mounts stage32.sqfs
+# - merge it with current rootfs through aufs
+# - will not download, if the "nfs=" is used in the
+# kernel command line
+#
+#########################################################################
+#
+# first check if an NFS-share was given per command line
+#
+if [ -n "$NFS" ]; then
+ echo "Mounting stage 3.2 as NFS..."
+ busybox mount -n -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs \
+ || drop_shell "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}." \
+ || return 1
+ return 0
+fi
+
+#########################################################################
+#
+# MAIN PART
+#
+
+echo "Setting up stage 3.2 ..."
+
+STAGE32_TARGET_PATH="/stage32.sqfs"
+STAGE32_MOUNT_POINT="/rorootfs"
+
+# try to download it
+download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!"
+
+# "Delete" addon hook-script in aufs view
+touch "${FUTURE_ROOT}/.wh.addon-init"
+
+# try to mount it at STAGE32_MOUNT_POINT
+echo "Mounting stage 3.2 as SquashFS..."
+busybox mount -n -t squashfs "$STAGE32_TARGET_PATH" "$STAGE32_MOUNT_POINT" || drop_shell "Problem mounting Squashfs."
+
+echo "Building aufs ..."
+busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || drop_shell "Problem building aufs."
+mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp
+#busybox mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." # Move needed?
+FUTURE_ROOT="/mnt"
+
+# Move network stuff
+cp /etc/hostname /etc/hosts "${FUTURE_ROOT}/etc/"
+cp /etc/resolv.conf "${FUTURE_ROOT}/opt/openslx/"
+[ -s "/run/config" ] && cat "/run/config" >> "${FUTURE_ROOT}/opt/openslx/config"
+
+# if booting with splash, suppress kernel output in stage32
+if [ $SPLASH -eq 1 ]; then
+ if grep -q -E "^ *kernel.printk" "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"; then
+ sed -i 's/^ *kernel\.printk.*/kernel\.printk = 1 1 0 1/g' "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ else
+ echo "kernel.printk = 1 1 0 1" >> "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ fi
+fi
+
+# Kinda specific for virtualization environment: Autologin and run VM for benchmarks
+if [ -n "$SLX_BENCHMARK_VM" ]; then
+ # Enable KDM autologin for demo user
+ sed -i 's/^AutoLoginUser=.*//;s/^AutoLoginEnable=.*/AutoLoginEnable=true\nAutoLoginUser=demo/' "${FUTURE_ROOT}/etc/kde4/kdm/kdmrc"
+ # Running the VM automatically has to be taken care of by run-virt and vmchooser. SLX_BENCHMARK_VM should contain
+ # a numeric value for the index in vmchooser
+fi
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_stage4 b/core/rootfs/rootfs-stage31/data/inc/setup_stage4
new file mode 100644
index 00000000..585627c2
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/setup_stage4
@@ -0,0 +1,69 @@
+#!/bin/ash
+
+[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; }
+
+MOUNTPOINT="/rorootfs/"
+mkdir -p "$MOUNTPOINT"
+
+
+# first load module
+insmod /lib/modules/dnbd3/dnbd3.ko
+
+# dnbd3 it is
+if [ -z "${SLX_DNBD3_SERVERS}${SLX_DNBD3_PRIO_SERVERS}" ]; then
+ slxlog --echo "mount-stage4" "dnbd3 stage4 configured, but SLX_DNBD3(_PRIO)_SERVERS empty or not set in /opt/openslx/config."
+ exit 1
+fi
+# Determine revision
+if [ -z "$SLX_STAGE4_RID" ] || echo "$SLX_STAGE4_RID" | grep -v -q -E "^[0-9]+$"; then
+ SLX_STAGE4_RID="0"
+fi
+# Randomize list
+SERVERS=$(for SERVER in $SLX_DNBD3_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //')
+IMAGE=$(echo $SLX_STAGE4 | awk '{printf $2}')
+[ -e /var/run/dnbd3.socket ] || sleep 2 # Ugly, service should only start when dnbd3 daemon is up and running
+RET=1337
+for SRV in $SLX_DNBD3_PRIO_SERVERS $SERVERS; do
+ echo "Requesting $IMAGE from $SRV"
+ dnbd3=$(/opt/openslx/bin/dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID" -d /dev/dnbd0)
+ RET=$?
+ [ "$RET" -eq "0" ] && break
+ echo "... didn't work ($RET)"
+ sleep 1
+done
+if [ "$RET" -ne "0" ]; then
+ drop_shell "Omg"
+ slxlog --echo "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE : $SLX_STAGE4_RID) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)"
+ exit $RET
+fi
+echo "Mounting /dev/dnbd0 to $MOUNTPOINT"
+if ! busybox mount -t squashfs -o ro /dev/dnbd0 "$MOUNTPOINT"; then
+ slxlog --echo "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)"
+ exit 1
+fi
+
+busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${MOUNTPOINT}=ro" none /mnt || drop_shell "Problem building aufs."
+mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp
+FUTURE_ROOT="/mnt"
+
+cp /etc/hostname /etc/hosts "${FUTURE_ROOT}/etc/"
+cp /etc/resolv.conf "${FUTURE_ROOT}/opt/openslx/"
+[ -s "/run/config" ] && cat "/run/config" >> "${FUTURE_ROOT}/opt/openslx/config"
+
+# if booting with splash, suppress kernel output in stage32
+if [ $SPLASH -eq 1 ]; then
+ if grep -q -E "^ *kernel.printk" "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"; then
+ sed -i 's/^ *kernel\.printk.*/kernel\.printk = 1 1 0 1/g' "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ else
+ echo "kernel.printk = 1 1 0 1" >> "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ fi
+fi
+
+# Kinda specific for virtualization environment: Autologin and run VM for benchmarks
+if [ -n "$SLX_BENCHMARK_VM" ]; then
+ # Enable KDM autologin for demo user
+ sed -i 's/^AutoLoginUser=.*//;s/^AutoLoginEnable=.*/AutoLoginEnable=true\nAutoLoginUser=demo/' "${FUTURE_ROOT}/etc/kde4/kdm/kdmrc"
+ # Running the VM automatically has to be taken care of by run-virt and vmchooser. SLX_BENCHMARK_VM should contain
+ # a numeric value for the index in vmchooser
+fi
+
diff --git a/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger
new file mode 100755
index 00000000..02987f21
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger
@@ -0,0 +1,93 @@
+#!/bin/ash
+
+exec >> /run/stdout
+exec 2>> /run/stderr
+set -x
+
+if [ "x$1" != "xbound" -a "x$1" != "xrenew" ] || [ "x$interface" != "xbr0" ] || [ -z "$ip" ]; then
+ exit 0
+fi
+
+# If we already got an IP from KCL, see if it differs, and remove first if so
+# We just try to prevent everything from breaking if the DHCP server doesn't
+# objey the renew request by the client and hands out a new address
+if [ -s "/run/firstip" ]; then
+ #...some address is already configured...
+ OLD=$(cat "/run/firstip")
+ if [ "x${OLD}" != "x${ip}" ]; then
+ #...it's a different one, reconfigure...
+ echo "..reconfiguring ${OLD} to ${ip}.."
+ # remove default route and let it be added again below, as it might get lost when changing the primary address on the interface
+ ip route del default 2>/dev/null
+ rm -f -- "/run/firstgw"
+ ip addr del "${OLD}" dev "${interface}" 2>/dev/null
+ ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}"
+ fi
+else
+ #...no address configured yet, just add...
+ echo "..adding ${ip}.."
+ ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}"
+fi
+echo -n "$ip" > "/run/firstip"
+
+# Same procedure for default gateway
+if [ -n "${router}" ]; then
+ if [ -s "/run/firstgw" ]; then
+ OLD=$(cat "/run/firstgw")
+ if [ "x${OLD}" != "x${router}" ]; then
+ echo "..reconfiguring default gw from ${OLD} to ${router}.."
+ ip route del default 2>/dev/null
+ ip route add default via "$router"
+ fi
+ else
+ ip route add default via "$router"
+ fi
+ echo -n "$router" > "/run/firstgw"
+fi
+
+rm -f -- "/etc/resolv.conf"
+
+# DNS/domain?
+if [ -n "$dns" ]; then
+ echo "..got DNS.."
+ echo "# From DHCP in stage 3.1" >> "/run/config"
+ echo "SLX_DNS='$dns'" >> "/run/config"
+fi
+for serv in $dns; do
+ echo "nameserver $serv" >> "/etc/resolv.conf"
+done
+if [ -z "$domain" ]; then
+ # try to get domain via reverse lookup if empty
+ echo "..trying to get domain via DNS, as DHCP didn't supply one.."
+ fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}')
+ domain="${fqdn#*.}"
+fi
+if [ -n "$domain" ]; then
+ echo "domain $domain" >> "/etc/resolv.conf"
+fi
+if [ -n "$search" ]; then
+ echo "search $search" >> "/etc/resolv.conf"
+elif [ -n "$domain" ]; then
+ echo "search $domain" >> "/etc/resolv.conf"
+fi
+
+
+# Hostname
+if [ -z "$hostname" ]; then
+ # as with domain, if there's no hostname, try to get via DNS
+ echo "..trying to get hostname via DNS, as DHCP didn't supply one.."
+ [ -z "$fqdn" ] && fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}')
+ hostname="${fqdn%%.*}"
+elif [ -n "$domain" ]; then
+ fqdn="${hostname}.${domain%% *}" # in case domain is a list
+fi
+if [ -n "$hostname" ]; then
+ [ -z "$fqdn" ] && fqdn="$hostname"
+ echo "..setting hostname $hostname (fqdn: $fqdn).."
+ echo "$hostname" > "/proc/sys/kernel/hostname"
+ echo "$hostname" > "/etc/hostname"
+ echo "127.0.0.1 localhost" > "/etc/hosts"
+ echo "127.0.1.1 $fqdn $hostname" >> "/etc/hosts"
+ echo "SLX_HOSTNAME='$hostname'" >> "/run/config"
+fi
+
diff --git a/core/rootfs/rootfs-stage31/data/init b/core/rootfs/rootfs-stage31/data/init
new file mode 100755
index 00000000..5e6d1caf
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/data/init
@@ -0,0 +1,166 @@
+#!/bin/ash
+# Copyright (c) 2013, 2014 - bwLehrpool Projekt
+# Copyright (c) 2012 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# First script for initial ramfs for OpenSLX linux stateless clients
+#############################################################################
+
+# set PATH correctly
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+# import common functions
+. "/inc/functions"
+
+# mount the important standard directories
+[ ! -f /proc/cpuinfo ] && busybox mount -n -t proc proc /proc
+bench_event "KERNEL" "Kernel initialized"
+[ ! -d /sys/class ] && busybox mount -n -t sysfs sysfs /sys
+
+# NOTE: busybox mount is only available through the busybox binary,
+# the link had to be dropped, to prevent bugs in the stage32.
+busybox mount -n -t devtmpfs -o 'rw,relatime,nosuid,noexec,mode=0755' initramfsdevs /dev
+busybox mount -n -t tmpfs -o 'mode=755' run "/run"
+
+# preparations for mounting stage3.2
+FUTURE_ROOT="/dev/shm/uniontmp"
+mkdir -p "$FUTURE_ROOT" /rorootfs
+busybox mount -n -t tmpfs -o 'mode=755' none "$FUTURE_ROOT"
+mkdir -p "$FUTURE_ROOT/opt/openslx"
+
+
+# Get all variables we care about from the KCL
+. /inc/parse_kcl
+
+# NOTE: this is only relevant when using the distro's kernel
+# load kernel modules as given in /etc/modules
+modprobe -a -b $(cat /etc/modules) 2>/dev/null
+
+# Load drm gfx drivers, if successful, check if splash screen should be shown, and do so
+. "/inc/drm.functions"
+if [ "$SPLASH" -eq 1 ]; then
+ if setup_gfx; then
+ echo "1 1 0 1" > /proc/sys/kernel/printk
+ exec 4>&1 5>&2 > /dev/null 2>&1
+ MUTED_OUTPUT=1
+ clear
+ echo -e "\033[?25l" >&4
+ if [ -e "/etc/splash.ppm.gz" ]; then
+ fbsplash -x -b -s "/etc/splash.ppm.gz" &
+ elif [ -e "/etc/splash.ppm" ]; then
+ fbsplash -x -b -s "/etc/splash.ppm" &
+ else
+ echo "Splash screen requested, but not found in initramfs..." >&4
+ fi
+ fi
+else
+ setup_gfx
+fi
+
+# suppress kernel output if DEBUG is set and no splash screen is requested
+if [ $SPLASH -eq 0 ]; then
+ [ $DEBUG -ge 1 ] && echo "4 4 1 7" > /proc/sys/kernel/printk || echo "1 1 0 1" >/proc/sys/kernel/printk
+fi
+
+[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: before network."
+
+. "/inc/setup_network" || . "/inc/setup_network_retry" || drop_shell "Error setting up network"
+bench_event "NETWORK" "Network up and running"
+
+[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring."
+
+. "/inc/activate_sysconfig" || drop_shell "Could not source /inc/activate_sysconfig"
+bench_event "CONFIG" "Downloaded config"
+# From here on, we have all the vars from /opt/openslx/config
+
+# Sync time via NTP
+. "/inc/ntp_sync"
+
+[ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32."
+
+. "/inc/setup_stage32" || drop_shell "Problem setting up stage3.2"
+bench_event "STAGE32" "Downloaded stage 3.2"
+
+# copy files needed for stage3.2 to FUTURE_ROOT
+echo "Copying busybox etc. to stage32..."
+tar -cp /bin/* /sbin/* | tar -xp -C "${FUTURE_ROOT}/opt/openslx/"
+mkdir -p "${FUTURE_ROOT}/opt/openslx/inc"
+cp -a "/inc/functions" "${FUTURE_ROOT}/opt/openslx/inc/"
+
+# set the SLX_ROOT_PASS if given in config
+if [ ! -z "$SLX_ROOT_PASS" ]; then
+ sed -i "s#^root:[^:]*:#root:$SLX_ROOT_PASS:#" "${FUTURE_ROOT}/etc/shadow"
+fi
+# set the SLX_DEMO_PASS if given in config
+if [ ! -z "$SLX_DEMO_PASS" ]; then
+ sed -i "s#^demo:[^:]*:#demo:$SLX_DEMO_PASS:#" "${FUTURE_ROOT}/etc/shadow"
+fi
+
+# one last debug shell if activated
+[ $DEBUG -ge 1 ] && drop_shell "Requested Debug Shell: before switch_root."
+
+# Activate debug shell after switchroot?
+[ -n "$DEBUG_SHELL" ] && ln -s "../debug-shell.service" "${FUTURE_ROOT}/usr/lib/systemd/system/sysinit.target.wants/debug-shell.service"
+
+# need /proc for this ;)
+bench_event "PRESWITCH" "Switching to stage 3.2"
+
+# unmount filesystems
+for mnt in proc sys run ; do
+ busybox umount -f -l "/$mnt" 2>/dev/null
+done
+
+# HACK HACK: Klausurmodus
+# Putting this here as we're hopefully moving to the all new dracut solution soon
+# so there's no reason to make it pretty now
+if [ -n "$SLX_EXAM" ]; then
+ # Visual: Make kdm all orange
+ sed -i 's/#e3e4e9/#f9a72b/g' "${FUTURE_ROOT}/usr/share/desktop/themes/kdm/bwlehrpool/theme.xml"
+ # Set autologindelay to 0 to directly boot
+ sed -i 's/^AutoLoginDelay=.*/AutoLoginDelay=0/g' "${FUTURE_ROOT}/etc/kde4/kdm/kdmrc"
+ # Visual: Move splash screen to upper left corner
+ if [ -e "/etc/splash.ppm.gz" ]; then
+ fbsplash -b -s "/etc/splash.ppm.gz" &
+ elif [ -e "/etc/splash.ppm" ]; then
+ fbsplash -b -s "/etc/splash.ppm" &
+ fi
+ # Visual: ssh banner
+ echo "+ - - - - KLAUSURMODUS AKTIV - - - - +" >> "${FUTURE_ROOT}/etc/issue.net"
+ echo "++++++++++++++++++++++++++++++++++++++" >> "${FUTURE_ROOT}/etc/issue.net"
+ # Disable ctrl-alt-delete
+ rm -- "${FUTURE_ROOT}/usr/lib/systemd/system/ctrl-alt-del.target"
+ # No idleaction
+ rm -- "${FUTURE_ROOT}/etc/cron.d/openslx-idleaction"
+ # Ignore everything but power button
+ cat > "${FUTURE_ROOT}/etc/systemd/logind.conf" <<EOF
+[Login]
+NAutoVTs=0
+ReserveVT=0
+KillUserProcesses=no
+HandlePowerKey=poweroff
+HandleSuspendKey=ignore
+HandleHibernateKey=ignore
+HandleLidSwitch=ignore
+IdleAction=ignore
+EOF
+ # Link exam.service in sysinit.target
+ ln -s "../exam.service" "${FUTURE_ROOT}/etc/systemd/system/sysinit.target.wants/exam.service"
+fi
+
+echo "Switching root...."
+echo "$bench_result" > "${FUTURE_ROOT}/opt/openslx/.benchmark"
+# Prepare environment (HOME is needed as a hack for nss_ldap with ssl and no caching)
+unset BOOT_IMAGE initrd KCL ip slxbase slxsrv IPINFO vga ip MAC BOOTIF DEBUG OLDPWD MUTED_OUTPUT GFX
+export HOME=/
+export init="/usr/lib/systemd/systemd"
+export recovery=
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
+exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd
+
diff --git a/core/rootfs/rootfs-stage31/module.build b/core/rootfs/rootfs-stage31/module.build
new file mode 100644
index 00000000..cda5788a
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.build
@@ -0,0 +1,74 @@
+#!/bin/bash
+fetch_source() {
+ :
+}
+
+build() {
+ local COPYLIST BIN_LOCATION DRM_MODULES FILE BIN MODNAME PCI_FILE ALIAS VENDOR DEVICE LIB
+ COPYLIST="list_binaries_and_files"
+ [ -e "$COPYLIST" ] && rm -f "$COPYLIST"
+ for BIN in $REQUIRED_BINARIES; do
+ BIN_LOCATION=$(which "$BIN")
+ [ -z "$BIN_LOCATION" ] && perror "Cannot find $BIN"
+ get_link_chain "$BIN_LOCATION" >> "$COPYLIST"
+ done
+
+ mkdir -p "$MODULE_BUILD_DIR/lib"
+ find /lib /lib64 /usr/lib /usr/lib64 \( -name "libnss_dns*" -o -name "libresolv*" -o -name "libnss_files*" \) >> "$COPYLIST"
+
+ tarcopy "$(cat "$COPYLIST" | sort -u)" "$MODULE_BUILD_DIR"
+
+ # generate drm module loading database
+ pinfo "Generating PCI ID database for DRM drivers"
+ DRM_MODULES="$KERNEL_BASE_DIR/lib/modules/$TARGET_KERNEL_LONG/kernel/drivers/gpu/drm"
+ PCI_FILE="$MODULE_BUILD_DIR/drm.cfg"
+ [ -d "$DRM_MODULES" ] || perror "DRM dir not found at $DRM_MODULES"
+ cp "$MODULE_DIR/templates/drm.cfg" "$PCI_FILE" || perror "Could not copy drm.cfg from templates dir"
+ echo "# -- generated from kernel $TARGET_KERNEL_LONG modules:" >> "$PCI_FILE"
+ for FILE in $(find "$DRM_MODULES" -name "*.ko"); do
+ MODNAME=$(basename "$FILE")
+ MODNAME=${MODNAME%.ko}
+ [ -z "$MODNAME" ] && perror "$FILE equals empty modname"
+ echo "# $MODNAME" >> "$PCI_FILE"
+ for ALIAS in $(modinfo "$FILE" | grep '^alias:' | grep -o 'pci:v.*' | tr '[A-F]' '[a-f]'); do
+ VENDOR=$(echo $ALIAS | cut -c 10-13)
+ if [ "x$(echo $ALIAS | cut -c 15)" == "x*" ]; then
+ # device wildcard
+ grep -q -i "^${VENDOR}\s" "$PCI_FILE" && continue
+ echo "${VENDOR} $MODNAME" >> "$PCI_FILE"
+ else
+ # specific device
+ DEVICE=$(echo $ALIAS | cut -c 19-22)
+ grep -q -i "^${VENDOR}:${DEVICE}\s" "$PCI_FILE" && continue
+ echo "${VENDOR}:${DEVICE} $MODNAME" >> "$PCI_FILE"
+ fi
+ done
+ done
+}
+
+post_copy() {
+ pinfo "Generating rootfs for Stage 3.1 ..."
+ generate_rootfs
+
+ # copy kernel, modules and firmware
+ copy_kernel_modules
+ copy_firmware
+ copy_kernel
+}
+
+#
+# helper functions to generate the base rootfs
+#
+generate_rootfs() {
+ # create basic directory structure
+ mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,run,etc,mnt,sys} \
+ || perror "Cannot create basic directory structure in '${TARGET_BUILD_DIR}'"
+
+ # copy device files from running system
+ cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \
+ "${TARGET_BUILD_DIR}"/dev || perror "Cannot copy devices from running system"
+
+ # copy libc and ld-linux
+ tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}"
+}
+
diff --git a/core/rootfs/rootfs-stage31/module.conf b/core/rootfs/rootfs-stage31/module.conf
new file mode 100644
index 00000000..d4944184
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.conf
@@ -0,0 +1,74 @@
+REQUIRED_BINARIES="
+ ntpdate
+"
+REQUIRED_MODULES="
+ busybox
+ kernel
+"
+REQUIRED_KERNEL_MODULES="
+ kernel/drivers/net/ethernet/*.ko
+ kernel/drivers/net/ethernet/*/*.ko
+ kernel/drivers/net/ethernet/*/*/*.ko
+ kernel/drivers/video/sis/sisfb.ko
+ kernel/drivers/video/via/viafb.ko
+ kernel/drivers/acpi/video.ko
+ kernel/drivers/ssb/ssb.ko
+ kernel/drivers/acpi/button.ko
+ kernel/drivers/gpu/drm/drm*.ko
+ kernel/drivers/gpu/drm/*/*.ko
+ kernel/drivers/hid/hid-generic.ko
+ kernel/drivers/i2c/algos/i2c-algo-bit.ko
+ kernel/drivers/i2c/i2c-core.ko
+ kernel/drivers/usb/usb-common.ko
+ kernel/drivers/usb/core/usbcore.ko
+ kernel/drivers/net/netconsole.ko
+ kernel/drivers/hid/hid.ko
+ kernel/drivers/hid/hid-cherry.ko
+ kernel/drivers/hid/usbhid/usbhid.ko
+ kernel/drivers/platform/x86/wmi.ko
+ kernel/drivers/platform/x86/mxm-wmi.ko
+ kernel/fs/configfs/configfs.ko
+ kernel/fs/nfs_common/nfs_acl.ko
+ kernel/fs/nfs/nfs.ko
+ kernel/fs/fscache/fscache.ko
+ kernel/fs/lockd/lockd.ko
+ kernel/fs/squashfs/squashfs.ko
+ kernel/fs/xfs/xfs.ko
+ kernel/net/sunrpc/sunrpc.ko
+ kernel/net/sunrpc/auth_gss/auth_rpcgss.ko
+ kernel/net/802/stp.ko
+ kernel/net/bridge/bridge.ko
+ kernel/ubuntu/aufs/aufs.ko
+ kernel/fs/aufs/aufs.ko
+ kernel/drivers/block/nbd.ko
+ kernel/drivers/parport/parport.ko
+ kernel/drivers/video/backlight/adp8860_bl.ko
+ kernel/drivers/video/backlight/adp8870_bl.ko
+ kernel/fs/xfs/xfs.ko
+"
+REQUIRED_FIRMWARE="
+ 3com/
+ e100/
+ matrox/
+ r128/
+ radeon/
+ RTL8192E/
+ RTL8192SE/
+ rtl_nic/
+ tigon/
+ i915/
+ intel/
+"
+REQUIRED_LIBRARIES="
+ libnss_files
+ libnss_dns
+ libresolv
+"
+REQUIRED_SYSTEM_FILES="
+ /etc/protocols
+ /etc/services
+ /etc/localtime
+"
+REQUIRED_FILES="
+ /drm.cfg
+"
diff --git a/core/rootfs/rootfs-stage31/module.conf.centos b/core/rootfs/rootfs-stage31/module.conf.centos
new file mode 100644
index 00000000..35c9927b
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.conf.centos
@@ -0,0 +1,3 @@
+REQUIRED_INSTALLED_PACKAGES="
+ ntpdate
+"
diff --git a/core/rootfs/rootfs-stage31/module.conf.debian b/core/rootfs/rootfs-stage31/module.conf.debian
new file mode 100644
index 00000000..35c9927b
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.conf.debian
@@ -0,0 +1,3 @@
+REQUIRED_INSTALLED_PACKAGES="
+ ntpdate
+"
diff --git a/core/rootfs/rootfs-stage31/module.conf.fedora b/core/rootfs/rootfs-stage31/module.conf.fedora
new file mode 100644
index 00000000..35c9927b
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.conf.fedora
@@ -0,0 +1,3 @@
+REQUIRED_INSTALLED_PACKAGES="
+ ntpdate
+"
diff --git a/core/rootfs/rootfs-stage31/module.conf.ubuntu b/core/rootfs/rootfs-stage31/module.conf.ubuntu
new file mode 100644
index 00000000..35c9927b
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/module.conf.ubuntu
@@ -0,0 +1,3 @@
+REQUIRED_INSTALLED_PACKAGES="
+ ntpdate
+"
diff --git a/core/rootfs/rootfs-stage31/templates/drm.cfg b/core/rootfs/rootfs-stage31/templates/drm.cfg
new file mode 100644
index 00000000..bbfa3bc0
--- /dev/null
+++ b/core/rootfs/rootfs-stage31/templates/drm.cfg
@@ -0,0 +1,19 @@
+## nvidia
+# 8800 GTS
+10de:0193 @nvidia
+# ION
+10de:087d @nvidia
+##
+# 10de-11c0: nvidia Geforce GTX 660 (OG)
+# 10de-0fc2: nvidia GeForce GT 630 (OG)
+# 10de-0dd8: nvidia Quadro 2000
+##
+10de:11c0 @nvidia
+10de:0fc2 @nvidia
+10de:0dd8 @nvidia
+## intel
+# Dell GX 620
+8086:2772 i915
+# aliases
+@nvidia nvidia/nvidia.ko nvidia/nvidia-uvm.ko nvidia/nvidia-modeset.ko
+@nvidia_fallback nouveau
diff --git a/core/rootfs/rootfs-stage32/TODO b/core/rootfs/rootfs-stage32/TODO
new file mode 100644
index 00000000..046b40d2
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/TODO
@@ -0,0 +1,4 @@
+libmdns needed?
+/etc/modprobe.d/blacklist.conf needed?
+
+Support for rpc.statd and rpcbind for OpenSuSE
diff --git a/core/rootfs/rootfs-stage32/data/bin/ash b/core/rootfs/rootfs-stage32/data/bin/ash
new file mode 120000
index 00000000..8f88d64e
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/bin/ash
@@ -0,0 +1 @@
+/opt/openslx/bin/busybox \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/bin/sh b/core/rootfs/rootfs-stage32/data/bin/sh
new file mode 120000
index 00000000..5d4150d0
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/bin/sh
@@ -0,0 +1 @@
+/bin/bash \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/conf.d/nfs-common.conf b/core/rootfs/rootfs-stage32/data/etc/conf.d/nfs-common.conf
new file mode 100644
index 00000000..c12705b9
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/conf.d/nfs-common.conf
@@ -0,0 +1,7 @@
+# Common configuration file for rpc-services.
+
+# Options for rpcbind
+BIND_OPTS="-w"
+
+# Options for rpc.statd
+STATD_OPTS="-L"
diff --git a/core/rootfs/rootfs-stage32/data/etc/hosts b/core/rootfs/rootfs-stage32/data/etc/hosts
new file mode 100644
index 00000000..631cf753
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/hosts
@@ -0,0 +1,8 @@
+127.0.0.1 localhost
+
+# The following lines are desirable for IPv6 capable hosts
+::1 ip6-localhost ip6-loopback
+fe00::0 ip6-localnet
+ff00::0 ip6-mcastprefix
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
diff --git a/core/rootfs/rootfs-stage32/data/etc/keymaps/de_DE b/core/rootfs/rootfs-stage32/data/etc/keymaps/de_DE
new file mode 100644
index 00000000..375c2012
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/keymaps/de_DE
Binary files differ
diff --git a/core/rootfs/rootfs-stage32/data/etc/modprobe.d/50-mltk-blacklist.conf b/core/rootfs/rootfs-stage32/data/etc/modprobe.d/50-mltk-blacklist.conf
new file mode 100644
index 00000000..00be09ca
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/modprobe.d/50-mltk-blacklist.conf
@@ -0,0 +1,11 @@
+# Blacklist for mltk related modules
+
+# Intel corporation 82Q35 Express MEI controller spams syslog under
+# some 3.0 kernels
+blacklist mei
+
+# pcspeaker device driver
+blacklist pcspkr
+
+# Strange device driver for alsa via pcspeaker
+blacklist snd-pcsp
diff --git a/core/rootfs/rootfs-stage32/data/etc/nsswitch.conf b/core/rootfs/rootfs-stage32/data/etc/nsswitch.conf
new file mode 100644
index 00000000..6886def9
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/nsswitch.conf
@@ -0,0 +1,19 @@
+# /etc/nsswitch.conf
+#
+# Example configuration of GNU Name Service Switch functionality.
+# If you have the `glibc-doc-reference' and `info' packages installed, try:
+# `info libc "Name Service Switch"' for information about this file.
+
+passwd: compat
+group: compat
+shadow: compat
+
+hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
+networks: files
+
+protocols: db files
+services: db files
+ethers: db files
+rpc: db files
+
+netgroup: nis
diff --git a/core/rootfs/rootfs-stage32/data/etc/profile b/core/rootfs/rootfs-stage32/data/etc/profile
new file mode 100644
index 00000000..cbc5dba2
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/profile
@@ -0,0 +1,56 @@
+# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
+# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
+# XXX: Use `backticks` here instead of $(this stuff) as we don't know which shell is running...
+
+export UID=`id -u` 2> /dev/null
+
+# If running interactively, then:
+if [ "$PS1" ]; then
+
+ if [ "$BASH" ]; then
+ export PS1="[\u@\h \W]\\$ "
+ else
+ if [ "$UID" -eq 0 ]; then
+ export PS1='# '
+ else
+ export PS1='$ '
+ fi
+ fi
+
+ export HISTSIZE=1000
+ export HISTFILESIZE=1000
+ export PAGER='/bin/less'
+ export EDITOR='/bin/vi'
+ export INPUTRC=/etc/inputrc
+ #export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
+ export TERMINFO='/lib/terminfo'
+
+fi
+
+# Stuff we might wanna know
+PWENT=`getent passwd $USER`
+export USER=`echo "$PWENT" | awk -F ':' '{print $1}'`
+export GID=`echo "$PWENT" | awk -F ':' '{print $4}'`
+export HOME=`echo "$PWENT" | awk -F ':' '{print $6}'`
+export GROUP=`id -gn`
+export LOGNAME=$USER
+export HOSTNAME=`hostname`
+
+# set TERM to xterm on SSH sessions
+[ -n "$SSH_TTY" ] && export TERM=xterm
+
+# Source configuration files from /etc/profile.d
+for i in /etc/profile.d/*.sh ; do
+ if [ -r "$i" ]; then
+ . $i
+ fi
+done
+
+# Sourcing /etc/profile.local - please add custom stuff to profile.local
+# as /etc/profile may be overwritten by system updates
+test -s /etc/profile.local && . /etc/profile.local
+
+if [ -s "$HOME/.bashrc" ]; then
+ . "$HOME/.bashrc"
+fi
+
diff --git a/core/rootfs/rootfs-stage32/data/etc/resolv.conf b/core/rootfs/rootfs-stage32/data/etc/resolv.conf
new file mode 120000
index 00000000..c6430d61
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/resolv.conf
@@ -0,0 +1 @@
+/opt/openslx/resolv.conf \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/early-network-triggers.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/early-network-triggers.service
new file mode 100644
index 00000000..2c5d7769
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/early-network-triggers.service
@@ -0,0 +1,13 @@
+# This will trigger network.target etc. at an early point,
+# if network setup happened in stage31 (dhcp...)
+[Unit]
+Description=Trigger network targets early
+DefaultDependencies=no
+Wants=systemd-tmpfiles-setup.service
+Before=sysinit.target
+After=systemd-tmpfiles-setup.service
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-early_network_triggers
+RemainAfterExit=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/graphical.target.wants/killsplash.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/graphical.target.wants/killsplash.service
new file mode 120000
index 00000000..40a962d5
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/graphical.target.wants/killsplash.service
@@ -0,0 +1 @@
+../killsplash.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service
new file mode 100644
index 00000000..0534f45c
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/load-gfx-driver.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Load DRM GFX driver and 3D
+Before=sysinit.target shutdown.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-load_gfx_driver
+RemainAfterExit=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service
new file mode 100644
index 00000000..7f8b54a8
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Mount Openslx Stage 4
+DefaultDependencies=no
+Wants=setup-dnbd3.service stage4.target
+After=setup-dnbd3.service
+Before=stage4.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/opt/openslx/scripts/systemd-mount_stage4
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-dns.target b/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-dns.target
new file mode 100644
index 00000000..bc12cd1b
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-dns.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=DNS Server available
+ConditionPathExists=/run/network/dns-ready
+
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-gateway.target b/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-gateway.target
new file mode 100644
index 00000000..770eb697
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/network-gateway.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=Default route configured
+ConditionPathExists=/run/network/gateway-ready
+
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service
new file mode 120000
index 00000000..c1792e42
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service
@@ -0,0 +1 @@
+mount-stage4.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpc-statd.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpc-statd.service
new file mode 100644
index 00000000..903a3b1a
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpc-statd.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=NFSv2/3 Network Status Monitor Daemon
+After=rpcbind.service
+Requires=rpcbind.service
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/conf.d/nfs-common.conf
+ExecStart=/sbin/rpc.statd $STATD_OPTS
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpcbind.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpcbind.service
new file mode 100644
index 00000000..7dc4dcc2
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/rpcbind.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=RPC Bind
+After=network.target
+Wants=rpcbind.target
+Before=rpcbind.target
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/conf.d/nfs-common.conf
+ExecStart=/sbin/rpcbind $BIND_OPTS
+Restart=always
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service
new file mode 100644
index 00000000..6bb3a986
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-partitions.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Setup local disk partitions (tmp, swap)
+DefaultDependencies=no
+Before=basic.target
+After=systemd-udev-settle.service
+Wants=tmp.target
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-setup_partitions
+RemainAfterExit=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service
new file mode 100644
index 00000000..88f38dbb
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Setup SLX addon %i
+DefaultDependencies=no
+Wants=tmp.target
+After=tmp.target
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-setup_slx_addons %I
+RemainAfterExit=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addons.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addons.service
new file mode 100644
index 00000000..71a81d3f
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addons.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Download, mount and append SLX addons
+After=tmp.target
+Wants=tmp.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-setup_slx_addons
+RemainAfterExit=yes
+
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target b/core/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target
new file mode 100644
index 00000000..9b2e9e94
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target
@@ -0,0 +1,5 @@
+[Unit]
+Requires=mount-stage4.service
+After=mount-stage4.service
+Description=OpenSLX Stage 4
+RefuseManualStart=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/early-network-triggers.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/early-network-triggers.service
new file mode 120000
index 00000000..8aec0a6d
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/early-network-triggers.service
@@ -0,0 +1 @@
+../early-network-triggers.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service
new file mode 120000
index 00000000..b72d0453
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/load-gfx-driver.service
@@ -0,0 +1 @@
+../load-gfx-driver.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service
new file mode 120000
index 00000000..af2957f8
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-partitions.service
@@ -0,0 +1 @@
+../setup-partitions.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service
new file mode 120000
index 00000000..415050b5
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service
@@ -0,0 +1 @@
+../setup-slx-addons.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/update-etc_issue.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/update-etc_issue.service
new file mode 120000
index 00000000..4540789e
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/update-etc_issue.service
@@ -0,0 +1 @@
+../update-etc_issue.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/zram-swap.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/zram-swap.service
new file mode 120000
index 00000000..c1754b11
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/zram-swap.service
@@ -0,0 +1 @@
+../zram-swap.service \ No newline at end of file
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/tmp.target b/core/rootfs/rootfs-stage32/data/etc/systemd/system/tmp.target
new file mode 100644
index 00000000..a8c3eab2
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/tmp.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=/tmp has been mounted
+Wants=setup-partitions.service
+After=setup-partitions.service
+
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service
new file mode 100644
index 00000000..21a09b7c
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/update-etc_issue.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Update /etc/issue
+Before=getty.target shutdown.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/openslx-create_issue
+RemainAfterExit=no
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/zram-swap.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/zram-swap.service
new file mode 100644
index 00000000..a458b380
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/zram-swap.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Setup zram swap partitions
+DefaultDependencies=no
+Wants=swap.target
+Before=swap.target
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-zram_swap
+RemainAfterExit=yes
diff --git a/core/rootfs/rootfs-stage32/data/etc/terminfo/l/linux b/core/rootfs/rootfs-stage32/data/etc/terminfo/l/linux
new file mode 100644
index 00000000..48d722f8
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/terminfo/l/linux
Binary files differ
diff --git a/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm b/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm
new file mode 100644
index 00000000..438b1581
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm
Binary files differ
diff --git a/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm-256color b/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm-256color
new file mode 100644
index 00000000..b934be06
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/terminfo/x/xterm-256color
Binary files differ
diff --git a/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/network.conf b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/network.conf
new file mode 100644
index 00000000..346ecf7e
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/network.conf
@@ -0,0 +1 @@
+d /run/network 0755 root root
diff --git a/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/openslx-log.conf b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/openslx-log.conf
new file mode 100644
index 00000000..4d93fb9c
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/openslx-log.conf
@@ -0,0 +1 @@
+d /var/log/openslx 0777 root root
diff --git a/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf
new file mode 100644
index 00000000..a20cf5ce
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf
@@ -0,0 +1,2 @@
+d /run/lock 1777 root root
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/bin/penv b/core/rootfs/rootfs-stage32/data/opt/openslx/bin/penv
new file mode 100755
index 00000000..5d0c8dc7
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/bin/penv
@@ -0,0 +1,7 @@
+#!/bin/ash
+
+[ "$#" -ne "1" ] && echo "Usage: $0 PID" && exit 1
+[ ! -e "/proc/$1/environ" ] && echo "No such process: $1" && exit 1
+[ ! -r "/proc/$1/environ" ] && echo "Cannot open process: $1" && exit 1
+sed 's/\x0/\n/g' "/proc/$1/environ" | grep -E --color=auto '^[^=]*'
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog b/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
new file mode 100755
index 00000000..52320c1a
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/bin/slxlog
@@ -0,0 +1,76 @@
+#!/bin/ash
+
+##################
+# Remote logging #
+##################
+#
+# Usage: slxlog [-e | --echo] "logtype" "Human readable string" ["file name which's contents should be sent too"]
+# -e or --echo will echo message to stdout too
+#
+
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
+
+. /opt/openslx/config
+[ -z "$SLX_REMOTE_LOG" ] && exit 3
+
+LOGCHECK="/tmp/remote_log_check"
+NOW=$(date +%s)
+
+if [ "x$1" = "x-e" -o "x$1" = "x--echo" ]; then
+ shift
+ echo "$@"
+fi
+
+[ $# -eq 0 ] && exit 0
+
+TYPE="$1"
+
+# Simple spamcheck. Not very tamper-proof, but if you'd want to spam the server
+# you could do it anyways. This is to protect from accidental loops calling this.
+if [ -r "$LOGCHECK" ]; then
+ # Allow max 150 messages in total
+ LINES=$(cat "$LOGCHECK" | wc -l)
+ [ "$LINES" -gt "150" ] && exit 1
+ # Allow max 5 of same type messages in 30 seconds
+ LINES=$(grep "$TYPE" "$LOGCHECK" | wc -l)
+ if [ "$LINES" -ge "5" ]; then
+ LAST=$(grep "$TYPE" "$LOGCHECK" | tail -n 5 | head -n 1 | awk '{print $1}')
+ if [ -n "$LAST" ]; then
+ DIFF="$(( $NOW - $LAST ))"
+ [ "$DIFF" -lt "30" ] && exit 2
+ fi
+ fi
+fi
+echo "$NOW $TYPE" >> "$LOGCHECK"
+chmod 0666 "$LOGCHECK" 2>/dev/null
+
+if [ $# -lt 2 ]; then
+ MSG="Missing text for $@"
+else
+ MSG="$2"
+fi
+USER=$(whoami)
+MSG="[$USER] $MSG"
+
+if [ $# -gt 2 ]; then
+ EXTRA="$3"
+fi
+
+if [ -n "$SLX_DEBUG" ]; then
+ CURLLOG="/tmp/slxlog.$USER"
+else
+ CURLLOG="/dev/null"
+fi
+
+if [ -n "$EXTRA" ] && [ -r "$EXTRA" -a -s "$EXTRA" ] && [ "$(stat -c %s "$EXTRA")" -lt "10000" ]; then # valid file attachment
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc@$EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
+elif [ -z "$EXTRA" ]; then # no attachment
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
+elif [ -s "$EXTRA" ]; then # empty attachment file (or missing)
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment too large: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
+else # attachment file to big (more than 10k)
+ curl --data-urlencode "type=$TYPE" --data-urlencode "description=$MSG" --data-urlencode "longdesc=Attachment missing/empty: $EXTRA" "$SLX_REMOTE_LOG" >> "$CURLLOG" 2>&1 &
+fi
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
new file mode 100755
index 00000000..879463cd
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Copyright (c) 2013, 2014 - bwLehrpool Projekt
+# Copyright (c) 2012 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# First script for initial ramfs for OpenSLX linux stateless clients
+#############################################################################
+PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin
+
+# Set greeting and add information about the booted system
+len=$(expr length "$(cat /etc/hostname)")
+while [ $len -le 56 ] ; do
+ space="$space "
+ len=$(($len + 1))
+done
+
+sed "s/%space%/$space/g" /opt/openslx/etc/issue.template > /etc/issue
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-early_network_triggers b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-early_network_triggers
new file mode 100755
index 00000000..1e999da6
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-early_network_triggers
@@ -0,0 +1,29 @@
+#!/bin/ash
+
+# This script will trigger several network targets if
+# applicable at an early point.
+# This happens if dhcp/network setup was successful in stage31
+
+# Main interface
+BRIDGE="br0"
+
+if [ ! -e "/sys/class/net/${BRIDGE}/operstate" -o "x$(cat "/sys/class/net/${BRIDGE}/operstate")" == "xup" ] && [ -e "/opt/openslx/uniontmp/etc/hostname" -o -e "/etc/resolv.conf" ]; then
+ echo "Triggering network.target"
+ touch "/run/network/network-ready"
+ systemctl start network.target &
+fi
+
+if [ -s "/etc/resolv.conf" ] && grep -q "^nameserver" "/etc/resolv.conf"; then
+ echo "Triggering network-dns.target"
+ touch "/run/network/dns-ready"
+ systemctl start network-dns.target &
+fi
+
+if route -n | grep -q -E '^0\.0\.0\.0.*U.*G'; then
+ echo "Triggering network-gateway.target"
+ touch "/run/network/gateway-ready"
+ systemctl start network-gateway.target &
+fi
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver
new file mode 100755
index 00000000..7bc310fc
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-load_gfx_driver
@@ -0,0 +1,22 @@
+#!/bin/bash
+PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin
+PCIFILE=/tmp/lspci-output
+
+if ! lspci -n > "$PCIFILE"; then
+ echo "lspci -n failed..."
+ exit 1
+fi
+
+if grep -E ' (8086:0152|8086:0412|8086:0416|1002:6779)( |$)' "$PCIFILE" > /dev/null; then
+ echo "i915 - enable 3D"
+ echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config"
+fi
+
+if lsmod | grep -q '^nvidia\s'; then
+ # nvidia kernel module was loaded in stage31 - download libs
+ systemctl start setup-slx-addon@nvidia_libs &
+ echo -e "# Written by load-gfx-driver\nSLX_VMWARE_3D=yes" >> "/opt/openslx/config"
+fi
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4 b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4
new file mode 100755
index 00000000..10cfca5f
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4
@@ -0,0 +1,71 @@
+#!/bin/bash
+# Needs full bash
+
+. /opt/openslx/config
+PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin
+
+[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; }
+
+MOUNTPOINT="/opt/openslx/mnt/stage4"
+mkdir -p "$MOUNTPOINT"
+
+if [[ "$SLX_STAGE4" == dnbd3* ]]; then
+ # dnbd3 it is
+ if [ -z "${SLX_DNBD3_SERVERS}${SLX_DNBD3_PRIO_SERVERS}" ]; then
+ slxlog --echo "mount-stage4" "dnbd3 stage4 configured, but SLX_DNBD3(_PRIO)_SERVERS empty or not set in /opt/openslx/config."
+ exit 1
+ fi
+ # Determine revision
+ if [ -z "$SLX_STAGE4_RID" ] || echo "$SLX_STAGE4_RID" | grep -v -q -E "^[0-9]+$"; then
+ SLX_STAGE4_RID="0"
+ fi
+ # Randomize list
+ SERVERS=$(for SERVER in $SLX_DNBD3_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //')
+ IMAGE=$(echo $SLX_STAGE4 | awk '{printf $2}')
+ [ -e /var/run/dnbd3.socket ] || sleep 2 # Ugly, service should only start when dnbd3 daemon is up and running
+ RET=1337
+ for SRV in $SLX_DNBD3_PRIO_SERVERS $SERVERS; do
+ echo "Requesting $IMAGE from $SRV"
+ dnbd3=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID")
+ RET=$?
+ [ "$RET" -eq "0" ] && break
+ echo "... didn't work ($RET)"
+ sleep 1
+ done
+ if [ "$RET" -ne "0" ]; then
+ slxlog --echo "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE : $SLX_STAGE4_RID) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)"
+ exit $RET
+ fi
+ echo "Mounting $dnbd3 to $MOUNTPOINT"
+ if ! mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT"; then
+ slxlog --echo "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)"
+ exit 1
+ fi
+else
+ # Try nfs
+ echo "Mounting ${SLX_STAGE4} to $MOUNTPOINT"
+ if ! mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT"; then
+ slxlog --echo "mount-stage4" "Could not mount stage4 from '$SLX_STAGE4' to '$MOUNTPOINT'"
+ exit 1
+ fi
+fi
+
+echo "Appending $MOUNTPOINT to /"
+if mount -o "remount,append:$MOUNTPOINT=ro" /; then
+
+ # addons can trigger ldconfig, hence
+ # make sure no ldconfig is running before copying the real ld cache
+ while ps aux|grep -v grep|grep -q ldconfig; do
+ sleep 1
+ done
+ cp -r "${MOUNTPOINT}/"etc/ld.* /etc/ || echo "Could not really copy full blown ldconfig from stage4 to live system"
+else
+ slxlog --echo "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT' to aufs at /"
+ exit 1
+fi
+
+# dbus reload needed eg. for gnome etc. and perhaps other service files which stage4 needs:
+systemctl reload dbus.service
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
new file mode 100755
index 00000000..0c352241
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
@@ -0,0 +1,168 @@
+#!/bin/ash
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Local hard disk autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
+
+#############################################################################
+
+# Mount point for persistent scratch partition (type 45)
+PERSISTENT="/opt/openslx/persistent"
+
+# General formatter for the /tmp partition on a local harddisk
+diskfm () {
+ mopt="" # Global var!
+ local target="$1"
+ local fslist="xfs jfs ext3 ext2 ext4"
+ local fs
+ local path
+ [ $# -ge 2 ] && fslist="$2"
+ for fs in $fslist ; do
+ unset available
+ case $(cat /proc/filesystems) in
+ *${fs}*) available=yes;;
+ *) modprobe "${fs}" && available=yes;;
+ esac
+ if [ -n "${available}" ]; then
+ unset found
+ if which "mkfs.$fs" ; then
+ found=yes
+ case "mkfs.$fs" in
+ mkfs.xfs)
+ fopt="-f -b size=4k -s size=4k -l size=512b" # fastest formatting possible :)
+ mopt="-o noexec"
+ ;;
+ mkfs.ext2)
+ fopt="-Fq"
+ mopt="-o nocheck,noexec"
+ ;;
+ mkfs.ext3|mkfs.ext4)
+ fopt="-Fq"
+ mopt="-o noexec"
+ ;;
+ mkfs.reiserfs)
+ fopt="-f"
+ mopt="-o noexec"
+ ;;
+ mkfs.jfs)
+ fopt="-q"
+ mopt="-o noexec"
+ ;;
+ esac
+ mkfs.$fs ${fopt} "${target}"
+ fi
+ [ -n "$found" ] && break
+ fi
+ done
+}
+
+mount_temp () {
+ local PRE=$(pwd)
+ if ! cd /tmp; then
+ mount_temp_fallback $@
+ return $?
+ fi
+ mount $@ /tmp || return 1
+ chmod a+rwxt /tmp
+ # Move stuff from working directory, which is old /tmp, to new /tmp just mounted
+ mv ./* ./.[!.]* ./..?* /tmp/ 2> /dev/null
+ local OLD=$(LANG=C ls -alh | grep -v -E ' \.\.?$' | grep -v '^total')
+ [ -n "$OLD" ] && echo -- "Leftovers:" && echo -- "$OLD"
+ cd "$PRE"
+}
+
+mount_temp_fallback () {
+ mkdir -p /tmptmp
+ mv /tmp/* /tmp/.* /tmptmp/ 2> /dev/null
+ mount $@ /tmp || return 1
+ chmod a+rwxt /tmp
+ mv /tmptmp/* /tmptmp/.* /tmp/
+ rmdir /tmptmp
+ return 0
+}
+
+fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition"
+
+if [ ! -s "/etc/disk.partition" ]; then
+ sleep 3
+ fdisk -l | sed -n "/^\/dev\//p" > "/etc/disk.partition"
+fi
+
+echo "Partitions:"
+cat "/etc/disk.partition"
+
+# Check for standard swap partitions and make them available to the system
+HAVE_SWAP=no
+for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ echo -e "$hdpartnr\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab"
+ swapon "$hdpartnr" -p 10 && HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that)
+done
+
+# We use special non assigned partition type (id44) for harddisk scratch
+# space, thus no normal filesystem will be incidentally deleted or
+# corrupted
+HAVE_TEMP=no
+for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ # check for supported filesystem and formatter
+ if diskfm "$hdpartnr"; then
+ # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ mount_temp "$mopt" "$hdpartnr" || continue
+ echo -e "${hdpartnr}\t/tmp\t\tauto\t\tnoexec\t 0 0" >> "/etc/fstab"
+ HAVE_TEMP=yes
+ break
+ else
+ echo "formatting failed for some reason"
+ fi # Made this non-forking, systemd should handle it - 2013-05-28
+done
+
+# Put detected linux partitions (83) into /etc/fstab with "noauto", special
+# partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx
+HAVE_PERSISTENT=no
+for partid in 83 45 46 ; do
+ for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ if [ "${partid}" -eq 83 ]; then
+ mkdir -p "/media/${hdpartnr#/dev/*}"
+ echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
+ elif [ "${partid}" -eq 45 -a "$HAVE_PERSISTENT" = "no" ]; then
+ mkdir -p "$PERSISTENT"
+ if ! mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT"; then
+ diskfm "$hdpartnr" "jfs xfs ext3" || continue
+ mount -t auto -o noexec "${hdpartnr}" "$PERSISTENT" || continue
+ fi
+ HAVE_PERSISTENT=yes
+ echo -e "${hdpartnr}\t${PERSISTENT}\tauto\t\tnoauto,noexec\t\t 0 0" >> "/etc/fstab"
+ elif [ "${partid}" -eq 46 ]; then
+ mkdir -p "/media/${hdpartnr#/dev/*}"
+ #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\
+ #test -d /mnt/media/${hdpartnr#/dev/*}/home && \
+ # ln -sf /media/${hdpartnr#/dev/*} /var/home
+ echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
+ fi
+ done
+done
+[ "$HAVE_PERSISTENT" = "no" -a -d "$PERSISTENT" ] && rm -f "$PERSISTENT"
+
+mount -a
+
+# Make huge tmpfs if nothing could be mounted for /tmp
+if [ "$HAVE_TEMP" = "no" ]; then
+ mount_temp -t tmpfs -o size=60G none
+ slxlog "partition-temp" "Running /tmp on tmpfs only!" "/etc/disk.partition"
+fi
+if [ "$HAVE_SWAP" = "no" ]; then
+ TOTAL_RAM=$(grep ^MemTotal /proc/meminfo | awk '{print $2}')
+ if [ -n "$TOTAL_RAM" ] && [ "$TOTAL_RAM" -lt "3000000" ]; then
+ slxlog "partition-swap" "Have no (formatted) swap partition, using zram swap only!" "/etc/disk.partition"
+ fi
+fi
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
new file mode 100755
index 00000000..8fb2579a
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
@@ -0,0 +1,94 @@
+#!/bin/bash
+# Needs full bash
+#
+# Script to be called by systemd
+#
+# Downloads and appends addons per sqfs/aufs.
+#
+######################################################################################
+#
+# Two modes for this script:
+# - without any arguments, it will just go through the list of addons to
+# setup as given through the OpenSLX configuration file
+# - with an argument, it will setup the addon given as $1
+#
+#
+######################################################################################
+
+export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin
+
+# read global OpenSLX config
+. /opt/openslx/config || { echo "Could not source config!"; exit 23; }
+
+# source functions.inc for the download function
+. /opt/openslx/inc/functions || { echo "/opt/openslx/inc/functions not found!"; exit 1337; }
+
+# quick fix for the missing FUTURE_ROOT needed by /opt/openslx/etc/functions.inc
+export FUTURE_ROOT="/"
+
+# read openslx config, especially servers given by SLX_KCL_SERVERS and SLX_CONFIG_SERVERS
+if [ -z "${SLX_CONFIG_SERVERS}" ]; then
+ echo "SLX_CONFIG_SERVERS is not set in /opt/openslx/config. Will only try the base servers from the cmdline."
+ #[ -z "${SLX_KCL_SERVERS}" ] && SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv")
+fi
+
+# read base slx servers from cmdline
+BASE_MOUNT_POINT="/opt/openslx/mnt"
+DOWNLOAD_DEST="/tmp/addons"
+mkdir -p "$DOWNLOAD_DEST" || { echo "Failed to create $DOWNLOAD_DEST"; exit 1; }
+
+######################################################################################
+#
+# NO ARGUMENTS -> LOOP OVER ALL ADDONS
+#
+
+if [ $# -eq 0 ]; then
+ [ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; }
+ for ADDON in ${SLX_ADDONS}; do
+ systemctl start "setup-slx-addon@$ADDON" &
+ done
+fi
+
+######################################################################################
+#
+# WITH ARGUMENTS -> SETUP ADDON
+#
+
+if [ $# -eq 1 ]; then
+ ADDON="$1"
+
+ # download the addon from the given URL
+ ADDON_TARGET_PATH="${DOWNLOAD_DEST}/$(basename "$ADDON").sqfs"
+ if ! download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"; then
+ slxlog --echo "addon-download" "Download of '${HTTP_BASE_PATH}/${ADDON}.sqfs' failed."
+ exit 1
+ fi
+
+ # now mount it to $BASE_MOUNT_POINT/<addon-name>
+ ADDON_MOUNT_POINT="${BASE_MOUNT_POINT}/$(basename "$ADDON")"
+ mkdir -p "$ADDON_MOUNT_POINT"
+ mount -t squashfs -o ro "$ADDON_TARGET_PATH" "$ADDON_MOUNT_POINT" || \
+ { slxlog --echo "addon-mount" "Failed to mount $ADDON_TARGET_PATH."; exit 1; }
+
+ # now append it to /
+ echo "Appending ${ADDON_MOUNT_POINT} to /"
+ if ! mount -o "remount,ins:1:${ADDON_MOUNT_POINT}=rr" / ; then # ins:2 makes sure the addon is after tmpfs and stage32, but before stage4
+ slxlog --echo "addon-aufs" "Failed to append ${ADDON_MOUNT_POINT} to the aufs. Cleaning up..."
+ umount -l ${ADDON_MOUNT_POINT} || echo "Could not unmount ${ADDON_MOUNT_POINT}!"
+ exit 1
+ fi
+
+ # Run post-hook if available
+ if [ -x "$ADDON_MOUNT_POINT/addon-init" ]; then
+ "$ADDON_MOUNT_POINT/addon-init" || \
+ slxlog --echo "addon-init" "Warning: Could not execute addon-init of $ADDON"
+ fi
+ if ! grep -q '/opt/openslx/mnt/stage4' "/proc/mounts"; then
+ ldconfig 2> /dev/null || ldconfig.real 2> /dev/null
+ fi
+fi
+
+[ $# -gt 1 ] && { echo "Error - $0 only takes no or one argument. $# given." && exit 1; }
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap
new file mode 100755
index 00000000..f8bd5682
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-zram_swap
@@ -0,0 +1,60 @@
+#!/bin/ash
+# Copyright (c) 2013 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found under http://openslx.org
+#
+# Local hard disk autodetection script for OpenSLX linux stateless clients,
+# detecting swap and special partitions
+
+#############################################################################
+
+
+# Add zram swap
+# Some older ubuntu kernels had a problem here, see https://bugs.launchpad.net/ubuntu/+source/linux-lts-raring/+bug/1217189
+# So make sure you're up to date
+
+make_swap () {
+ [ $# -ne 2 ] && echo "make_swap: Wrong parameter count $#" && exit 1
+ local USE="$1"
+ local DEV="$2"
+ echo "$USE" > "/sys/block/zram${DEV}/disksize"
+ mkswap "/dev/zram${DEV}"
+ swapon "/dev/zram${DEV}" -p 1000 # high priority (in case we have hdd swap 0x82, prefer zram)
+}
+
+CPUS=$(grep -c -E "^processor.*[0-9]+$" "/proc/cpuinfo")
+if [ -z "$CPUS" ]; then
+ echo "ERROR: Could not determine CPU core count"
+ exit 1
+fi
+
+[ "$CPUS" -gt "16" ] && CPUS=16 # zram can only handle up to 32 devices, the system can apparently even just handle 29 swap partitions, so use a reasonable upper limit
+if ! modprobe zram "num_devices=$CPUS"; then
+ echo "ERROR: Could not load zram module"
+ exit 1
+fi
+
+TOTAL=$(grep ^MemTotal /proc/meminfo | awk '{print $2}')
+USE=$(( $TOTAL / ( 2 * $CPUS ) ))
+echo "Have $CPUS cores, $TOTAL kb mem, use $USE kb zram swap per core"
+USE=$(( $USE * 1024 ))
+DEV=0
+while [ "$DEV" -lt "$CPUS" ]; do
+ make_swap "$USE" "$DEV" &
+ LAST=$!
+ DEV=$(( $DEV + 1 ))
+done
+
+# Wait, so we don't trigger swap.target too early
+while kill -0 "$LAST"; do
+ usleep 100000
+done
+
+exit 0
+
diff --git a/core/rootfs/rootfs-stage32/data/root/.bashrc b/core/rootfs/rootfs-stage32/data/root/.bashrc
new file mode 100644
index 00000000..6266b0f4
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/data/root/.bashrc
@@ -0,0 +1,48 @@
+[ -z "$PS1" ] && return
+HISTCONTROL=ignoredups:ignorespace
+shopt -s histappend
+HISTSIZE=1000
+HISTFILESIZE=2000
+shopt -s checkwinsize
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+case "$TERM" in
+ xterm-color) color_prompt=yes;;
+esac
+force_color_prompt=yes
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+alias ll='ls -alFh'
+alias la='ls -A'
+alias l='ls -CF'
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+export PATH=/root/bin:$PATH
diff --git a/core/rootfs/rootfs-stage32/module.build b/core/rootfs/rootfs-stage32/module.build
new file mode 100644
index 00000000..4fbc26b5
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.build
@@ -0,0 +1,146 @@
+#!/bin/bash
+fetch_source() {
+ :
+}
+
+build() {
+ if [ ! -z "$REQUIRED_CONTENT_PACKAGES" ]; then
+ local COPYLIST="list_dpkg_output"
+ [ -e "${COPYLIST}" ] && rm "${COPYLIST}"
+ list_packet_files >> "${COPYLIST}"
+ tarcopy "$(cat "${COPYLIST}" | sort -u)" "${MODULE_BUILD_DIR}"
+ fi
+
+ local FILELIST="list_binaries_and_files"
+ [ -e "${FILELIST}" ] && rm "${FILELIST}"
+
+ # Compile rdns
+ mkdir -p "$MODULE_BUILD_DIR/opt/openslx/bin"
+ gcc -o "$MODULE_BUILD_DIR/opt/openslx/bin/rdns" "$MODULE_DIR/rdns.c" || perror "Compiling rdns failed."
+ # Get ldconfig
+ mkdir -p "$MODULE_BUILD_DIR/sbin"
+ local LOC=$(which ldconfig.real)
+ [ -z "$LOC" ] && LOC=$(which ldconfig)
+ [ -z "$LOC" ] && perror "Cannot find ldconfig"
+ pdebug "Picking ldconfig from $LOC"
+ cp "$LOC" "$MODULE_BUILD_DIR/sbin/ldconfig"
+
+ pinfo "Searching binaries from config file in system..."
+ for BIN in ${REQUIRED_BINARIES}
+ do
+ [ -n "$(find "$MODULE_BUILD_DIR" -name "$BIN")" ] && continue
+ BIN_LOCATION="$(which "$BIN")"
+ if [ ! -z "$BIN_LOCATION" -a -e "$BIN_LOCATION" ]; then
+ get_link_chain "$BIN_LOCATION" >> "$FILELIST"
+ else
+ perror "${BIN} not found on the system! Please install it."
+ fi
+ done
+
+ pinfo "Searching libraries from config file in system... (could take some time)"
+ for LIB in ${REQUIRED_LIBRARIES}
+ do
+ # lib + lib64: Ugly hack, will be replaced by a better solution
+ for LIB_LOCATION in $(find /lib/ /lib64/ -name "${LIB}.so*")
+ do
+ get_link_chain "${LIB_LOCATION}" >> "${FILELIST}"
+ done
+ done
+
+ for FILE in ${REQUIRED_DIRECTORIES}
+ do
+ [ ! -d ${FILE} ] && perror "Missing required directory $FILE"
+ echo ${FILE} >> "${FILELIST}"
+ done
+ for FILE in ${REQUIRED_FILES}
+ do
+ [ ! -f ${FILE} ] && perror "Missing required file $FILE"
+ echo ${FILE} >> "${FILELIST}"
+ done
+
+ local NUMFILES=$(cat "${FILELIST}" | wc -l)
+ if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then
+ pinfo "File list generated at ${MODULE_BUILD_DIR}/${FILELIST} ($NUMFILES entries)"
+ pinfo "If something fails here, try to clean this module first."
+ tarcopy "$(cat "${FILELIST}")" "${MODULE_BUILD_DIR}"
+ fi
+}
+
+post_copy() {
+ # symlink for more
+ if [ ! -e "$TARGET_BUILD_DIR/bin/more" ]; then
+ [ -e "$TARGET_BUILD_DIR/bin/less" ] && ln -s /bin/less "$TARGET_BUILD_DIR/bin/more"
+ [ -e "$TARGET_BUILD_DIR/usr/bin/less" ] && ln -s /usr/bin/less "$TARGET_BUILD_DIR/bin/more"
+ fi
+ # same hack for mount
+ [ ! -e "$TARGET_BUILD_DIR/bin/mount" ] && ln -s /usr/bin/mount "$TARGET_BUILD_DIR/bin/mount"
+
+ # make basic directory structure
+ mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,run,sys,var,opt/openslx/mnt}
+ ln -s -n -f -t "$TARGET_BUILD_DIR/var" "../run/lock" "../run"
+
+ # copy devices from running system
+ cp -a /dev/{console,kmsg,mem,null,shm,tty,tty0,tty1,tty9,urandom,zero} \
+ "${TARGET_BUILD_DIR}"/dev || perror "Copying devices from running system failed."
+
+ # set /etc/environment to include /opt/openslx/bin and /opt/openslx/sbin
+ #add_env PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
+ add_env PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
+ # set terminal to linux as it defaults to xterm which messes up ssh sessions
+ add_env TERM "linux"
+
+ # quick fix for /etc/fstab
+ [ ! -e "${TARGET_BUILD_DIR}/etc/fstab" ] && echo "# no configuration" > "${TARGET_BUILD_DIR}/etc/fstab"
+
+ # link /etc/mtab, needed for systemd
+ [ ! -e "${TARGET_BUILD_DIR}/etc/mtab" ] && ln -s "/proc/self/mounts" "${TARGET_BUILD_DIR}/etc/mtab"
+
+ # passwd, group, shadow
+ init_users_and_groups
+
+ # quick fix for missing group in /etc/group
+ add_group "lock"
+ add_group "nogroup"
+ add_user "nobody"
+
+ # setup root account
+ PASSWORD= USER=root add_user
+ DEMO_ID="$(USER=demo PASSWORD= USERHOME=/home/demo USERSHELL=/bin/bash add_user)"
+
+ mkdir -p "${TARGET_BUILD_DIR}/root"
+ mkdir -p "${TARGET_BUILD_DIR}/home/demo"
+ chown "$DEMO_ID:$DEMO_ID" "${TARGET_BUILD_DIR}/home/demo"
+ sed -i -r 's/^blacklist.*pcspkr/#&/g' "$TARGET_BUILD_DIR/etc/modprobe.d/blacklist.conf"
+
+ echo "minilinux-$(hostname)" > "${TARGET_BUILD_DIR}/etc/hostname"
+
+
+ # copy kernel, modules and firmware
+ copy_kernel_modules
+ copy_firmware
+ copy_kernel
+
+ # Try to fetch distro logo
+ if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then
+ local DIST=$(lsb_release -si)
+ if [ -n "$DIST" ]; then
+ [ -z "$CFG_DISTLOGO_URL" ] && CFG_DISTLOGO_URL='http://mltk-services.ruf.uni-freiburg.de/distro_logo.php?distro='
+ wget -t 3 -T 3 -O "$TARGET_BUILD_DIR/etc/distro.png" "${CFG_DISTLOGO_URL}${DIST}"
+ if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then
+ rm -f "$TARGET_BUILD_DIR/etc/distro.png"
+ pwarning "Could not download distro-logo"
+ fi
+ else
+ pwarning "Could not determine distribution"
+ fi
+ fi
+ # Create issue.template
+ local DIST=$(lsb_release -sd)
+ local GITC=$(git rev-parse --short HEAD)
+ local DATE=$(date "+%Y-%m-%d")
+ local VERSION=$(echo "bwLehrpool/$DIST $DATE/$GITC" | escape_replace)
+ mkdir -p "$TARGET_BUILD_DIR/opt/openslx/etc"
+ sed "s/%version%/$VERSION/g" "$MODULE_DIR/templates/issue.template" > "$TARGET_BUILD_DIR/opt/openslx/etc/issue.template" || perror "Could not create issue template"
+
+}
+
diff --git a/core/rootfs/rootfs-stage32/module.conf b/core/rootfs/rootfs-stage32/module.conf
new file mode 100644
index 00000000..0e62ab55
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf
@@ -0,0 +1,261 @@
+REQUIRED_MODULES="
+ kernel
+"
+REQUIRED_BINARIES="
+ bash
+ dmesg
+ curl
+ less
+ agetty
+ loadkeys
+ setfont
+ login
+ sulogin
+ mount
+ umount
+ mount.nfs4
+ umount.nfs4
+ mkfs.xfs
+ mkfs.ext3
+ mkfs.ext4
+ blkid
+ modprobe
+ insmod
+ lsmod
+ rm
+ kill
+ ps
+ scp
+ ssh
+ tput
+ xterm
+ bc
+ dirname
+ mkdosfs
+ iptables
+ rdns
+ find
+ rpcbind
+ rpc.statd
+ pkill
+ getent
+ ldconfig
+ grep
+ date
+ cat
+ ls
+ awk
+ sed
+"
+REQUIRED_LIBRARIES="
+ libcap
+ libcidn
+ libcom_err
+ libcrypt
+ libcrypto
+ libnsl
+ libnss_compat
+ libnss_dns
+ libnss_files
+ libnss_hesiod
+ libnss_nis
+ libnss_nisplus
+ libnss_mdns
+ libpam
+ libutil
+ libtinfo
+ libresolv
+"
+REQUIRED_FILES="
+ /etc/inputrc
+ /etc/localtime
+ /etc/login.defs
+ /etc/securetty
+ /etc/protocols
+ /etc/services
+ /etc/networks
+ /etc/netconfig
+ /etc/fonts/fonts.conf
+"
+REQUIRED_KERNEL_MODULES="
+ kernel/drivers/cpufreq
+ kernel/drivers/memstick
+ kernel/drivers/mfd
+ kernel/drivers/gpio
+ kernel/drivers/block
+ kernel/drivers/uwb
+ kernel/drivers/w1
+ kernel/drivers/regulator
+ kernel/drivers/leds
+ kernel/drivers/firmware
+ kernel/drivers/watchdog
+ kernel/drivers/media/rc
+ kernel/drivers/media/video
+ kernel/drivers/media/common
+ kernel/drivers/mmc
+ kernel/drivers/staging
+ kernel/drivers/firewire
+ kernel/drivers/bluetooth
+ kernel/drivers/power
+ kernel/drivers/video
+ kernel/drivers/uio
+ kernel/drivers/md
+ kernel/drivers/virtio
+ kernel/drivers/pci
+ kernel/drivers/acpi
+ kernel/drivers/input
+ kernel/drivers/ssb
+ kernel/drivers/spi
+ kernel/drivers/crypto
+ kernel/drivers/bcma
+ kernel/drivers/nfc
+ kernel/drivers/usb
+ kernel/drivers/char
+ kernel/drivers/vhost
+ kernel/drivers/i2c
+ kernel/drivers/ata
+ kernel/drivers/tty
+ kernel/drivers/parport
+ kernel/drivers/misc
+ kernel/drivers/scsi
+ kernel/drivers/message
+ kernel/drivers/auxdisplay
+ kernel/drivers/target
+ kernel/drivers/dca
+ kernel/drivers/dma
+ kernel/drivers/rtc
+ kernel/drivers/pps
+ kernel/drivers/hid
+ kernel/drivers/atm
+ kernel/drivers/platform
+ kernel/drivers/edac
+ kernel/drivers/hv
+ kernel/drivers/idle
+ kernel/drivers/xen
+ kernel/ubuntu/aufs
+ kernel/arch
+ kernel/lib
+ kernel/fs
+ kernel/crypto
+ kernel/net
+ kernel/sound
+ kernel/fs/autofs4/autofs4
+ kernel/drivers/net/macvtap.ko
+ kernel/drivers/net/veth.ko
+ kernel/drivers/net/vxlan.ko
+ kernel/net/openvswitch/openvswitch.ko
+"
+REQUIRED_FIRMWARE="
+ 3com
+ acenic
+ adaptec
+ advansys
+ ar3k
+ asihpi
+ av7110
+ bnx2
+ bnx2x
+ brcm
+ cis
+ cpia2
+ cxgb3
+ cxgb4
+ dabusb
+ dsp56k
+ e100
+ ea
+ edgeport
+ emi26
+ emi62
+ ene-ub6250
+ ess
+ hp
+ isci
+ kaweth
+ keyspan
+ keyspan_pda
+ korg
+ libertas
+ matrox
+ mrvl
+ mwl8k
+ ositech
+ r128
+ radeon
+ RTL8192E
+ RTL8192SE
+ rtl_nic
+ sb16
+ scripts
+ slicoss
+ sun
+ sxg
+ tehuti
+ ti-connectivity
+ tigon
+ ttusb-budget
+ ueagle-atm
+ usbdux
+ vicam
+ vxge
+ yam
+ yamaha
+ agere_ap_fw.bin
+ agere_sta_fw.bin
+ aic94xx-seq.fw
+ ath3k-1.fw
+ atmel_at76c502_3com.bin
+ atmel_at76c502.bin
+ atmel_at76c502d.bin
+ atmel_at76c502e.bin
+ atmel_at76c504_2958.bin
+ atmel_at76c504a_2958.bin
+ atmel_at76c504.bin
+ atmel_at76c506.bin
+ atmsar11.fw
+ carl9170-1.fw
+ f2255usb.bin
+ GPL-3
+ htc_7010.fw
+ htc_9271.fw
+ i2400m-fw-usb-1.4.sbcf
+ i2400m-fw-usb-1.5.sbcf
+ i6050-fw-usb-1.5.sbcf
+ intelliport2.bin
+ lbtf_usb.bin
+ lgs8g75.fw
+ mts_cdma.fw
+ mts_edge.fw
+ mts_gsm.fw
+ mts_mt9234mu.fw
+ mts_mt9234zba.fw
+ mwl8335_duplex.fw
+ NPE-B
+ NPE-C
+ phanfw.bin
+ rt2561.bin
+ rt2561s.bin
+ rt2661.bin
+ rt2860.bin
+ rt2870.bin
+ rt3070.bin
+ rt3071.bin
+ rt3090.bin
+ rt73.bin
+ s2250.fw
+ s2250_loader.fw
+ TDA7706_OM_v2.5.1_boot.txt
+ TDA7706_OM_v3.0.2_boot.txt
+ ti_3410.fw
+ ti_5052.fw
+ tlg2300_firmware.bin
+ tr_smctr.bin
+ usbduxfast_firmware.bin
+ usbdux_firmware.bin
+ usbduxsigma_firmware.bin
+ vntwusb.fw
+ WHENCE.ubuntu
+ whiteheat.fw
+ whiteheat_loader.fw
+"
+
diff --git a/core/rootfs/rootfs-stage32/module.conf.centos b/core/rootfs/rootfs-stage32/module.conf.centos
new file mode 100644
index 00000000..b48da75e
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.centos
@@ -0,0 +1,16 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-utils
+ xfsprogs
+ squashfs-tools
+ curl
+ xvidtune
+ xterm
+"
+REQUIRED_CONTENT_PACKAGES="
+"
+REQUIRED_DIRECTORIES="
+ /usr/$LIB64/xtables
+"
+REQUIRED_FILES+="
+ /usr/share/X11/app-defaults/Xvidtune
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.debian b/core/rootfs/rootfs-stage32/module.conf.debian
new file mode 100644
index 00000000..fbf489e7
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.debian
@@ -0,0 +1,19 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-common
+ squashfs-tools
+ whois
+ xfsprogs
+ firmware-linux-free
+ curl
+ jfsutils
+ libssl-dev
+"
+REQUIRED_CONTENT_PACKAGES="
+
+"
+REQUIRED_DIRECTORIES="
+ /lib/xtables
+"
+REQUIRED_FILES+="
+ /etc/X11/app-defaults/Xvidtune
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.fedora b/core/rootfs/rootfs-stage32/module.conf.fedora
new file mode 100644
index 00000000..b48da75e
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.fedora
@@ -0,0 +1,16 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-utils
+ xfsprogs
+ squashfs-tools
+ curl
+ xvidtune
+ xterm
+"
+REQUIRED_CONTENT_PACKAGES="
+"
+REQUIRED_DIRECTORIES="
+ /usr/$LIB64/xtables
+"
+REQUIRED_FILES+="
+ /usr/share/X11/app-defaults/Xvidtune
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.opensuse b/core/rootfs/rootfs-stage32/module.conf.opensuse
new file mode 100644
index 00000000..a9601b88
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.opensuse
@@ -0,0 +1,22 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-client
+ xfsprogs
+ squashfs
+ timezone
+ libcap2
+ jfsutils
+ curl
+"
+REQUIRED_CONTENT_PACKAGES="
+ timezone
+ libcap2
+"
+REQUIRED_DIRECTORIES="
+ /usr/$LIB64/xtables
+"
+REQUIRED_FILES+="
+ /usr/share/X11/app-defaults/Xvidtune
+"
+REQUIRED_KERNEL_MODULES+="
+ kernel/drivers/cdrom
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.opensuse.13.1 b/core/rootfs/rootfs-stage32/module.conf.opensuse.13.1
new file mode 100644
index 00000000..aa7f8afb
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.opensuse.13.1
@@ -0,0 +1,20 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-client
+ xfsprogs
+ squashfs
+ timezone
+ libcap2
+ jfsutils
+ curl
+ xvidtune
+"
+REQUIRED_CONTENT_PACKAGES="
+ timezone
+ libcap2
+"
+REQUIRED_DIRECTORIES="
+ /usr/$LIB64/xtables
+"
+REQUIRED_FILES+="
+ /usr/share/X11/app-defaults/Xvidtune
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.opensuse.13.2 b/core/rootfs/rootfs-stage32/module.conf.opensuse.13.2
new file mode 100644
index 00000000..aa7f8afb
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.opensuse.13.2
@@ -0,0 +1,20 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-client
+ xfsprogs
+ squashfs
+ timezone
+ libcap2
+ jfsutils
+ curl
+ xvidtune
+"
+REQUIRED_CONTENT_PACKAGES="
+ timezone
+ libcap2
+"
+REQUIRED_DIRECTORIES="
+ /usr/$LIB64/xtables
+"
+REQUIRED_FILES+="
+ /usr/share/X11/app-defaults/Xvidtune
+"
diff --git a/core/rootfs/rootfs-stage32/module.conf.ubuntu b/core/rootfs/rootfs-stage32/module.conf.ubuntu
new file mode 100644
index 00000000..77c68cef
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/module.conf.ubuntu
@@ -0,0 +1,21 @@
+REQUIRED_INSTALLED_PACKAGES="
+ nfs-common
+ squashfs-tools
+ whois
+ xfsprogs
+ curl
+ openssl
+"
+REQUIRED_CONTENT_PACKAGES="
+ openssl
+"
+REQUIRED_BINARIES+="
+ openssl
+"
+REQUIRED_DIRECTORIES="
+ /lib/xtables
+"
+REQUIRED_FILES+="
+ /etc/X11/app-defaults/Xvidtune
+ /usr/lib/ssl/openssl.cnf
+"
diff --git a/core/rootfs/rootfs-stage32/rdns.c b/core/rootfs/rootfs-stage32/rdns.c
new file mode 100644
index 00000000..218f7400
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/rdns.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <errno.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+int main(int argc, char *argv[])
+{
+ if (argc != 2) {
+ fprintf(stderr,"usage: %s <IPADDRESS>\n", argv[0]);
+ return 1;
+ }
+
+ struct hostent *he;
+ struct in_addr ipv4addr;
+ struct in6_addr ipv6addr;
+
+ inet_pton(AF_INET, argv[1], &ipv4addr);
+ he = gethostbyaddr(&ipv4addr, sizeof ipv4addr, AF_INET);
+ if (he == NULL) return 2;
+ if (he->h_name == NULL) return 3;
+ printf("%s\n", he->h_name);
+
+ return 0;
+}
+
diff --git a/core/rootfs/rootfs-stage32/templates/issue.template b/core/rootfs/rootfs-stage32/templates/issue.template
new file mode 100644
index 00000000..a79797ad
--- /dev/null
+++ b/core/rootfs/rootfs-stage32/templates/issue.template
@@ -0,0 +1,9 @@
+ WELCOME TO %space% \n (\l)
+ _____ ______ ______ __ __ _______ __ __ __
+ / _ | _ | ___| | | | | ____| | | | | |
+ | | | | |_| | |_ | | | | |___ | | / /
+ | | | | ___/| _| | | ____ | | | |
+ | |_| | | | |___| | | | ____| | |___ / /
+ _____/|__| |______|__| |__| |_______|______|__| |__| - NG
+
+ %version% (c) <OpenSLX.ORG>