1 |
commit: f2e48df4ad02697915037dfbe5fe81411c1750fe |
2 |
Author: Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com> |
3 |
AuthorDate: Tue Jun 3 17:48:14 2014 +0000 |
4 |
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jun 23 23:11:15 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=f2e48df4 |
7 |
|
8 |
Better implementation which was originally done in 946918e & 7a38d63. |
9 |
|
10 |
--- |
11 |
defaults/initrd.scripts | 36 ++++++++++++++++++++++++++++++++++++ |
12 |
defaults/linuxrc | 38 ++------------------------------------ |
13 |
2 files changed, 38 insertions(+), 36 deletions(-) |
14 |
|
15 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
16 |
index 07890ec..52b18b3 100644 |
17 |
--- a/defaults/initrd.scripts |
18 |
+++ b/defaults/initrd.scripts |
19 |
@@ -310,6 +310,42 @@ union_insert_modules() { |
20 |
done |
21 |
} |
22 |
|
23 |
+# Implements RC_NO_UMOUNTS variable into ${CHROOT}/etc/rc.conf for a cleaner shutdown process |
24 |
+# This should really go into /etc/init.d/localmounts but until then we manually set this here |
25 |
+conf_rc_no_umounts() { |
26 |
+ local conf nomount fnd |
27 |
+ conf="${CHROOT}/etc/rc.conf" |
28 |
+ fnd=0 |
29 |
+ |
30 |
+ if nomount=$(grep -n '^[[:blank:]]*RC_NO_UMOUNTS=' $conf); then |
31 |
+ local i n data cmd IFS |
32 |
+ IFS=' |
33 |
+' |
34 |
+ set -- $nomount |
35 |
+ unset IFS |
36 |
+ |
37 |
+ for i; do |
38 |
+ n=${i%%:*}; i=${i#"$n"} |
39 |
+ data=${i#*=} |
40 |
+ |
41 |
+ case $data in |
42 |
+ "\"$RC_NO_UMOUNTS\""|"'$RC_NO_UMOUNTS'") fnd=1;; |
43 |
+ *) cmd="$cmd$n d;" |
44 |
+ esac |
45 |
+ done |
46 |
+ |
47 |
+ if [ -n "$cmd" ]; then |
48 |
+ sed -i "${cmd%;}" $conf |
49 |
+ test_success "Unable to edit rc.conf" |
50 |
+ fi |
51 |
+ fi |
52 |
+ |
53 |
+ if [ 0 -eq "$fnd" ]; then |
54 |
+ printf 'RC_NO_UMOUNTS="%s"\n' "$RC_NO_UMOUNTS" >> $conf |
55 |
+ test_success "Unable to write to rc.conf" |
56 |
+ fi |
57 |
+} |
58 |
+ |
59 |
# Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint |
60 |
create_changefs() { |
61 |
local size |
62 |
|
63 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
64 |
index 0e40d16..a6c4806 100644 |
65 |
--- a/defaults/linuxrc |
66 |
+++ b/defaults/linuxrc |
67 |
@@ -791,42 +791,8 @@ then |
68 |
#sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' /${UNION}/etc/fstab > /${UNION}/etc/fstab.new |
69 |
#mv /${UNION}/etc/fstab.new /${UNION}/etc/fstab |
70 |
|
71 |
- # RC_NO_UMOUNTS variable for a clean shutdown/reboot |
72 |
- RC_MOUNTS=$(grep 'RC_NO_UMOUNTS' "${CHROOT}"/etc/rc.conf) |
73 |
- |
74 |
- # Iterate through ${RC_MOUNTS} to find our duplicate(s) and or remove obsolete lines when ever |
75 |
- # our RC_NO_UMOUNTS variable changes. |
76 |
- if [ -n "${RC_MOUNTS}" ]; then |
77 |
- printf '%s\n' ${RC_MOUNTS} | |
78 |
- { |
79 |
- while read -r mount; do |
80 |
- # Remove double quotes from ${mount} |
81 |
- new_mount=$(echo ${mount} | sed 's/"//g') |
82 |
- |
83 |
- if [[ "${new_mount}" = "RC_NO_UMOUNTS="${RC_NO_UMOUNTS}"" ]]; then |
84 |
- RESULTS=false |
85 |
- else |
86 |
- # Escape characters in ${mounts} for use in sed |
87 |
- mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g') |
88 |
- |
89 |
- # Remove non matching pattern |
90 |
- sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf |
91 |
- |
92 |
- RESULTS=true |
93 |
- fi |
94 |
- done |
95 |
- |
96 |
- # no RC_NO_UMOUNTS match found |
97 |
- if ${RESULTS}; then return 1;fi |
98 |
- } |
99 |
- else |
100 |
- echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf |
101 |
- fi |
102 |
- |
103 |
- # An RC_NO_UMOUNTS was not found that matches our current one |
104 |
- if [ $? -eq 1 ]; then |
105 |
- echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf |
106 |
- fi |
107 |
+ # Function to handle the RC_NO_UMOUNTS variable in ${CHROOT}/etc/rc.conf |
108 |
+ conf_rc_no_umounts |
109 |
|
110 |
# Fstab change for aufs |
111 |
test ! $(grep -o ^aufs "${CHROOT}"/etc/fstab) && |