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