From 0ecb880774a2a74350d055afe7773ae0c31aaab9 Mon Sep 17 00:00:00 2001 From: Matej Matuska Date: Tue, 20 Dec 2022 12:25:48 +0100 Subject: [PATCH 53/63] Add autosourcing --- .../files/dracut/90sys-upgrade/.profile | 9 +++++++++ .../files/dracut/90sys-upgrade/.shrc | 4 ++++ .../files/dracut/90sys-upgrade/leapp_debug_tools.sh | 9 ++++++--- .../files/dracut/90sys-upgrade/module-setup.sh | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.profile create mode 100644 repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.shrc diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.profile b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.profile new file mode 100644 index 00000000..c4fe05a7 --- /dev/null +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.profile @@ -0,0 +1,9 @@ +#!/bin/sh +# script read at startup by login shells +# in the initramfs this is read for example by the emergency shell + +# set the environment file, containing shell commands to execute at startup of +# interactive shells +if [ -f "$HOME/.shrc" ]; then + ENV="$HOME/.shrc"; export ENV +fi diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.shrc b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.shrc new file mode 100644 index 00000000..5e965f47 --- /dev/null +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/.shrc @@ -0,0 +1,4 @@ +#!/bin/sh + +# shell commands to execute on interactive shell startup +. leapp_debug_tools.sh diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/leapp_debug_tools.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/leapp_debug_tools.sh index 91c228ce..5878b75b 100644 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/leapp_debug_tools.sh +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/leapp_debug_tools.sh @@ -1,3 +1,4 @@ +#!/bin/sh # library containing some useful functions for debugging in initramfs # mounts the sysroot @@ -29,10 +30,12 @@ leapp_dbg_chroot() { for dir in /sys /run /proc /dev /dev/pts; do mount --bind $dir "$NEWROOT$dir" - done || { echo "Failed to mount some directories" || return 1 } + done || { + echo "Failed to mount some directories" || return 1 + } - chroot $NEWROOT sh -c "mount -a; /bin/bash" + chroot "$NEWROOT" sh -c "mount -a; /bin/bash" for dir in /sys /run /proc /dev/pts /dev; do - umount $NEWROOT$dir + umount "$NEWROOT$dir" done } diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/module-setup.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/module-setup.sh index a9cfffb4..06479fb5 100755 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/module-setup.sh +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/module-setup.sh @@ -73,6 +73,8 @@ install() { "${generatordir}/initrd-system-upgrade-generator" inst_script "${_moddir}/leapp_debug_tools.sh" "/bin/leapp_debug_tools.sh" + inst_script "${_moddir}/.profile" "/.profile" + inst_script "${_moddir}/.shrc" "/.shrc" ## upgrade shell service #sysinit_wantsdir="${_initdir}${unitdir}/sysinit.target.wants" -- 2.39.0