-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc6.patch
123 lines (110 loc) · 3.09 KB
/
rc6.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
--- rc.6.orig 2012-02-15 20:43:02.000000000 +0100
+++ rc.6 2012-02-15 21:06:45.000000000 +0100
@@ -10,6 +10,13 @@
# Modified by: Patrick J. Volkerding, <[email protected]>
#
# Modified for Salix by: George Vlahavas <vlahavas~at~gmail~dot~com>
+# tweaks for an lxc container by ponce <[email protected]>,
+# based also on Chris Willing's modifications
+# http://www.vislab.uq.edu.au/howto/lxc/rc.6
+# tweaks for Salix container by Frédéric Galusik <fredg~at~salixos~dot~org>
+
+# a check for a container variable is made to jump unneeded sections
+CONTAINER=yes
# modified for colorized screen messages and local needs
. /etc/shell-colors
@@ -45,6 +52,9 @@
;;
esac
+# container check
+if [ ! $CONTAINER ]; then
+
# Save the system time to the hardware clock using hwclock --systohc.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
@@ -61,6 +71,8 @@
fi
fi
+fi # end container check
+
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
echo -e "${BOLDWHITE}Running local shutdown commands...${COLOR_RESET}"
@@ -143,6 +155,9 @@
sleep 2
fi
+# container check
+if [ ! $CONTAINER ]; then
+
# Shut down PCMCIA devices:
if [ -x /etc/rc.d/rc.pcmcia ]; then
. /etc/rc.d/rc.pcmcia stop
@@ -150,17 +165,24 @@
/bin/sleep 5
fi
+fi # end container check
+
# Turn off process accounting:
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
echo -e "${BOLDWHITE}Turning off process accounting.${COLOR_RESET}"
/sbin/accton off
fi
+# container check
+if [ ! $CONTAINER ]; then
+
# Terminate acpid before syslog:
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
. /etc/rc.d/rc.acpid stop
fi
+fi # end container check
+
# Kill all processes.
# INIT is supposed to handle this entirely now, but this didn't always
# work correctly without this second pass at killing off the processes.
@@ -172,6 +194,9 @@
/sbin/killall5 -9
fi
+# container check
+if [ ! $CONTAINER ]; then
+
# Try to turn off quota.
if /bin/grep -q quota /etc/fstab ; then
if [ -x /sbin/quotaoff ]; then
@@ -180,6 +205,8 @@
fi
fi
+fi # end container check
+
# Carry a random seed between reboots.
echo -e "${BOLDWHITE}Saving random seed from /dev/urandom in /etc/random-seed.${COLOR_RESET}"
# Use the pool size from /proc, or 512 bytes:
@@ -198,6 +225,9 @@
rm -f /var/lock/subsys/*
fi
+# container check
+if [ ! $CONTAINER ]; then
+
# Turn off swap:
echo -e "${BOLDCYAN}Turning off swap.${COLOR_RESET}"
/sbin/swapoff -a
@@ -209,9 +239,14 @@
echo -e "${BOLDCYAN}Remounting root filesystem read-only.${COLOR_RESET}"
/bin/mount -v -n -o remount,ro /
+fi # end container check
+
# This never hurts:
/bin/sync
+# container check
+if [ ! $CONTAINER ]; then
+
# Close any volumes opened by cryptsetup:
if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do
@@ -278,3 +313,8 @@
/sbin/poweroff
fi
+fi # end container check
+
+# confirm successful shutdown
+echo ; echo -e "${BOLDYELLOW}Container stopped.${COLOR_RESET}" ; echo
+