aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Reyes (likewhoa) <design@missionaccomplish.com>2014-06-03 19:48:14 +0200
committerRick Farina (Zero_Chaos) <zerochaos@gentoo.org>2015-04-29 13:31:45 -0400
commitaa073bf7ee057fa5d7b1643ccb25618162c2bbd6 (patch)
tree7b5b063467647b76828622c43502c64f5d8b79cb
parentA new bootstrapFS function has been added to cut on duplicate code (diff)
downloadgenkernel-aa073bf7.tar.gz
genkernel-aa073bf7.tar.bz2
genkernel-aa073bf7.zip
Better implementation which was originally done in 946918e & 7a38d63.
-rw-r--r--defaults/initrd.scripts36
-rw-r--r--defaults/linuxrc38
2 files changed, 38 insertions, 36 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index eb5ed6a..91056b1 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -310,6 +310,42 @@ union_insert_modules() {
done
}
+# Implements RC_NO_UMOUNTS variable into ${CHROOT}/etc/rc.conf for a cleaner shutdown process
+# This should really go into /etc/init.d/localmounts but until then we manually set this here
+conf_rc_no_umounts() {
+ local conf nomount fnd
+ conf="${CHROOT}/etc/rc.conf"
+ fnd=0
+
+ if nomount=$(grep -n '^[[:blank:]]*RC_NO_UMOUNTS=' $conf); then
+ local i n data cmd IFS
+ IFS='
+'
+ set -- $nomount
+ unset IFS
+
+ for i; do
+ n=${i%%:*}; i=${i#"$n"}
+ data=${i#*=}
+
+ case $data in
+ "\"$RC_NO_UMOUNTS\""|"'$RC_NO_UMOUNTS'") fnd=1;;
+ *) cmd="$cmd$n d;"
+ esac
+ done
+
+ if [ -n "$cmd" ]; then
+ sed -i "${cmd%;}" $conf
+ test_success "Unable to edit rc.conf"
+ fi
+ fi
+
+ if [ 0 -eq "$fnd" ]; then
+ printf 'RC_NO_UMOUNTS="%s"\n' "$RC_NO_UMOUNTS" >> $conf
+ test_success "Unable to write to rc.conf"
+ fi
+}
+
# Function to create an ext2 fs on $CHANGESDEV, $CHANGESMNT mountpoint
create_changefs() {
local size
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 0e40d16..a6c4806 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -791,42 +791,8 @@ then
#sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' /${UNION}/etc/fstab > /${UNION}/etc/fstab.new
#mv /${UNION}/etc/fstab.new /${UNION}/etc/fstab
- # RC_NO_UMOUNTS variable for a clean shutdown/reboot
- RC_MOUNTS=$(grep 'RC_NO_UMOUNTS' "${CHROOT}"/etc/rc.conf)
-
- # Iterate through ${RC_MOUNTS} to find our duplicate(s) and or remove obsolete lines when ever
- # our RC_NO_UMOUNTS variable changes.
- if [ -n "${RC_MOUNTS}" ]; then
- printf '%s\n' ${RC_MOUNTS} |
- {
- while read -r mount; do
- # Remove double quotes from ${mount}
- new_mount=$(echo ${mount} | sed 's/"//g')
-
- if [[ "${new_mount}" = "RC_NO_UMOUNTS="${RC_NO_UMOUNTS}"" ]]; then
- RESULTS=false
- else
- # Escape characters in ${mounts} for use in sed
- mount_re=$(echo ${mount} | sed -e 's/\//\\\//g' -e 's/\&/\\\&/g')
-
- # Remove non matching pattern
- sed -i "/${mount_re}/d" "${CHROOT}"/etc/rc.conf
-
- RESULTS=true
- fi
- done
-
- # no RC_NO_UMOUNTS match found
- if ${RESULTS}; then return 1;fi
- }
- else
- echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
- fi
-
- # An RC_NO_UMOUNTS was not found that matches our current one
- if [ $? -eq 1 ]; then
- echo "RC_NO_UMOUNTS=\"${RC_NO_UMOUNTS}\"">> "${CHROOT}"/etc/rc.conf
- fi
+ # Function to handle the RC_NO_UMOUNTS variable in ${CHROOT}/etc/rc.conf
+ conf_rc_no_umounts
# Fstab change for aufs
test ! $(grep -o ^aufs "${CHROOT}"/etc/fstab) &&