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