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