summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
Diffstat (limited to 'remote')
-rw-r--r--remote/core/core.conf65
-rwxr-xr-xremote/core/data/init153
-rwxr-xr-xremote/setup_core170
3 files changed, 388 insertions, 0 deletions
diff --git a/remote/core/core.conf b/remote/core/core.conf
new file mode 100644
index 00000000..40f6aedb
--- /dev/null
+++ b/remote/core/core.conf
@@ -0,0 +1,65 @@
+REQUIRED_MODULES=" kernel/drivers/video/sis/sisfb.ko
+ kernel/drivers/video/via/viafb.ko
+ kernel/drivers/acpi/video.ko
+ kernel/drivers/ssb/ssb.ko
+ kernel/drivers/gpu/drm/ttm/ttm.ko
+ kernel/drivers/gpu/drm/via/via.ko
+ kernel/drivers/gpu/drm/drm.ko
+ kernel/drivers/gpu/drm/tdfx/tdfx.ko
+ kernel/drivers/gpu/drm/nouveau/nouveau.ko
+ kernel/drivers/gpu/drm/savage/savage.ko
+ kernel/drivers/gpu/drm/radeon/radeon.ko
+ kernel/drivers/gpu/drm/drm_kms_helper.ko
+ kernel/drivers/gpu/drm/i810/i810.ko
+ kernel/drivers/gpu/drm/i2c/ch7006.ko
+ kernel/drivers/gpu/drm/i2c/sil164.ko
+ kernel/drivers/gpu/drm/sis/sis.ko
+ kernel/drivers/gpu/drm/mga/mga.ko
+ kernel/drivers/gpu/drm/i915/i915.ko
+ kernel/drivers/gpu/drm/r128/r128.ko
+ kernel/drivers/i2c/algos/i2c-algo-bit.ko
+ kernel/drivers/net/netconsole.ko
+ kernel/drivers/net/ethernet/realtek/8139too.ko
+ kernel/drivers/net/ethernet/realtek/r8169.ko
+ kernel/drivers/net/ethernet/nvidia/forcedeth.ko
+ kernel/drivers/net/ethernet/via/via-rhine.ko
+ kernel/drivers/net/ethernet/amd/pcnet32.ko
+ kernel/drivers/net/ethernet/atheros/atl1e/atl1e.ko
+ kernel/drivers/net/ethernet/atheros/atl1c/atl1c.ko
+ kernel/drivers/net/ethernet/sis/sis900.ko
+ kernel/drivers/net/ethernet/broadcom/tg3.ko
+ kernel/drivers/net/ethernet/broadcom/b44.ko
+ kernel/drivers/net/ethernet/intel/e1000/e1000.ko
+ kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
+ kernel/drivers/net/ethernet/intel/e100.ko
+ kernel/drivers/net/ethernet/marvell/skge.ko
+ kernel/drivers/net/ethernet/3com/3c59x.ko
+ kernel/drivers/net/ethernet/dec/tulip/tulip.ko
+ kernel/drivers/hid/hid.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/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"
+REQUIRED_FIRMWARE=" 3com/
+ e100/
+ matrox/
+ r128/
+ radeon/
+ RTL8192E/
+ RTL8192SE/
+ rtl_nic/
+ tigon/"
+REQUIRED_FILES=" /etc/netconfig
+ /etc/networks
+ /etc/protocols
+ /etc/services"
diff --git a/remote/core/data/init b/remote/core/data/init
new file mode 100755
index 00000000..510a17e3
--- /dev/null
+++ b/remote/core/data/init
@@ -0,0 +1,153 @@
+#!/bin/sh
+# 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
+#############################################################################
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/openslx/bin:/openslx/sbin
+export LD_LIBRARY_PATH=/usr/lib64
+
+mount -n -t tmpfs -o 'mode=755' run "/run"
+
+# mount the important standard directories
+[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
+[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
+
+echo "/sbin/mdev" > /proc/sys/kernel/hotplug
+# read graphic and network adaptor configuration (without proprietary drivers yet)
+
+( hwinfo --gfxcard > /etc/hwinfo ) &
+( hwinfo --netcard > /etc/netcard ) &
+
+# read kernel command line for debugging switch
+read KCL < /proc/cmdline
+export KCL
+for opts in ${KCL}; do
+ case ${opts} in
+ debug=*)
+ DEBUG=1;;
+ ip=*)
+ # process IP info
+ ipinfo=${opts#ip=};;
+ nfs=*)
+ nfs=${opts#nfs=}
+ nfspath=${nfs#*:}
+ nfsserver=${nfs%:/*}
+ ;;
+ esac
+done
+
+while ps | grep -v grep | grep -q " hwinfo --gfxcard" ; do usleep 10 ; done
+
+case $(cat /etc/hwinfo) in
+ *i915*)
+ modprobe -a i915 2>/dev/null
+ ;;
+ *intel*|*Intel*)
+ modprobe -a i810 i830 i915 2>/dev/null
+ ;;
+ *nvidia*|*NVidia*|*nouveau*)
+ modprobe -q nouveau 2>/dev/null
+ ;;
+ *radeon*|*Radeon*)
+ modprobe -q radeon 2>/dev/null
+ ;;
+ *mga*|*matrox*|*Matrox*)
+ modprobe -q mga 2>/dev/null
+ ;;
+ *VMWARE*)
+ ;;
+ *)
+ modprobe -qa r128 savage sis tdfx ttm via viafb
+ ;;
+esac
+( modprobe -a drm fbcon; mdev -s ) &
+
+# load required network and usb controller drivers, filter out wireless adaptors
+while ps | grep -v grep | grep -q " hwinfo --netcard" ; do usleep 10 ; done
+nwcardlist="forcedeth|e1000e|e1000|e100|tg3|via-rhine|r8169|pcnet32"
+echo "modprobe -qa usbhid hid-bright" >/etc/modprobe.base
+grep modprobe /etc/netcard | grep -E "$nwcardlist" \
+ | sed 's/.* Cmd: "//;s/"//;s/modprobe/modprobe -qb/' \
+ | sort -u >>/etc/modprobe.base
+# virtio hack
+if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then
+ echo "modprobe -q virtio_net" >>/etc/modprobe.base
+fi
+/bin/sh /etc/modprobe.base; mdev -s
+
+# setup network
+nwif="eth0"
+# set up loopback networking
+[ $DEBUGLEVEL -eq 20 ] && echo "** starting ip config at $(sysup)"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+ip link set dev $nwif up 2>/dev/null || { echo "No link for $nwif, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; }
+
+# analyze ip information from the kernel command line and put parts
+# of it into several variables
+if [ -n "$ipinfo" ] ; then
+ getip () {
+ local val="$ipinfo:"; i=$(($1 - 1));
+ while [ $i -gt 0 ] ; do
+ val=${val#*:} ; i=$(($i - 1));
+ done;
+ echo $val|sed "s/:.*//"; }
+ 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_srv=$(getip 5)
+ [ -n "$dns_srv" ] && echo nameserver $dns_srv >/etc/resolv.conf;
+ echo -e "# ip configuration written by $0 script:\nclientip=$clientip\n\
+subnet_mask=$subnet_mask\ngateway=$gateway\nserverip=$serverip\n\
+broadcast_address=$broadcast_address" >>/etc/initramfs-setup
+ # set static ip address
+ ip addr add $clientip/$(ipcalc -s -p $clientip $subnet_mask|sed s/.*=//) \
+ broadcast $broadcast_address dev $nwif 2>/dev/null
+ ip route add default via $gateway 2>/dev/null
+else
+ noipyet="yes"
+fi
+
+
+# load local file systems
+modprobe aufs
+modprobe squashfs
+
+mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
+mount -n -t tmpfs none /dev/shm/uniontmp
+
+if [ -n "$nfs" ] ; then
+ mount -t nfs -o ro,async,nolock ${nfsserver}:${nfspath} /rorootfs || { echo "Problem mounting NFS-Directory from ${nfsserver}:${nfspath}. Dropping to DEBUG shell."; DEBUG=1; }
+else
+ mount -n /mnt/openslx.sqfs /rorootfs || { echo "Problem mounting Squashfs. Dropping to DEBUG shell."; DEBUG=1; }
+fi
+
+mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt
+mkdir -p /mnt/uniontmp /mnt/tmp
+mount -n --move /dev/shm/uniontmp /mnt/uniontmp
+
+if [ $DEBUG -ge 1 ]; then
+ echo "Starting debug shell, CTRL + D will start Stage 3.2."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+fi
+
+for mnt in proc sys run ; do
+ umount -n $mnt
+done
+
+unset BOOT_IMAGE initrd
+# new style of pivoting (switch_root or run-init)
+exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd
diff --git a/remote/setup_core b/remote/setup_core
new file mode 100755
index 00000000..6888bc07
--- /dev/null
+++ b/remote/setup_core
@@ -0,0 +1,170 @@
+#!/bin/bash
+
+ROOT_DIR="/home/joe/work/tm-scripts"
+
+MODULE_DIR="${ROOT_DIR}/remote"
+STAGE31_DIR="${MODULE_DIR}/stage3.1"
+
+MODULE_LIST="${MODULE_DIR}/core/stage31.modules"
+FIRMWARE_LIST="${MODULE_DIR}/core/stage31.firmware"
+
+
+. "${ROOT_DIR}/helper/logging.inc"
+. "${ROOT_DIR}/helper/string.inc"
+. "${ROOT_DIR}/helper/fileutil.inc"
+. "${ROOT_DIR}/helper/system.inc"
+. "${ROOT_DIR}/helper/binutil.inc"
+
+initial_checks() {
+
+ [ ! -z "${KERNEL_VERSION}" ] || perror "No kernel version, cannot proceed."
+ [ ! -z "${ARCH_TRIPLET}" ] || perror "No arch triplet, cannot proceed."
+
+ [ -f "${MODULE_LIST}" ] || perror "No list for stage3.1 kernel modules found."
+ [ -f "${FIRMWARE_LIST}" ] || perror "No list for stage3.1 firmware found."
+
+
+ [ -d "${STAGE31_DIR}" ] || mkdir -p "${STAGE31_DIR}"
+ [ ! -z "$(which depmod)" ] || perror "No 'depmod' found on this systemd."
+
+ [ -d ""${MODULE_DIR}"/tools/busybox/build" ] || perror "No busybox found. Build it first."
+}
+
+read_config() {
+ local CORE_CONFIG="${MODULE_DIR}/core/core.conf"
+ [ ! -e "${CORE_CONFIG}" ] && perror "${MODULE_DIR}/core/core.conf not found."
+ . "${CORE_CONFIG}" || perror "Sourcing "${MODULE_DIR}"/core/core.conf failed."
+}
+
+copy_kernel_modules() {
+
+ local MODLIST="stage31_modules_list"
+ [ -e $MODLIST ] && rm -f $MODLIST
+
+ # process modules list
+ for MOD in ${REQUIRED_MODULES}; do
+ local MOD_PATH="/lib/modules/${KERNEL_VERSION}/${MOD}"
+ if [ ! -e "${MOD_PATH}" ]; then
+ pwarning "Module $MOD not found. Skipping. (might cause problem on certain clients!)"
+ continue
+ else
+ pdebug "Copying "${MOD_PATH}""
+ echo "${MOD_PATH}" >> "${MODLIST}"
+ fi
+ done
+
+ if [ -s "$MODLIST" ]; then
+ local MODLISTCOUNT=$(cat "$MODLIST" | wc -l)
+ pinfo "Copying $MODLISTCOUNT modules to stage 3.1 target directory."
+ tarcopy "$(cat "$MODLIST")" "${STAGE31_DIR}"
+ fi
+
+}
+
+generate_modules_map_files() {
+
+ # first strip modules.order of all the modules we don't use
+ cat /lib/modules/"${KERNEL_VERSION}"/modules.order | grep -E $(tr '\n' '|' < $MODULE_LIST) \
+ >> "${STAGE31_DIR}"/lib/modules/"${KERNEL_VERSION}"/modules.order
+
+ # copy list of builtin kernel modules
+ cp /lib/modules/"${KERNEL_VERSION}"/modules.builtin "${STAGE31_DIR}"/lib/modules/"${KERNEL_VERSION}"
+ # with modules.order and modules.builtin, we can run depmod for the rest of the files
+ depmod -b "${STAGE31_DIR}"
+}
+
+
+copy_firmware() {
+
+ local FWLIST="stage31_firmware_list"
+ [ -e $FWLIST ] && rm -f $FWLIST
+
+ local FW_PATH="/lib/firmware"
+
+ # process firmware list
+ pinfo "Copying firmware from system..."
+ for FW in ${REQUIRED_FIRMWARE}; do
+ local FOUND=0
+ if [ -e "${FW_PATH}"/"${FW}" ]; then
+ pdebug "Copying "${FW_PATH}"/"${FW}""
+ echo "${FW_PATH}"/"${FW}" >> "$FWLIST"
+ FOUND=1
+ fi
+ if [ -e "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" ]; then
+ pdebug "Copying "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}""
+ echo "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" >> "$FWLIST"
+ FOUND=1
+ fi
+ [ $FOUND -ne 1 ] && pwarning "Neither "${FW_PATH}"/"${FW}" nor "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" found on the system."
+ done
+
+ if [ -s "${FWLIST}" ]; then
+ local FWLISTCOUNT=$(cat "$FWLIST"|wc -l)
+ pinfo "Copying $FWLISTCOUNT firmware to stage 3.1 target directory."
+ tarcopy "$(cat "$FWLIST")" "${STAGE31_DIR}"
+ fi
+}
+
+generate_rootfs() {
+ # create basic directory structure
+ mkdir -p "${STAGE31_DIR}"/{bin,dev,proc,run,etc,mnt,sys} || perror "Cannot create basic directory structure in '${STAGE31_DIR}'"
+
+ # copy device files from running system
+ cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \
+ "${STAGE31_DIR}"/dev || perror "Cannot copy devices from running system"
+
+ # copy libc and ld-linux
+ tarcopy "$(list_basic_libs)" "${STAGE31_DIR}"
+
+ # copy required files
+ tarcopy "${REQUIRED_FILES}" "${STAGE31_DIR}"
+
+ # copy static data
+ cp -r "${MODULE_DIR}"/core/data/* "${STAGE31_DIR}"
+}
+
+get_basic_tools() {
+ # get busybox from tools/ we checked earlier if its there.
+ cp -r "${MODULE_DIR}"/tools/busybox/build/openslx/* "${STAGE31_DIR}"
+
+ # get hwinfo and the required libx86emu
+ [ ! -d "${MODULE_DIR}"/core/src ] && mkdir -p "${MODULE_DIR}"/core/src
+ cd "${MODULE_DIR}"/core/src
+
+ # start with libx86emu
+ git clone git://gitorious.org/x86emu/libx86emu.git
+ cd libx86emu
+ make || perror "[libx86emu] make failed."
+ #make install || perror "[libx86emu] make install to system failed."
+ DESTDIR="${MODULE_DIR}"/core/build make install || perror "[libx86emu] make install to "${STAGE31_DIR}" failed."
+ cd - &> /dev/null
+
+ # now hwinfo
+ git clone git://gitorious.org/opensuse/hwinfo.git
+ cd hwinfo
+ make || perror "[hwinfo] make failed."
+ DESTDIR="${MODULE_DIR}"/core/build make install || perror "[hwinfo] make install failed."
+ cd - &> /dev/null
+
+ # get dependencies of hwinfo
+ cd "${MODULE_DIR}"/core/build
+ HWINFO=$(find . -type f -name hwinfo -executable)
+ get_link_chain "${MODULE_DIR}"/core/build/"${HWINFO}" "${MODULE_DIR}"/core/build >> list_wanted_stage3.1
+ get_dynamic_dependencies -l "${MODULE_DIR}"/core/build "${MODULE_DIR}"/core/build/"${HWINFO}" >> list_wanted_stage3.1
+ tarcopy "$(cat list_wanted_stage3.1)" "${STAGE31_DIR}"
+ cd - &> /dev/null
+}
+
+generate_stage31() {
+
+ pinfo "Generating stage 3.1 file system..."
+ cd "${MODULE_DIR}"/core
+ initial_checks
+ read_config
+ copy_kernel_modules
+ generate_modules_map_files
+ copy_firmware
+ generate_rootfs
+ get_basic_tools
+ cd - &> /dev/null
+}