[projects/rc-scripts] Conditions for lxc similar to vservers

adwol adwol at pld-linux.org
Mon Jan 20 13:30:43 CET 2025


commit 64eec49fa594a9ba5f631c3a65c74a1df8a82b75
Author: Adam Osuchowski <>
Date:   Mon Jan 20 12:38:22 2025 +0100

    Conditions for lxc similar to vservers

 lib/functions    | 5 +++--
 rc.d/rc          | 6 ++++--
 rc.d/rc.shutdown | 2 +-
 rc.d/rc.sysinit  | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/lib/functions b/lib/functions
index d1b6c1eb..d81eacaf 100644
--- a/lib/functions
+++ b/lib/functions
@@ -369,7 +369,8 @@ nls() {
 rc_splash() {
 	local action="$1"
 
-	if ! is_no "$BOOT_SPLASH" && ! is_yes "$VSERVER"; then
+	if ! is_no "$BOOT_SPLASH" && ! is_yes "$VSERVER" && \
+		[[ "$container" != lxc* ]]; then
 		[ -x /bin/splash ] && /bin/splash "$action"
 	fi
 
@@ -495,7 +496,7 @@ filter_chroot() {
 		pids=$(filter_ns "$@") && set -- "$pids"
 	fi
 
-	if is_yes "$VSERVER"; then
+	if is_yes "$VSERVER" || [[ "$container" = lxc* ]]; then
 		echo $@
 		return
 	fi
diff --git a/rc.d/rc b/rc.d/rc
index eba06521..74303c4b 100755
--- a/rc.d/rc
+++ b/rc.d/rc
@@ -69,6 +69,7 @@ fi
 # (it can be serial console too)
 if [ "$COLUMNS" -gt 0 ]; then
 	if [ "$argv2" != "chroot" ] && ! is_yes "$VSERVER" && \
+		[[ "$container" != lxc* ]] && \
 		[ "$runlevel" = "0" -o "$runlevel" = "6" ]; then
 		CONSOLE=/dev/tty1
 		[ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > $CONSOLE
@@ -82,7 +83,8 @@ fi
 
 # See if we want to be in user confirmation mode
 if [ "$previous" = "N" ]; then
-	if ! is_yes "$VSERVER" && grep -qi confirm /proc/cmdline >/dev/null 2>/dev/null \
+	if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]] && \
+		grep -qi confirm /proc/cmdline >/dev/null 2>/dev/null \
 		|| [ -f /var/run/confirm ]; then
 		rm -f /var/run/confirm
 		CONFIRM="yes"
@@ -129,7 +131,7 @@ else
 	export progress=0
 fi
 
-if is_yes "$VSERVER"; then
+if is_yes "$VSERVER" || [[ "$container" = lxc* ]]; then
 	# if runlevel is not 0 (halt) or 6 (reboot) run rc.sysinit
 	# BUT only if rc is run standalone (not run by init, as init will run rc.sysinit)
 	if [ "$previous" != "N" -a "$runlevel" != "0" -a "$runlevel" != "6" ]; then
diff --git a/rc.d/rc.shutdown b/rc.d/rc.shutdown
index be5c7857..9fc1d2af 100755
--- a/rc.d/rc.shutdown
+++ b/rc.d/rc.shutdown
@@ -54,7 +54,7 @@ fi
 # Write to wtmp file before unmounting /var
 halt -w
 
-if ! is_yes "$VSERVER"; then
+if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then
 	# Turn off swap, then unmount file systems.
 	run_cmd "Turning off swap" swapoff -a
 
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index b55f0cc7..86f7c273 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -1045,7 +1045,7 @@ is_yes "$SELINUX" && restorecon /tmp/.ICE-unix >/dev/null 2>&1
 
 test -d /var/run/netreport || mkdir -m 770 /var/run/netreport
 
-if ! is_yes "$VSERVER"; then
+if ! is_yes "$VSERVER" && [[ "$container" != lxc* ]]; then
 	enable_swap
 
 	# If a SCSI tape has been detected, load the st module unconditionally
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/rc-scripts.git/commitdiff/64eec49fa594a9ba5f631c3a65c74a1df8a82b75



More information about the pld-cvs-commit mailing list