diff options
| -rwxr-xr-x | builder/dnbd3-rootfs/debugging-tools/endless | bin | 6752 -> 0 bytes | |||
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/prepare-root-partition.sh | 39 | ||||
| -rw-r--r-- | dev-tools/debugging-tools/endless.c (renamed from builder/dnbd3-rootfs/debugging-tools/endless.c) | 0 | ||||
| -rw-r--r-- | dev-tools/debugging-tools/network.functions (renamed from builder/dnbd3-rootfs/debugging-tools/network.functions) | 0 | ||||
| -rw-r--r-- | dev-tools/debugging-tools/setup-network.sh (renamed from builder/dnbd3-rootfs/debugging-tools/setup-network.sh) | 0 | ||||
| -rw-r--r-- | dev-tools/example-openslx.config | 41 | ||||
| -rwxr-xr-x | dev-tools/exampleDracutModule/apply-package.sh | 8 | ||||
| -rwxr-xr-x | dev-tools/exampleDracutModule/module-setup.sh | 41 |
8 files changed, 97 insertions, 32 deletions
diff --git a/builder/dnbd3-rootfs/debugging-tools/endless b/builder/dnbd3-rootfs/debugging-tools/endless Binary files differdeleted file mode 100755 index de7a8c0a..00000000 --- a/builder/dnbd3-rootfs/debugging-tools/endless +++ /dev/null diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index 79cb6225..b57a915c 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -18,36 +18,27 @@ source /etc/openslx if [[ "$SLX_WRITABLE_DEVICE_IDENTIFIER" != '' ]] && ! persistent_device="$( tools.find_block_device "$SLX_WRITABLE_DEVICE_IDENTIFIER" '' \ - "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT" + "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS" )" then logging.warn "Failed to find unique device with identifier" \ "\"${SLX_WRITABLE_DEVICE_IDENTIFIER}\"; matched devices:" \ "\"${persistent_device}\"" fi - -# TODO move somewhere else -#tmp_device="$(tools.find_block_device \ - #'$SLX_TMP_PARTITION_IDENTIFIER')" - -#if [ -n $tmp_device ]; then - #mount --type auto "$tmp_device" "$NEWROOT/tmp" -#fi - -if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE" ] && [ -n "$persistent_device" ] +if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" ] && [ -n "$persistent_device" ] then persistent_mountpoint=/mnt/slx_writable_device - storage_file=$persistent_mountpoint/$SLX_WRITABLE_DEVICE_STORAGE_FILE - ! mkdir --parents $persistent_mountpoint + storage_file_path="${persistent_mountpoint}/$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" + ! mkdir --parents "$(dirname "$storage_file_path")" if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then logging.warn "Failed to mount $persistent_device, checking filesystem." - ! $SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CHECK_COMMAND \ + ! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \ "$persistent_device" if ! mount --type auto "$persistent_device" "$persistent_mountpoint" then logging.warn "Mounting $persistent_device, still failing," \ "creating new filesystem on device" - $SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CREATE_COMMAND \ + $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \ "$persistent_device" fi if ! mount --type auto "$persistent_device" "$persistent_mountpoint" @@ -58,13 +49,13 @@ then fi fi if [ -n "$persistent_device" ]; then - if [ ! -e "$storage_file" ]; then + if [ ! -e "$storage_file_path" ]; then # Create a sparse file. - dd of="$storage_file" bs=1M \ - seek="$SLX_WRITABLE_DEVICE_STORAGE_FILE_MAX_SIZE_MB" count=0 + dd of="$storage_file_path" bs=1M \ + seek="$SLX_WRITABLE_DEVICE_STORAGE_MAXIMUM_FILE_SIZE_IN_MB" count=0 fi persistent_device="$(losetup --find)" - losetup "$persistent_device" "$storage_file" + losetup "$persistent_device" "$storage_file_path" fi fi @@ -77,19 +68,19 @@ if [ -n "$persistent_device" ]; then persistent='P' fi else - ramdisk_size="$SLX_RAMDISK_SIZE" - if [ "$ramdisk_size" = '' ]; then - ramdisk_size="$(awk '/MemTotal/ {print $2}' /proc/meminfo)" + ramdisk_size_in_kb="$SLX_RAMDISK_SIZE_IN_KB" + if [ "$ramdisk_size_in_kb" = '' ]; then + ramdisk_size_in_kb="$(awk '/MemTotal/ {print $2}' /proc/meminfo)" fi # NOTE: If the kernel modul "brd" is compiled into current kernel we can't # configure ram disk size dynamically. In this case it have to be # configured via kernel command line: "brd.rd_size=SITE_IN_KILOBYTE" # statically: #! rmmod brd 2>/dev/null - #modprobe brd max_part=1 rd_size="$ramdisk_size" + #modprobe brd max_part=1 rd_size="$ramdisk_size_in_kb" #writable_device='/dev/ram0' ramdisk_location="$(mktemp)" - dd of="$ramdisk_location" seek="$ramdisk_size" count=0 1>/dev/null + dd of="$ramdisk_location" seek="$ramdisk_size_in_kb" count=0 1>/dev/null writable_device="$(losetup --find)" losetup "$writable_device" "$ramdisk_location" fi diff --git a/builder/dnbd3-rootfs/debugging-tools/endless.c b/dev-tools/debugging-tools/endless.c index 22c9bc50..22c9bc50 100644 --- a/builder/dnbd3-rootfs/debugging-tools/endless.c +++ b/dev-tools/debugging-tools/endless.c diff --git a/builder/dnbd3-rootfs/debugging-tools/network.functions b/dev-tools/debugging-tools/network.functions index 89ca5a20..89ca5a20 100644 --- a/builder/dnbd3-rootfs/debugging-tools/network.functions +++ b/dev-tools/debugging-tools/network.functions diff --git a/builder/dnbd3-rootfs/debugging-tools/setup-network.sh b/dev-tools/debugging-tools/setup-network.sh index 3b32a68c..3b32a68c 100644 --- a/builder/dnbd3-rootfs/debugging-tools/setup-network.sh +++ b/dev-tools/debugging-tools/setup-network.sh diff --git a/dev-tools/example-openslx.config b/dev-tools/example-openslx.config index 47d37c43..57197eec 100644 --- a/dev-tools/example-openslx.config +++ b/dev-tools/example-openslx.config @@ -1,25 +1,50 @@ +# This file contains configuration how the dnbd3 provided read only basic image +# should be injected and made writable by a local writable layer. + +# The openslx config will be placed in "/etc/openslx" in initramfs. + +# Location where this config file should be placed in final booted template +# system. SLX_CONFIGURATION_LOCATION='/opt/openslx/' +# A comma separated list of dnbd3 server host names or ip addresses where +# the read only image should be provided. The first matching ip will be used. SLX_DNBD3_SERVERS='132.230.4.201,132.230.4.202,10.0.2.2' +# dnbd3 image version to use. SLX_DNBD3_RID='0' +# Device name where the read only image should be injected. SLX_DNBD3_DEVICE='/dev/dnbd0' +# Path on remote dnbd3 server for basic readonly image. SLX_DNBD3_IMAGE='archLinux/archLinux.vmdk' -# If empty the whole device is used +# Partition identifier for the system partition, if empty the whole device will +# be used (no partition assumed). SLX_SYSTEM_PARTITION_IDENTIFIER='system' +# Script to run and set the read only device. +# (e.g. "lvm_scan && read_only_partition=/dev/centos/root") +SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT='' +# Device to mount and save the writable binary difference fill in. Empty means +# no writable device should be injected and ram will be used as fallback. SLX_WRITABLE_DEVICE_IDENTIFIER='' -SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT='' -SLX_WRITABLE_DEVICE_STORAGE_FILE='storage.img' +# Time to wait for the writable device in seconds. +SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS=10 +# File path for binary difference file. +SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH='storage.img' # NOTE: if the filesystem is any other than ext4, then the corresponding # filesystem tools have to be added to the initramfs manually. (use the dracut # --install parameter) -SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CREATE_COMMAND='mkfs.ext4' -SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CHECK_COMMAND='fsck.ext4' -SLX_WRITABLE_DEVICE_STORAGE_FILE_MAX_SIZE_MB='1000' +SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND='mkfs.ext4' +SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND='fsck.ext4' +SLX_WRITABLE_DEVICE_STORAGE_MAXIMUM_FILE_SIZE_IN_MB='1000' +# Indicates whether existing persistent file should be taken in account. SLX_WRITABLE_DEVICE_PERSISTENT='no' # If empty we will end up in an empty fstab file. If you want to reuse the # original fstab (from the template system) provide a dummy script like "true". SLX_GENERATE_FSTAB_SCRIPT=' echo "/dev/mapper/root / btrfs subvol=root 0 0" >> "$NEWROOT/etc/fstab" ' -# if empty will use all available ram -SLX_RAMDISK_SIZE='' +# Upper bound for ram using. If empty all available ram will be used. +SLX_RAMDISK_SIZE_IN_KB='' +# Specifies mount options for the final root location where we want to pivot +# root in. SLX_MOUNT_ROOT_OPTIONS='-o subvol=root' +# Path where all the logs should be placed. +SLX_LOG_FILE_PATH='/var/log/openslx' diff --git a/dev-tools/exampleDracutModule/apply-package.sh b/dev-tools/exampleDracutModule/apply-package.sh new file mode 100755 index 00000000..218740ef --- /dev/null +++ b/dev-tools/exampleDracutModule/apply-package.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- + +source /etc/openslx + +echo -------------------------------------------------------------------------- +echo TEST +echo -------------------------------------------------------------------------- diff --git a/dev-tools/exampleDracutModule/module-setup.sh b/dev-tools/exampleDracutModule/module-setup.sh new file mode 100755 index 00000000..bfe216e7 --- /dev/null +++ b/dev-tools/exampleDracutModule/module-setup.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- + +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd '../' && \ + cd *'dnbd3-rootfs/scripts/rebash' && pwd)/core.sh" +core.import exceptions +core.import logging + +check() { + local __doc__=' + Checks whether needed assumptions are satisfied. + + Example: + + `check` + ' + # Tell dracut that this module should only be included if it is required + # explicitly. + return 255 +} +depends() { + local __doc__=' + Outputs all dependent dracut modules to make this module work. + + >>> depends + +doc_test_contains + base + ' + echo dnbd3-rootfs +} +install() { + local __doc__=' + Copies all needed files into the initramfs image and registers all needed + dracut hooks. + + Example: + + `install` + ' + inst_hook pre-pivot 00 "$moddir/apply-package.sh" +} |
