diff options
| author | Jonathan Bauer | 2012-12-20 15:33:34 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2012-12-20 15:33:34 +0100 |
| commit | f6dad6269ab3228ead055291b846d2a9edb04564 (patch) | |
| tree | 30096a5fbd037fe4f9f0a0ef2b68d04317883c8e | |
| parent | static unit files for dbus, cleanup (diff) | |
| download | tm-scripts-f6dad6269ab3228ead055291b846d2a9edb04564.tar.gz tm-scripts-f6dad6269ab3228ead055291b846d2a9edb04564.tar.xz tm-scripts-f6dad6269ab3228ead055291b846d2a9edb04564.zip | |
mltk basic script :)
23 files changed, 364 insertions, 183 deletions
@@ -19,4 +19,62 @@ SELF=$(readlink -f $0) ROOT_DIR=$(dirname ${SELF}) +print_usage() { + echo "Toolkit for creating preboot mini-linux for OpenSLX NG (mltk)" + echo "Usage: $(basename ${SELF}) MODULE [OPTION]" + echo -e " MODULE:" + echo -e " \t core \t minimal initramfs (stage 3.1) to mount the system-container (stage 3.2)." + echo -e " \t sys \t minimal systemd-based rootfs including basic tools." + echo -e " OPTION:" + echo -e " \t build \t builds [MODULE]" + echo -e " \t clean \t clean build files for [MODULE]" + echo -e "" + echo -e " Module specific option:" + echo -e " \t sys \t build [TOOL]" + echo -e " \t \t TOOL can be: \t base, busybox, dbus, udev, systemd, plymouth" +} +if [ "x$1" = "x" ]; then + print_usage + exit 0 +elif [ "x$(whoami)" != "xroot" ]; then + echo "ERROR: You need to have root rights to install packages." + exit 1 +fi + +# read setup-tools and build_core +BUILD_CORE=${ROOT_DIR}/server/build_core +SETUP_TOOLS=${ROOT_DIR}/remote/setup_tools + +if [ "x$1" = "xcore" ]; then + [ -e ${BUILD_CORE} ] && . ${BUILD_CORE} + shift + if [ "x$1" = "xbuild" ]; then + generate_stage31 + elif [ "x$1" = "xclean" ]; then + clean_core + else + print_usage + exit 1 + fi +elif [ "x$1" = "xsys" ]; then + [ -e ${SETUP_TOOLS} ] && . ${SETUP_TOOLS} + shift + if [ "x$1" = "xbuild" ]; then + # shift away first 2 parameters + shift + echo "[sys] Building $@" + generate_stage32 $@ + elif [ "x$1" = "xclean" ]; then + shift + echo "[sys] Cleaning $@" + clean_sys $@ + else + print_usage + exit 1 + fi +else + echo "Module $1 not known." + print_usage + exit 1 +fi diff --git a/remote/setup-tools.sh b/remote/setup_tools index 639ec14f..cf96df7b 100755 --- a/remote/setup-tools.sh +++ b/remote/setup_tools @@ -1,24 +1,10 @@ #!/bin/bash -ROOT_DIR=$(dirname $(readlink -f $0)) -SELF=$(readlink -f $0) - -print_usage() { - echo "create tools for minilinux" - echo "Usage: $(basename ${SELF}) TOOL" -} - -if [ "x$1" = "x" ]; then - print_usage - exit 0 -elif [ "x$(whoami)" != "xroot" ]; then - echo "ERROR: You need to have root rights to install packages." - exit 1 -fi +MODULE_DIR=${ROOT_DIR}/remote #Create tools directory if not exists -TOOL_DIR=${ROOT_DIR}/tools -INIT_DIR=${ROOT_DIR}/stage3.2 +TOOL_DIR=${MODULE_DIR}/tools +INIT_DIR=${MODULE_DIR}/stage3.2 setup_git () { @@ -140,14 +126,18 @@ get_basic_libs () { echo "Basic libs copied." } -main () { +generate_stage32 () { - if [ "x$1" = "xall" ]; then - tools=$(ls $ROOT_DIR/tools) + # if no arguments assume all. + if [ "x$1" = "x" -o "x$1" = "xall" ]; then + tools=$(ls ${TOOL_DIR}) set -- $tools - fi + fi + # first copy libc and ld-linux get_basic_libs + + # now iterate over given tools and copy them cd ${TOOL_DIR} while (( "$#" )); do TOOL=$1 @@ -171,4 +161,28 @@ main () { } -main $@ +clean_sys() { + if [ "x$1" = "x" -o "x$1" = "xall" ]; then + #clean all + [ -d ${INIT_DIR} ] && rm -rf ${INIT_DIR} + for TOOL in $(ls ${TOOL_DIR}); do + clean_tool $TOOL + done + else + while (( "$#" )); do + clean_tool $1 + shift + done + fi +} +clean_tool() { + TOOLDIR=${TOOL_DIR}/$1 + echo "Cleaning ${TOOLDIR}" + [ -e ${TOOLDIR}/.built ] && rm ${TOOLDIR}/.built + [ -e ${TOOLDIR}/.fetched_source ] && rm ${TOOLDIR}/.fetched_source + [ -d ${TOOLDIR}/build ] && rm -rf ${TOOLDIR}/build + [ -d ${TOOLDIR}/src ] && rm -rf ${TOOLDIR}/src + [ -e ${TOOLDIR}/list_binaries_and_files ] && rm ${TOOLDIR}/list_binaries_and_files +} + +#generate_stage32 $@ diff --git a/remote/tools/base/base.build b/remote/tools/base/base.build index fb7b7294..a56982fa 100644 --- a/remote/tools/base/base.build +++ b/remote/tools/base/base.build @@ -52,8 +52,8 @@ post_copy() { echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/openslx/sbin:/openslx/bin\"" \ > ${INIT_DIR}/etc/environment - # copy static bash profile - cp ${TOOL_DIR}/${TOOL}/data/profile ${INIT_DIR}/etc + # copy static files + cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} # copy pam modules, TODO: better way to find arch-dependant interfix... tar -cpv $(dirname $(locate pam_unix.so|grep ^/lib/)) | tar -xpv -C ${INIT_DIR} &>/dev/null diff --git a/remote/tools/base/data/README b/remote/tools/base/data/README deleted file mode 100644 index 48aab378..00000000 --- a/remote/tools/base/data/README +++ /dev/null @@ -1,3 +0,0 @@ -Static files to customized the basic system - -Here comes things like bash config, pam config, etc diff --git a/remote/tools/base/data/profile b/remote/tools/base/data/etc/profile index 12e75661..3784e784 100644 --- a/remote/tools/base/data/profile +++ b/remote/tools/base/data/etc/profile @@ -15,8 +15,8 @@ if [ "$PS1" ]; then if [ "$BASH" ]; then export PS1="[\u@\h \W]\\$ " - alias ll='ls -laFh' - alias ls='ls -F' + alias ll='ls --color=auto -laFh' + alias ls='ls --color=auto -F' export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:'; else if [ "`id -u`" -eq 0 ]; then diff --git a/remote/tools/base/data/etc/systemd/system/network-fast.service b/remote/tools/base/data/etc/systemd/system/network-fast.service new file mode 100644 index 00000000..6656b189 --- /dev/null +++ b/remote/tools/base/data/etc/systemd/system/network-fast.service @@ -0,0 +1,8 @@ +[Unit] +Description=Setup Network Connection +After=udev.service + +[Service] +ExecPre=/openslx/bin/ip link set dev eth0 up +ExecStart=/openslx/sbin/udhcpc -O domain -O nissrv -O nisdomain -t 8 -s /etc/udhcpc.default.script -i eth0 + diff --git a/remote/tools/base/data/etc/udhcpc.default.script b/remote/tools/base/data/etc/udhcpc.default.script new file mode 100755 index 00000000..09442a5e --- /dev/null +++ b/remote/tools/base/data/etc/udhcpc.default.script @@ -0,0 +1,64 @@ +#!/bin/sh +# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. +# +# Based on the busybox example scripts and the old udhcp source +# package default.* scripts. + +RESOLV_CONF="/etc/resolv.conf" + +case $1 in + bound|renew) + [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" + [ -n "$subnet" ] && NETMASK="netmask $subnet" + + ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $interface + ip route add default via $router + + # read filename from fbgui.conf where ip config should be saved. + ipconf=$(cat /etc/fbgui.conf | grep ip_config | cut -d '=' -f2) + + echo "ip=$ip" > $ipconf + echo "subnet=$subnet" >> $ipconf + echo "broadcast=$broadcast" >> $ipconf + echo "gateway=$router" >> $ipconf + echo "$ip:132.230.4.3:$router:$subnet" > /tmp/ip_config_fbgui + + # Update resolver configuration file + R="" + [ -n "$domain" ] && R="domain $domain +" + count=1; + for i in $dns; do + echo "$0: Adding DNS $i" + R="${R}nameserver $i +" + count=$((count+1)); + done + + if [ -x /sbin/resolvconf ]; then + echo -n "$R" | resolvconf -a "${interface}.udhcpc" + else + echo -n "$R" > "$RESOLV_CONF" + fi + trigger=$(cat /etc/fbgui.conf | grep file_trigger | cut -d '=' -f2) + + echo "gogo" >> $trigger + ;; + + deconfig) + + ;; + + leasefail) + echo "$0: Lease failed: $message" + ;; + + nak) + echo "$0: Received a NAK: $message" + ;; + + *) + echo "$0: Unknown udhcpc command: $1"; + exit 1; + ;; +esac diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service new file mode 100644 index 00000000..d01ba9b8 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-halt.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Halt Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=halt.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service new file mode 100644 index 00000000..1fe6e47f --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-kexec.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Reboot with kexec Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=kexec.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service new file mode 100644 index 00000000..49742f6e --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-poweroff.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Power Off Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=poweroff.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service new file mode 100644 index 00000000..56af45a7 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit-wait.service @@ -0,0 +1,8 @@ +[Unit] +Description=Wait for Plymouth Boot Screen to Quit +After=rc-local.service plymouth-start.service systemd-user-sessions.service + +[Service] +ExecStart=-/bin/plymouth --wait +Type=oneshot +TimeoutSec=20 diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service new file mode 100644 index 00000000..be3c1888 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-quit.service @@ -0,0 +1,8 @@ +[Unit] +Description=Terminate Plymouth Boot Screen +After=rc-local.service plymouth-start.service systemd-user-sessions.service + +[Service] +ExecStart=-/bin/plymouth quit +Type=oneshot +TimeoutSec=20 diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service new file mode 100644 index 00000000..caa3973b --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-read-write.service @@ -0,0 +1,9 @@ +[Unit] +Description=Tell Plymouth To Write Out Runtime Data +DefaultDependencies=no +After=local-fs.target +Before=sysinit.target + +[Service] +ExecStart=-/bin/plymouth update-root-fs --read-write +Type=oneshot diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service new file mode 100644 index 00000000..dbedd00d --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-reboot.service @@ -0,0 +1,11 @@ +[Unit] +Description=Show Plymouth Reboot Screen +After=getty@tty1.service prefdm.service plymouth-start.service +Before=reboot.service +DefaultDependencies=no +ConditionKernelCommandLine=!plymouth.enable=0 + +[Service] +ExecStart=/sbin/plymouthd --mode=shutdown --attach-to-session +ExecStartPost=-/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service b/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service new file mode 100644 index 00000000..09243001 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/plymouth-start.service @@ -0,0 +1,13 @@ +[Unit] +Description=Show Plymouth Boot Screen +DefaultDependencies=no +Wants=systemd-ask-password-plymouth.path +After=systemd-vconsole-setup.service systemd-udev-settle.service +Before=systemd-ask-password-plymouth.service +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=!/run/plymouth/pid + +[Service] +ExecStart=/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session +ExecStartPost=-/bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/drm/card0/dev;-/bin/udevadm settle --timeout=30 --exit-if-exists=/sys/class/graphics/fb0/dev; -/bin/plymouth show-splash +Type=forking diff --git a/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path new file mode 100644 index 00000000..c2ee4206 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.path @@ -0,0 +1,13 @@ +[Unit] +Description=Forward Password Requests to Plymouth Directory Watch +Documentation=http://www.freedesktop.org/wiki/Software/systemd/PasswordAgents +DefaultDependencies=no +Conflicts=shutdown.target +After=plymouth-start.service +Before=basic.target shutdown.target +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=/run/plymouth/pid + +[Path] +DirectoryNotEmpty=/run/systemd/ask-password +MakeDirectory=yes diff --git a/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service new file mode 100644 index 00000000..aa9ffc21 --- /dev/null +++ b/remote/tools/plymouth/data/etc/systemd/system/systemd-ask-password-plymouth.service @@ -0,0 +1,12 @@ +[Unit] +Description=Forward Password Requests to Plymouth +Documentation=http://www.freedesktop.org/wiki/Software/systemd/PasswordAgents +DefaultDependencies=no +Conflicts=shutdown.target +After=plymouth-start.service +Before=shutdown.target +ConditionKernelCommandLine=!plymouth.enable=0 +ConditionPathExists=/run/plymouth/pid + +[Service] +ExecStart=/bin/systemd-tty-ask-password-agent --watch --plymouth diff --git a/remote/tools/plymouth/plymouth.build b/remote/tools/plymouth/plymouth.build index 08647498..424bc292 100644 --- a/remote/tools/plymouth/plymouth.build +++ b/remote/tools/plymouth/plymouth.build @@ -32,26 +32,11 @@ build() { touch .built fi - # fix path: everything in lib/systemd to usr/lib/systemd - cd $BUILDDIR - - TARLIST="list_files_to_fix_prefix" - [ -f $TARLIST ] && rm $TARLIST - - # find files and symlinks with wrong prefix - for FILE in $(find . -type f -o -type l|grep ^./lib/systemd) - do - echo $FILE >> $TARLIST - done - # copy found files to usr/* - [ ! -d $BUILDDIR/usr ] && mkdir -p $BUILDDIR/usr - tar -cpv $(cat $TARLIST|sort -u) | tar -xpv -C $BUILDDIR/usr - # delete original location - rm -rf ./lib/systemd - cd - - } post_copy() { - : + # copy static dbus systemd unit files to stage3.2 + SYSTEMDDIR=${INIT_DIR}/etc/systemd/system + [ ! -d ${SYSTEMDDIR} ] && mkdir -p ${SYSTEMDDIR} + cp -r ${TOOL_DIR}/${TOOL}/data/* ${INIT_DIR} } diff --git a/remote/tools/plymouth/plymouth.conf b/remote/tools/plymouth/plymouth.conf index 4ade02d6..6c907826 100644 --- a/remote/tools/plymouth/plymouth.conf +++ b/remote/tools/plymouth/plymouth.conf @@ -7,8 +7,7 @@ DEPS=" libpng-dev libdrm-dev" REQUIRED_BINARIES=" plymouth plymouthd" -REQUIRED_DIRECTORIES=" /usr/lib/systemd/system - /usr/local/bin +REQUIRED_DIRECTORIES=" /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib/plymouth diff --git a/remote/tools/systemd/systemd.build b/remote/tools/systemd/systemd.build index ccdffcc0..981e87b6 100644 --- a/remote/tools/systemd/systemd.build +++ b/remote/tools/systemd/systemd.build @@ -42,7 +42,7 @@ post_copy() { # dont clear systemd log at startup # sed -i.bak "s/ExecStart=-\/sbin\/agetty %I 38400/ExecStart=-\/sbin\/agetty %I 38400 --noclear/g" \ - $INIT_DIR/usr/lib/systemd/system/getty@.service +# $INIT_DIR/usr/lib/systemd/system/getty@.service sed -i.bak "s/TTYVTDisallocate=yes/TTYVTDisallocate=no/g" \ $INIT_DIR/usr/lib/systemd/system/getty@.service } diff --git a/remote/tools/udev/udev.build b/remote/tools/udev/udev.build index f16d747e..70ed0b5a 100644 --- a/remote/tools/udev/udev.build +++ b/remote/tools/udev/udev.build @@ -27,9 +27,9 @@ build() { } post_copy() { - #copy systemd specific files - SYSTEMDDIR=$INIT_DIR/etc/systemd/system - [ ! -d $SYSTEMDDIR ] && mkdir -p $SYSTEMDDIR + #copy systemd specific files + SYSTEMDDIR=$INIT_DIR/etc/systemd/system + [ ! -d $SYSTEMDDIR ] && mkdir -p $SYSTEMDDIR cp -r $TOOL_DIR/$TOOL/data/* $INIT_DIR } diff --git a/server/build_core b/server/build_core index d0441c69..4e615520 100755 --- a/server/build_core +++ b/server/build_core @@ -18,71 +18,84 @@ # in the future the prefix should be set via slxsettings ... -ROOT_DIR=$(dirname $(readlink -f $0)) -SELF=$(readlink -f $0) +MODULE_DIR=${ROOT_DIR}/server -STAGE31_STATIC_DIR=${ROOT_DIR}/../data/stage3.1 -STAGE31_DIR=${ROOT_DIR}/stage3.1 -STAGE32_DIR=${ROOT_DIR}/../remote/stage3.2 +STAGE31_STATIC_DIR=${ROOT_DIR}/data/stage3.1 +STAGE31_DIR=${MODULE_DIR}/stage3.1 +STAGE32_DIR=${ROOT_DIR}/remote/stage3.2 # initial checks -if [ "x$(whoami)" != "xroot" ]; then - echo "ERROR: You need to have root rights to install packages." - exit 1 -fi - -if [ ! -d ${STAGE32_DIR} ]; -then - echo "No stage3.2 directory found. Please run setup-tools.sh first." - exit 1 -fi - -if [ ! -e ${STAGE32_DIR}/openslx/bin/busybox ]; -then - echo "Busybox not found, run 'setup-tools.sh busybox' first." - exit 1 -fi - -# shouldn't squashfs-tools be automatically installed as we need them nevertheless!? -# what if it is already on the machine? faster to check with which than the apt-get check? -if [ -z $(which mksquashfs) ]; -then - echo "mksquashfs not found, please install squashfs-tools first." - exit 1 -fi - -# produce stage3.1 -[ ! -d ${STAGE31_DIR} ] && mkdir -p ${STAGE31_DIR} - -# create basic directory structure -mkdir -p ${STAGE31_DIR}/{bin,dev,proc,run,lib,etc,mnt,sys} - -# copy device files from running system -cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - ${STAGE31_DIR}/dev - -# copy busybox, its libs and static data to stage3.1 -cp -r ${STAGE32_DIR}/openslx/* ${STAGE31_STATIC_DIR}/* ${STAGE31_DIR} - -# fetch the libraries needed for busybox -BASICLIBS="" -for i in $(ldd ${STAGE31_DIR}/bin/busybox); -do - if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 \ - -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; - then - echo $i - BASICLIBS="$BASICLIBS $i $(readlink -f "$i")" - fi -done -tar cpv $BASICLIBS | tar xpv -C ${STAGE31_DIR} &>/dev/null - -# finalize the initramfs target -[ ! -d ${STAGE32_DIR} ] && echo "No stage3.2 directory found. Please run setup_tools first." && exit 1 -[ -e ${STAGE31_DIR}/mnt/openslx.sqfs ] && rm ${STAGE31_DIR}/mnt/openslx.sqfs - -mksquashfs ${STAGE32_DIR} ${STAGE31_DIR}/mnt/openslx.sqfs -comp xz -b 1M -no-recovery 2>/dev/null - -cd ${STAGE31_DIR} -find . | cpio --format="newc" --create | gzip -9 > ${ROOT_DIR}/initramfs -cd - &>/dev/null +initial_checks() { + if [ ! -d ${STAGE32_DIR} ]; + then + echo "No stage3.2 directory found. Please run setup_tools first." + exit 1 + fi + + if [ ! -e ${STAGE32_DIR}/openslx/bin/busybox ]; + then + echo "Busybox not found, run 'setup_tools busybox' first." + exit 1 + fi + # shouldn't squashfs-tools be automatically installed as we need them nevertheless!? + # what if it is already on the machine? faster to check with which than the apt-get check? + if [ -z $(which mksquashfs) ]; + then + echo "mksquashfs not found, please install squashfs-tools first." + exit 1 + fi +} + +generate_initramfs() { + + # produce stage3.1 + [ ! -d ${STAGE31_DIR} ] && mkdir -p ${STAGE31_DIR} + + # create basic directory structure + mkdir -p ${STAGE31_DIR}/{bin,dev,proc,run,lib,etc,mnt,sys} + + # copy device files from running system + cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ + ${STAGE31_DIR}/dev + + # copy busybox, its libs and static data to stage3.1 + cp -r ${STAGE32_DIR}/openslx/* ${STAGE31_STATIC_DIR}/* ${STAGE31_DIR} + + # fetch the libraries needed for busybox + BASICLIBS="" + for i in $(ldd ${STAGE31_DIR}/bin/busybox); + do + if [ $(echo $i | grep '^/' | grep -c ld) -eq 1 \ + -o $(echo $i | grep '^/' | grep -c libc.so) -eq 1 ]; + then + echo $i + BASICLIBS="$BASICLIBS $i $(readlink -f "$i")" + fi + done + tar cpv $BASICLIBS | tar xpv -C ${STAGE31_DIR} &>/dev/null + +} + +generate_squashfs() { + + # finalize the initramfs target + [ ! -d ${STAGE32_DIR} ] && echo "No stage3.2 directory found. Please run setup_tools first." && exit 1 + [ -e ${STAGE31_DIR}/mnt/openslx.sqfs ] && rm ${STAGE31_DIR}/mnt/openslx.sqfs + + mksquashfs ${STAGE32_DIR} ${STAGE31_DIR}/mnt/openslx.sqfs -comp xz -b 1M -no-recovery 2>/dev/null + + cd ${STAGE31_DIR} + find . | cpio --format="newc" --create | gzip -9 > ${MODULE_DIR}/initramfs + cd - &>/dev/null +} + +generate_stage31() { + initial_checks + generate_initramfs + generate_squashfs +} + +clean_core() { + [ -d ${STAGE31_DIR} ] && rm -rf ${STAGE31_DIR} + [ -e ${MODULE_DIR}/initramfs ] && rm ${MODULE_DIR}/initramfs +} diff --git a/server/build_core.old b/server/build_core.old deleted file mode 100644 index e761eb2e..00000000 --- a/server/build_core.old +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# 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 -# -# Server side script to generate stage3.1,2 initial ramfses for OpenSLX Linux -# stateless clients -############################################################################# - -# first parameter is a hash pointing to the target directory -# /srv/openslx/build - -# in the future the prefix should be set via slxsettings ... -SLXPREFIX=/srv/openslx -IRTARGET=${SLXPREFIX}/build/$1 - -# add openslx distro (in)dependent data to the initramfs target -DISTRONAME=ubuntu -DISTROVER=12.04 - -for content in ${SLXPREFIX}/core/base - ${SLXPREFIX}/core/${DISTRONAME}/base - ${SLXPREFIX}/core/${DISTRONAME}/${DISTROVER} ; do - cp -a $content ${IRTARGET} -done - -# add kernel stuff to the initramfs target -KERNELVER= -mkdir -p ${IRTARGET}/lib/modules -cp -a ${SLXPREFIX}/kernel/${KERNELVER}/modules \ - ${IRTARGET}/lib/modules/${KERNELVER} - -# produce stage3.1 -mkdir -p ${IRTARGET}/stage3.1 - -# create the base directory structure for stage3.1 -mkdir -p ${IRTARGET}/stage3.1/{bin,dev,proc,run,lib,etc,mnt,sys} -cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - ${IRTARGET}/stage3.1/dev -cp ${IRTARGET}/openslx/bin/busybox ${IRTARGET}/stage3.1/bin - -# link the required busybox applets for stage3.1 -for app in insmod modprobe mount mkdir umount sh switch_root ; do - ln -s /bin/busybox ${IRTARGET}/stage3.1/bin/${app} -done - -# add the static stuff for stage3.1 -cp -a ${SLXPREFIX}/core/stage3.1 ${IRTARGET}/stage3.1 - -# finalize the initramfs target -which mksquashfs 2>&1>/dev/null || { echo "Please install SquashFS utilities" ; exit 1 } - -mksquashfs -ef ${IRTARGET}/stage3.1 ${IRTARGET} \ - ${IRTARGET}/stage3.1/mnt/openslx.sqfs -comp xz -b 1M -no-progress -no-recovery 2>/dev/null - -(cd ${IRTARGET}/stage3.1; find . | cpio --format="newc" --create | gzip -9 > ${IRTARGET}/initramfs) - - |
