diff options
| author | Simon Rettberg | 2014-01-28 19:04:32 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2014-01-28 19:04:32 +0100 |
| commit | f606854113a9736e87420cf49bbb53ad8ee6bbd4 (patch) | |
| tree | 1dd1622a4cf99db8770aeac11e3b6808c223e528 | |
| parent | [systemd] removed systemd-tmpfiles-cleaner stuff which was messing with (diff) | |
| download | tm-scripts-f606854113a9736e87420cf49bbb53ad8ee6bbd4.tar.gz tm-scripts-f606854113a9736e87420cf49bbb53ad8ee6bbd4.tar.xz tm-scripts-f606854113a9736e87420cf49bbb53ad8ee6bbd4.zip | |
[rfs-stage31] udhcpc in stage 3.1 to get DNS servers etc. early
TODO: Patch udhcpc to support searchdomain option (119)
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig (renamed from remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig) | 19 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/inc/setup_network (renamed from remote/rootfs/rootfs-stage31/data/bin/setup_network) | 20 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/inc/setup_stage32 (renamed from remote/rootfs/rootfs-stage31/data/bin/setup_stage32) | 0 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger | 59 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 45 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/rootfs-stage31.build | 41 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/rootfs-stage31.conf | 44 |
7 files changed, 156 insertions, 72 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig index 580b23ed..53487332 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig @@ -37,7 +37,7 @@ fetch_config_files() { ######################################################################### # # This function updates the downloaded config with the IP information -# received from /bin/setup_network +# received from /inc/setup_network update_sysconfig() { # sanity checks [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } @@ -55,18 +55,20 @@ HEREEND # 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 + 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" + local TEMP_EXTRACT_DIR="/tmp/config.tgz.tmp" 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}" tar -cp * | tar -xp -C "${FUTURE_ROOT}" + cd / + rm -rf -- "${TEMP_EXTRACT_DIR}" "${CONFIG}.tgz" } @@ -76,5 +78,6 @@ HEREEND # fetch_sysconfig -fetch_config_files +fetch_config_files update_sysconfig + diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/inc/setup_network index 79ae0886..3de48057 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_network +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network @@ -41,11 +41,7 @@ for LINE in $IP_OUT; do # 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/:.*//"; + echo "${IPINFO}" | awk -F ':' "{print \$$1}" } CLIENTIP="$(getip 1)" SERVERIP="$(getip 2)" @@ -56,9 +52,9 @@ for LINE in $IP_OUT; do # we might have an idea of the dns server via preboot DNS_SERVER="$(getip 5)" # set static ip address - ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" + [ -n "$CLIENTIP" ] && ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" ip link set dev "$BRIDGE" up - ip route add default via "$GATEWAY" dev "$BRIDGE" + [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE" else NOIPYET="yes" fi @@ -83,3 +79,13 @@ while true; do done echo "." +# udhcpc +PARAM= +if [ -n "$CLIENTIP" ]; then + PARAM="-r $CLIENTIP" +fi +echo -n "$CLIENTIP" > "/run/firstip" +echo -n "$GATEWAY" > "/run/firstgw" +echo -n "$FUTURE_ROOT" > "/run/future_root" +udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" + diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 index 4e19fb3a..4e19fb3a 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 diff --git a/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger b/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger new file mode 100755 index 00000000..7a8eaf0b --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger @@ -0,0 +1,59 @@ +#!/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}.." + 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 + +RESOLV=$(cat "/run/future_root") +RESOLV="${RESOLV}/etc/resolv.conf" +rm -f -- "$RESOLV" + +# DNS/domain? +if [ -n "$domain" ]; then + echo "domain $domain" >> "$RESOLV" + echo "search $domain" >> "$RESOLV" +fi +[ -n "$dns" ] && echo "..got DNS.." +for serv in $dns; do + echo "nameserver $serv" >> "$RESOLV" +done +cp "$RESOLV" "/etc/resolv.conf" 2>/dev/null + diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index ae65d9da..ac058591 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -16,7 +16,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin # import common functions -. /etc/functions.inc +. "/etc/functions.inc" # mount the important standard directories busybox mount -n -t tmpfs -o 'mode=755' run "/run" @@ -32,14 +32,25 @@ mkdir -p "$FUTURE_ROOT/opt/openslx" # let kernel know that mdev is to be used for hotplug echo "/sbin/mdev" > /proc/sys/kernel/hotplug -# read graphic and network adaptor configuration (without proprietary drivers yet) -# TODO: must ugly hack ever... needs to be improved when we add prop drivers -for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do - DRM="$(basename "$DRM")" - DRM="${DRM%.ko}" - echo "Trying to load module $DRM" - modprobe "$DRM" -done +setup_gfx () { + # read graphic and network adaptor configuration (without proprietary drivers yet) + # TODO: most ugly hack ever... needs to be improved when we add prop drivers + for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do + DRM="$(basename "$DRM")" + DRM="${DRM%.ko}" + #echo "Trying to load module $DRM" + modprobe "$DRM" 2>/dev/null + done + # start plymouth if activated + #if [ $DEBUG -lt 1 ]; then + # echo "Starting plymouth..." + # # link the theming directory from the config to the current root + # ln -sf "${FUTURE_ROOT}/usr/share" /usr/share + # lymouthd --kernel-command-line="splash" --tty=/dev/tty7 && plymouth show-splash + #fi +} + +setup_gfx & # discover devices mdev -s @@ -70,25 +81,17 @@ done [ $DEBUG -ge 5 ] && drop_shell "Requested Debug Shell: before network." -. "/bin/setup_network" || drop_shell "Error setting up network" +. "/inc/setup_network" || drop_shell "Error setting up network" [ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: after network/before configuring." -. "/bin/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" +. "/inc/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" [ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring." -# start plymouth if activated -#if [ $DEBUG -lt 1 ]; then -# echo "Starting plymouth..." -# # link the theming directory from the config to the current root -# ln -sf "${FUTURE_ROOT}/usr/share" /usr/share -# plymouthd --kernel-command-line="splash" --tty=/dev/tty7 && plymouth show-splash -#fi - [ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32." -. "/bin/setup_stage32" || drop_shell "Problem setting up stage3.2" +. "/inc/setup_stage32" || drop_shell "Problem setting up stage3.2" # copy files needed for stage3.2 to FUTURE_ROOT [ $DEBUG -ge 1 ] && echo "Copying busybox etc. to stage32..." @@ -107,7 +110,7 @@ fi # unmount filesystems for mnt in proc sys run ; do - busybox umount -n "$mnt" + busybox umount -n "$mnt" 2>/dev/null done echo "Switching root...." diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build index b2b66459..82477940 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build @@ -15,21 +15,24 @@ build() { get_link_chain "$FILE" >> "$COPYLIST" done + mkdir -p "$MODULE_BUILD_DIR/lib" + find /lib /lib64 /usr/lib /usr/lib64 \( -name "libnss_dns*" -o -name "libresolv*" \) -exec cp {} "$MODULE_BUILD_DIR/lib" \; + tarcopy "$(cat "$COPYLIST" | sort -u)" "$MODULE_BUILD_DIR" } post_copy() { pinfo "Generating rootfs for Stage 3.1 ..." - generate_rootfs + generate_rootfs # copy kernel, modules and firmware - copy_kernel_modules - copy_firmware + copy_kernel_modules + copy_firmware copy_kernel - # 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 + # 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 # TODO: Why isn't this a simple static file in this module's data dir? mkdir -p "$TARGET_BUILD_DIR/etc/modprobe.d" echo "options vmwgfx enable_fbdev=1" > "${TARGET_BUILD_DIR}"/etc/modprobe.d/vmwgfx-fbdev.conf @@ -39,18 +42,18 @@ post_copy() { # 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}" - - # copy required files - tarcopy "${REQUIRED_FILES}" "${TARGET_BUILD_DIR}" + # 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}" + + # copy required files + tarcopy "${REQUIRED_FILES}" "${TARGET_BUILD_DIR}" } diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf index cd68e75f..02887e69 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf @@ -1,12 +1,15 @@ -REQUIRED_MODULES=" busybox - kernel" -REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko +REQUIRED_MODULES=" + busybox + kernel +" +REQUIRED_KERNEL_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/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/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 @@ -45,19 +48,26 @@ REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko kernel/net/802/stp.ko kernel/net/bridge/bridge.ko kernel/ubuntu/aufs/aufs.ko - kernel/fs/aufs/aufs.ko" -REQUIRED_FIRMWARE=" 3com/ - e100/ - matrox/ - r128/ - radeon/ - RTL8192E/ - RTL8192SE/ - rtl_nic/ - tigon/" + kernel/fs/aufs/aufs.ko +" +REQUIRED_FIRMWARE=" + 3com/ + e100/ + matrox/ + r128/ + radeon/ + RTL8192E/ + RTL8192SE/ + rtl_nic/ + tigon/ +" REQUIRED_BINARIES=" grep " +REQUIRED_LIBRARIES=" + libnss_dns + libresolv +" REQUIRED_FILES=" /etc/protocols /etc/services |
