diff options
author | jandob | 2016-03-29 19:06:18 +0200 |
---|---|---|
committer | jandob | 2016-03-29 19:06:18 +0200 |
commit | 252b073349d374dc23f55701c4abdc1ffb4ade97 (patch) | |
tree | ae5965509e6089a6a3a64fc28586b09be655a788 | |
parent | add tee dependency (diff) | |
download | systemd-init-252b073349d374dc23f55701c4abdc1ffb4ade97.tar.gz systemd-init-252b073349d374dc23f55701c4abdc1ffb4ade97.tar.xz systemd-init-252b073349d374dc23f55701c4abdc1ffb4ade97.zip |
add logging to file functionality
11 files changed, 40 insertions, 19 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index b3d43015..0ceef33f 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -78,11 +78,11 @@ declare -A core_dependencies=( [dmsetup]='create a (temporary) writable layer during boot' \ [grep]='retrieve right boot partition during boot' \ [mktemp]='create save temporary files and dictionaries' \ + [tee]='read from standard input and write to standard output and files' \ [readlink]="connect dracut module with dracut's module system" \ [rm]='remove (temporary) files' \ [shift]='parse command line' \ [sed]='process strings' \ - [tee]='write stdout to file' \ ['cmake gcc make']='dynamically compile needed resources against current or given kernel') # shellcheck disable=SC2034 declare -A optional_dependencies=( @@ -557,7 +557,7 @@ main() { if ! ln --symbolic --force "$_dracut_modules_source" \ "$_dracut_modules_target" 2>/dev/null; then logging.warn \ - "Link \"$_dracut_modules_source\" to \"$_dracut_modules_target\" fails. We will copy them. So we have to recopy it every time to ensure that recompiled things take effect." + "Linking \"$_dracut_modules_source\" to \"$_dracut_modules_target\" failed. We will copy them. So we have to recopy it every time to ensure that recompiled things take effect." cp --recursive --force --no-target-directory \ "$(dirname "${BASH_SOURCE[0]}")/$(basename "$_dracut_modules_source")" \ "$_dracut_modules_target" @@ -603,7 +603,7 @@ main() { logging.set_commands_level "$_commands_log_level_backup" logging.set_level "$_log_level_backup" if [[ "$_return_code" != 0 ]]; then - logging.error 'Building initial ram file system fails.' + logging.error 'Building initial ram file system failed.' exit 1 fi exceptions.activate diff --git a/builder/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh b/builder/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh index a1554752..ee308af6 100755 --- a/builder/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh +++ b/builder/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh @@ -10,6 +10,8 @@ exceptions.try { logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" systemd_system_unit_path="$(dirname "$(find / -name dracut-mount.service \ -type f -print -quit)")" diff --git a/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh index f0a07dfb..a887d8c9 100755 --- a/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh +++ b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh @@ -10,6 +10,8 @@ exceptions.try { logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" # Needed to be able to go back to dracut at system shutdown. temporary_directory_path="$(mktemp --directory)" diff --git a/builder/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh b/builder/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh index 8bf51724..6a56f857 100755 --- a/builder/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh +++ b/builder/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh @@ -8,10 +8,12 @@ type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # endregion exceptions.try { +source "/etc/openslx" logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" -source "/etc/openslx" mkdir --parents "${NEWROOT}${SLX_CONFIGURATION_LOCATION}" cp "/etc/openslx" "${NEWROOT}${SLX_CONFIGURATION_LOCATION}" } diff --git a/builder/dnbd3-rootfs/hooks/fetch-config.sh b/builder/dnbd3-rootfs/hooks/fetch-config.sh index 0b8d5a0a..7921a99f 100755 --- a/builder/dnbd3-rootfs/hooks/fetch-config.sh +++ b/builder/dnbd3-rootfs/hooks/fetch-config.sh @@ -10,6 +10,9 @@ exceptions.try { logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" + # NOTE: "getarg" raises an exception so deactivate exceptions for now. exceptions.deactivate configuration_file_name="$(getarg slx_configuration_filename=)" diff --git a/builder/dnbd3-rootfs/hooks/mount-root-device.sh b/builder/dnbd3-rootfs/hooks/mount-root-device.sh index 49bfcdc6..35443def 100755 --- a/builder/dnbd3-rootfs/hooks/mount-root-device.sh +++ b/builder/dnbd3-rootfs/hooks/mount-root-device.sh @@ -9,6 +9,8 @@ exceptions.try { logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" if ! getarg root=; then source "/etc/openslx" diff --git a/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh b/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh index cb58d981..ba234c55 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh @@ -8,6 +8,8 @@ core.import logging ( logging.set_commands_level debug logging.set_level debug +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" SLX_INITIAL_KERNEL_COMMAND_LINE="$(cat /proc/cmdline | tr --delete '\n')" diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index b57a915c..95d13e51 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -9,10 +9,11 @@ type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # endregion exceptions.try { +source /etc/openslx logging.set_commands_level debug logging.set_level debug - -source /etc/openslx +[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx +logging.set_log_file "$SLX_LOG_FILE_PATH" # region find writable partition if [[ "$SLX_WRITABLE_DEVICE_IDENTIFIER" != '' ]] && @@ -110,7 +111,14 @@ if [[ $return_code != 0 ]]; then fi # endregion # region scan partitions -read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE")" +if [ "$SLX_LOG_FILE_PATH" != "" ]; then + read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE" \ + 2>>"$SLX_LOG_FILE_PATH")" +else + read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE")" +fi + + # Fail fast if no device could be determined. [ -z "$read_only_device" ] && exit 1 # endregion diff --git a/builder/dnbd3-rootfs/module-setup.sh b/builder/dnbd3-rootfs/module-setup.sh index fecadb2e..3599d797 100755 --- a/builder/dnbd3-rootfs/module-setup.sh +++ b/builder/dnbd3-rootfs/module-setup.sh @@ -251,15 +251,14 @@ install() { basename bash blockdev \ cat cut \ dd diff dirname dmsetup \ - find \ + find fsck.ext4 \ grep \ insmod \ losetup lsblk \ - mktemp mount mountpoint \ + mkfifo mkfs.ext4 mktemp mount mountpoint \ sed sleep sort \ - touch tr \ - wget \ - mkfs.ext4 fsck.ext4 + tee touch tr \ + wget } # endregion # region vim modline diff --git a/builder/dnbd3-rootfs/scripts/rebash b/builder/dnbd3-rootfs/scripts/rebash -Subproject c27ca6ac577c6da7983453ad84290cd9b951f56 +Subproject 9adcbb8f7eb07b519f30cac0a0e9c4d382f4901 diff --git a/dev-tools/example-openslx.config b/dev-tools/example-openslx.config index 57197eec..42d30e07 100644 --- a/dev-tools/example-openslx.config +++ b/dev-tools/example-openslx.config @@ -3,15 +3,15 @@ # The openslx config will be placed in "/etc/openslx" in initramfs. -# Location where this config file should be placed in final booted template +# Location where this config file should be placed in the 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. +# the read only image can be accessed. 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. +# Device name to which the read only image will be connected. SLX_DNBD3_DEVICE='/dev/dnbd0' # Path on remote dnbd3 server for basic readonly image. SLX_DNBD3_IMAGE='archLinux/archLinux.vmdk' @@ -21,12 +21,12 @@ 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. +# Device to mount and save the writable binary diff to. If Empty or not found, +# a ramdisk will be used as fallback. SLX_WRITABLE_DEVICE_IDENTIFIER='' # Time to wait for the writable device in seconds. SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS=10 -# File path for binary difference file. +# File path for binary difference file. If empty the whole device will be used. 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 @@ -41,7 +41,8 @@ SLX_WRITABLE_DEVICE_PERSISTENT='no' SLX_GENERATE_FSTAB_SCRIPT=' echo "/dev/mapper/root / btrfs subvol=root 0 0" >> "$NEWROOT/etc/fstab" ' -# Upper bound for ram using. If empty all available ram will be used. +# Upper bound for ram usage for the binary diff. 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. |