28ab1c
From 8c31ef8476d302d11bbad81644e82872bd1e86f3 Mon Sep 17 00:00:00 2001
28ab1c
From: Kairui Song <kasong@redhat.com>
28ab1c
Date: Mon, 15 Feb 2021 22:52:47 +0800
28ab1c
Subject: [PATCH] refactor(squash): move all setup code to init-squash.sh
28ab1c
28ab1c
Seperate of init.sh and setup-squash.sh is pointless, merge them into one.
28ab1c
28ab1c
(cherry picked from commit f9f4264d038816990aa0a830b31e31d2e8b84cad)
28ab1c
28ab1c
Resolves: #1959336
28ab1c
---
28ab1c
 modules.d/99squash/{setup-squash.sh => init-squash.sh} | 5 +++++
28ab1c
 modules.d/99squash/init.sh                             | 7 -------
28ab1c
 modules.d/99squash/module-setup.sh                     | 5 ++---
28ab1c
 3 files changed, 7 insertions(+), 10 deletions(-)
28ab1c
28ab1c
diff --git a/modules.d/99squash/setup-squash.sh b/modules.d/99squash/init-squash.sh
28ab1c
similarity index 93%
28ab1c
rename from modules.d/99squash/setup-squash.sh
28ab1c
rename to modules.d/99squash/init-squash.sh
28ab1c
index 253e6101..449585f0 100755
28ab1c
--- a/modules.d/99squash/setup-squash.sh
28ab1c
+++ b/modules.d/99squash/init-squash.sh
28ab1c
@@ -59,3 +59,8 @@ for file in $SQUASH_MNT/*; do
28ab1c
 
28ab1c
 	echo $mntdir >> $SQUASH_MNT_REC
28ab1c
 done
28ab1c
+
28ab1c
+exec /init.orig
28ab1c
+
28ab1c
+echo "Something went wrong when trying to exec original init!"
28ab1c
+exit 1
28ab1c
diff --git a/modules.d/99squash/init.sh b/modules.d/99squash/init.sh
28ab1c
deleted file mode 100755
28ab1c
index d8b2cbba..00000000
28ab1c
--- a/modules.d/99squash/init.sh
28ab1c
+++ /dev/null
28ab1c
@@ -1,7 +0,0 @@
28ab1c
-#!/bin/sh
28ab1c
-/squash/setup-squash.sh
28ab1c
-
28ab1c
-exec /init.orig
28ab1c
-
28ab1c
-echo "Something went wrong when trying to start original init executable!"
28ab1c
-exit 1
28ab1c
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
28ab1c
index dd4f3ecf..c0eb4acd 100644
28ab1c
--- a/modules.d/99squash/module-setup.sh
28ab1c
+++ b/modules.d/99squash/module-setup.sh
28ab1c
@@ -48,11 +48,10 @@ installpost() {
28ab1c
     # Install required files for the squash image setup script.
28ab1c
     hostonly="" instmods "loop" "squashfs" "overlay"
28ab1c
     inst_multiple modprobe mount mkdir ln echo
28ab1c
-    inst "$moddir"/setup-squash.sh /squash/setup-squash.sh
28ab1c
-    inst "$moddir"/clear-squash.sh /squash/clear-squash.sh
28ab1c
 
28ab1c
     mv "$initdir"/init "$initdir"/init.orig
28ab1c
-    inst "$moddir"/init.sh "$initdir"/init
28ab1c
+    inst "$moddir"/init-squash.sh /init
28ab1c
+    inst "$moddir"/clear-squash.sh /squash/clear-squash.sh
28ab1c
 
28ab1c
     # Keep systemctl outsite if we need switch root
28ab1c
     if [[ ! -f "$initdir/lib/dracut/no-switch-root" ]]; then
28ab1c