summaryrefslogtreecommitdiffstats
path: root/remote/rootfs
diff options
context:
space:
mode:
Diffstat (limited to 'remote/rootfs')
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/bin/setup_network2
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/bin/setup_stage326
-rw-r--r--remote/rootfs/rootfs-stage31/data/etc/functions.inc (renamed from remote/rootfs/rootfs-stage31/data/etc/functions)49
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init4
-rw-r--r--remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf2
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue2
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions136
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons27
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.build3
9 files changed, 130 insertions, 101 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network
index 8e070bdf..b504a92b 100755
--- a/remote/rootfs/rootfs-stage31/data/bin/setup_network
+++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network
@@ -26,7 +26,7 @@ IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]
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]')
+ 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
diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
index 151617bc..cf20fbf5 100755
--- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
+++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32
@@ -34,7 +34,7 @@ STAGE32_TARGET_PATH="/stage32.sqfs"
STAGE32_MOUNT_POINT="/rorootfs"
# try to download it
-download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || return 1
+download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!"
# try to mount it at STAGE32_MOUNT_POINT
echo "Mounting stage 3.2 as SquashFS..."
@@ -45,3 +45,7 @@ mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || d
mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp
mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp."
FUTURE_ROOT="/mnt"
+
+# "Delete" addon hook-script in aufs view
+touch "/mnt/opt/openslx/uniontmp/.wh.addon-init"
+
diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions.inc
index 37bb7d89..ce510aac 100644
--- a/remote/rootfs/rootfs-stage31/data/etc/functions
+++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc
@@ -11,9 +11,9 @@
# drop_shell "This is your error message."
#
drop_shell() {
- [ $# -gt 0 ] && echo $@
- echo "CTRL + D will continue booting."
- setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+ [ $# -gt 0 ] && echo $@
+ echo "CTRL + D will continue booting."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
}
#########################################################################
@@ -28,7 +28,7 @@ read_from_cmdline(){
local OPTION="$1"
local VALUE=""
-
+
VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)"
if [ -z "$VALUE" ]; then
echo "Error - '${OPTION}=' not found in command line, or empty"
@@ -40,7 +40,7 @@ read_from_cmdline(){
#########################################################################
#
-# Helper function to download given FILE_URL from servers in 'slxsrv'
+# 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:
@@ -53,8 +53,8 @@ read_from_cmdline(){
# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config"
#
download() {
- [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1
-
+ [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1
+
if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then
. "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'"
else
@@ -62,29 +62,30 @@ download() {
SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')"
echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config"
fi
-
- local FILE_URL="$1"
- local TARGET_PATH="$2"
-
- for TIMEOUT in 1 2 3 4 5; do
- for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do
+
+ 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 4 4 10; 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" ]; then
+ if [ "x$RET" != "x0" -o ! -e "$TARGET_PATH" ]; then
echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET"
- echo "Trying again in $(($TIMEOUT * 500)) ms..."
- [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..."
- usleep $(($TIMEOUT * 500000))
+ usleep 50000 # 50ms
else
- [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'."
+ echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'."
return 0
fi
done
+ echo "Trying again in $(($TIMEOUT * 250)) ms..."
+ usleep $(($TIMEOUT * 250000))
done
-
- # check if it actually worked
- if [ ! -e $TARGET_PATH ]; then
- echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed."
- return 1
- fi
+ # Max retries reached, no success :-(
+ return 1
}
+
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index 7e05084d..a75caab0 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -64,7 +64,7 @@ for opts in ${KCL}; do
export NFSSERVER=${nfs%:/*}
;;
BOOTIF=*)
- export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[a-z]' '[A-Z]' )" ;;
+ export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network)
esac
done
@@ -91,7 +91,7 @@ fi
# copy files needed for stage3.2 to FUTURE_ROOT
[ $DEBUG -ge 1 ] && echo "Copying busybox etc. to stage32..."
-tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/"
+tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions.inc" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/"
#echo 'blacklist pcspkr' >> /mnt/etc/modprobe.d/blacklist.conf
# one last debug shell if activated
diff --git a/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf
new file mode 100644
index 00000000..ef610bdc
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf
@@ -0,0 +1,2 @@
+D /run/lock 1777 root root
+
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
index c09162dc..8fbd5c8b 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue
@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
# Set greeting and add information on booted system
# Fixme (add version string and distro name)
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
index f162ec3a..bc5ce9c1 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions
@@ -17,38 +17,48 @@
# General formatter for the /tmp partition on a local harddisk
diskfm () {
-local target="$1"
-local fs
-local path
-for fs in xfs ext3 ext2 ; 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"
- mopt="-o noexec"
- ;;
- mkfs.ext2)
- fopt="-Fq"
- mopt="-o nocheck,noexec"
- ;;
- mkfs.reiserfs)
- fopt="-f"
- mopt="-o noexec"
- ;;
- esac
- mkfs.$fs ${fopt} "${target}"
- fi
- [ -n "$found" ] && break
- fi
-done
+ local target="$1"
+ local fs
+ local path
+ for fs in xfs ext3 ext2 ; 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"
+ mopt="-o noexec"
+ ;;
+ mkfs.ext2)
+ fopt="-Fq"
+ mopt="-o nocheck,noexec"
+ ;;
+ mkfs.reiserfs)
+ fopt="-f"
+ mopt="-o noexec"
+ ;;
+ esac
+ mkfs.$fs ${fopt} "${target}"
+ fi
+ [ -n "$found" ] && break
+ fi
+ done
+}
+
+function mount_temp () {
+ 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
}
# Check for local harddisks and appropriate partitions
@@ -66,46 +76,46 @@ for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space
swapon "$hdpartnr"
done
-# We use special non assigned partition type (id44) for harddisk scratch
+# We use special non assigned partition type (id44) for harddisk scratch
# space, thus no normal filesystem will be incidentally deleted or
# corrupted
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
- echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab"
- mkdir -p /tmptmp
- mv /tmp/* /tmp/.* /tmptmp/
- mount "$hdpartnr" /tmp
- chmod a+rwxt /tmp
- mv /tmptmp/* /tmptmp/.* /tmp/
- rmdir /tmptmp
- break
- else
- echo "formatting failed for some reason"
- fi # Made this non-forking, systemd should handle it - 2013-05-28
+ # check for supported filesystem and formatter
+ if diskfm "$hdpartnr"; then
+ # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready
+ mount_temp "$hdpartnr" || continue
+ echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab"
+ 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
for partid in 83 45 46 ; do
- for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
- mkdir -p "/media/${hdpartnr#/dev/*}"
- if [ "${partid}" -eq 83 ]; then
- echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
- elif [ "${partid}" -eq 45 ]; then
- #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*}
- #ln -sf /media/${hdpartnr#/dev/*} /var/scratch
- echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
- elif [ "${partid}" -eq 46 ]; then
- # Mount a home directory to (/mnt)/var/home
- #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
+ for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do
+ mkdir -p "/media/${hdpartnr#/dev/*}"
+ if [ "${partid}" -eq 83 ]; then
+ echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab"
+ elif [ "${partid}" -eq 45 ]; then
+ #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*}
+ #ln -sf /media/${hdpartnr#/dev/*} /var/scratch
+ echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab"
+ elif [ "${partid}" -eq 46 ]; then
+ # Mount a home directory to (/mnt)/var/home
+ #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
mount -a
+# Make huge tmpfs if nothing could be mounted for /tmp
+if [ "$(mount | grep -c "on /tmp ")" = "0" ]; then
+ mount_temp -t tmpfs -o size=10G none
+fi
+
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
index a3350424..a5dc9965 100755
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons
@@ -6,12 +6,14 @@
#
#
-. /opt/openslx/etc/functions
+. /opt/openslx/config || { echo "Could not source config!"; exit 23; }
+[ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; }
+
+. /opt/openslx/etc/functions.inc || { echo "functions.inc not found!"; exit 1337; }
+
export FUTURE_ROOT="/"
# read openslx config
-. /opt/openslx/config
-[ -z "${SLX_ADDONS}" ] && { echo "SLX_ADDONS is not set in /opt/openslx/config." && exit 1; }
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."
if [ -z "${SLX_KCL_SERVERS}" ]; then
@@ -23,20 +25,29 @@ fi
SLX_BASE_PATH=$(read_from_cmdline "slxbase")
SLX_BASE_MNT="/opt/openslx/mnt"
-SYS_TMP="/tmp"
+SYS_TMP="/tmp/addons"
+mkdir -p "$SYS_TMP" || { echo "Failed to create $SYS_TMP"; exit 1; }
for ADDON in ${SLX_ADDONS}; do
# download the addon from the given URL
- ADDON_TARGET_PATH="${SYS_TMP}/$(basename $(echo ${ADDON})).sqfs"
+ ADDON_TARGET_PATH="${SYS_TMP}/$(basename "$ADDON").sqfs"
download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"
# now mount it to $SLX_MNT/<addon-name>
- ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON})|awk -F "." '{print $1}')"
+ ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename "$ADDON")"
mkdir -p "$ADDON_MOUNT_POINT"
echo "Mounting ${ADDON_TARGET_PATH} to ${ADDON_MOUNT_POINT}"
- mount -t squashfs "$ADDON_TARGET_PATH" ${ADDON_MOUNT_POINT} || { echo "Failed to mount." && exit 1; }
+ mount -t squashfs "$ADDON_TARGET_PATH" "$ADDON_MOUNT_POINT" || { echo "Failed to mount." && exit 1; }
# now append it to /
echo "Appending ${ADDON_MOUNT_POINT} to /"
- mount -o remount,append:${ADDON_MOUNT_POINT}=ro / || { echo "Fail." && exit 1; }
+ mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / || { echo "Fail." && exit 1; }
+
+ # Run post-hook if available
+ if [ -x "$ADDON_MOUNT_POINT/addon-init" ]; then
+ echo "Running addon initialization script..."
+ "$ADDON_MOUNT_POINT/addon-init" || echo "Warning: Could not execute addon-init of $ADDON"
+ fi
done
+exit 0
+
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
index f9749740..02f238de 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
@@ -65,7 +65,8 @@ post_copy() {
[ ! -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,sys,var/run,var/lock,var/log,run/lock,run/shm,opt/openslx/mnt}
+ 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"
# make openslx log directory
mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx