From cfa56a07ced20baf933dc27c3e37569c4db09a27 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 7 Dec 2015 11:39:04 +0100 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- init.d/binfmt | 2 +- init.d/bootmisc | 9 ++++----- init.d/consolefont | 2 +- init.d/localmount | 24 +++++++++++++---------- init.d/netmount | 5 ++++- init.d/savecache | 48 ++++++++++++++++++++++++++++------------------ init.d/sysfs | 2 +- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/init.d/binfmt b/init.d/binfmt index 057c76f7..f1d8791e 100755 --- a/init.d/binfmt +++ b/init.d/binfmt @@ -16,5 +16,5 @@ start() ebegin "Loading custom binary format handlers" "$RC_LIBEXECDIR"/sh/binfmt.sh eend $? -return 0 + return 0 } diff --git a/init.d/bootmisc b/init.d/bootmisc index cd9f457e..c8c0cf54 100755 --- a/init.d/bootmisc +++ b/init.d/bootmisc @@ -121,11 +121,11 @@ clean_run() local dir # If / is still read-only due to a problem, this will fail! if ! checkpath -W /; then - eerror "/ is not writable; unable to clean up underlying /run" + ewarn "/ is not writable; unable to clean up underlying /run" return 1 fi if ! checkpath -W /tmp; then - eerror "/tmp is not writable; unable to clean up underlying /run" + ewarn "/tmp is not writable; unable to clean up underlying /run" return 1 fi # Now we know that we can modify /tmp and / @@ -136,13 +136,12 @@ clean_run() dir=$(mktemp -d) if [ -n "$dir" -a -d $dir -a -w $dir ]; then mount --bind / $dir && rm -rf $dir/run/* || rc=1 - umount $dir - rm -rf $dir + umount $dir && rmdir $dir else rc=1 fi if [ $rc -ne 0 ]; then - eerror "Could not clean up underlying /run on /" + ewarn "Could not clean up underlying /run on /" return 1 fi } diff --git a/init.d/consolefont b/init.d/consolefont index 5b175a60..a7ad1dde 100755 --- a/init.d/consolefont +++ b/init.d/consolefont @@ -7,7 +7,7 @@ description="Sets a font for the consoles." depend() { need localmount termencoding - after hotplug bootmisc + after hotplug bootmisc modules keyword -openvz -prefix -systemd-nspawn -uml -vserver -xenu -lxc } diff --git a/init.d/localmount b/init.d/localmount index ae9d3cfe..ed60049c 100755 --- a/init.d/localmount +++ b/init.d/localmount @@ -15,7 +15,7 @@ depend() start() { # Mount local filesystems in /etc/fstab. - local types="noproc" x= no_netdev= + local types="noproc" x= no_netdev= rc= for x in $net_fs_list $extra_net_fs_list; do types="${types},no${x}" done @@ -29,9 +29,11 @@ start() ebegin "Mounting local filesystems" mount -at "$types" $no_netdev eend $? "Some local filesystem failed to mount" - - # Always return 0 - some local mounts may not be critical for boot - return 0 + rc=$? + if [ "$RC_UNAME" != Linux ]; then + rc=0 + fi + return $rc } stop() @@ -70,17 +72,19 @@ stop() sync fi - local aufs_branch aufs_mount_dir aufs_mount_point aufs_si_dir aufs_si_id - for aufs_si_dir in /sys/fs/aufs/*; do - aufs_mount_dir=${aufs_si_dir#/sys/fs/aufs/} - aufs_si_id="$(printf "%s" $aufs_mount_dir | sed 's/_/=/g')" + local aufs_branch aufs_mount_point aufs_si_id aufs_br_id branches + for aufs_si_dir in /sys/fs/aufs/si*; do + [ -d "${aufs_si_dir}" ] || continue + aufs_si_id="si=${aufs_si_dir#/sys/fs/aufs/si_}" aufs_mount_point="$(mountinfo -o ${aufs_si_id})" - for x in $aufs_si_dir/br[0-9][0-9][0-9]; do + branches="$aufs_si_dir/br[0-9] $aufs_si_dir/br[0-9][0-9] $aufs_si_dir/br[0-9][0-9][0-9]" + for x in $branches; do + [ -e "${x}" ] || continue aufs_branch=$(sed 's/=.*//g' $x) eindent if ! mount -o "remount,del:$aufs_branch" "$aufs_mount_point" > /dev/null 2>&1; then ewarn "Failed to remove branch $aufs_branch from aufs \ - $aufs_mount_point" + $aufs_mount_point" fi eoutdent sync diff --git a/init.d/netmount b/init.d/netmount index 7949d68e..d8383a14 100755 --- a/init.d/netmount +++ b/init.d/netmount @@ -27,7 +27,10 @@ start() rc=$? fi ewend $rc "Could not mount all network filesystems" - return 0 + if [ "$RC_UNAME" != Linux ]; then + rc=0 + fi + return $rc } stop() diff --git a/init.d/savecache b/init.d/savecache index f3caa0ab..9e885e8e 100755 --- a/init.d/savecache +++ b/init.d/savecache @@ -7,43 +7,53 @@ description="Saves the caches OpenRC uses to non volatile storage" start() { if [ -e "$RC_SVCDIR"/clock-skewed ]; then - ewarn "WARNING: clock skew detected!" + ewarn "Clock skew detected!" if ! yesno "${RC_GOINGDOWN}"; then eerror "Not saving deptree cache" return 1 fi fi - if ! checkpath -W "$RC_LIBEXECDIR"; then - ewarn "WARNING: ${RC_LIBEXECDIR} is not writable!" - if ! yesno "${RC_GOINGDOWN}"; then - ewarn "Unable to save deptree cache" + if [ ! -d "$RC_LIBEXECDIR"/cache ]; then + if ! checkpath -W "$RC_LIBEXECDIR"; then + eerror "${RC_LIBEXECDIR} is not writable!" + eerror "Unable to save dependency cache" + if yesno "${RC_GOINGDOWN}"; then + return 0 + fi return 1 fi - return 0 - fi - ebegin "Saving dependency cache" - local rc= - if [ ! -d "$RC_LIBEXECDIR"/cache ]; then rm -rf "$RC_LIBEXECDIR"/cache if ! mkdir -p "$RC_LIBEXECDIR"/cache; then - rc=$? + eerror "Unable to create $RC_LIBEXECDIR/cache" + eerror "Unable to save dependency cache" if yesno "${RC_GOINGDOWN}"; then - rc=0 + return 0 fi - eend $rc "Unable to create $RC_SVCDIR/cache" - return $rc + return 1 + fi + fi + if ! checkpath -W "$RC_LIBEXECDIR"/cache; then + eerror "${RC_LIBEXECDIR}/cache is not writable!" + eerror "Unable to save dependency cache" + if yesno "${RC_GOINGDOWN}"; then + return 0 fi + return 1 fi - local save= + ebegin "Saving dependency cache" + local rc=0 save= for x in deptree depconfig shutdowntime softlevel nettree rc.log; do [ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x" done if [ -n "$save" ]; then - cp -p $save "$RC_LIBEXECDIR"/cache 2>/dev/null + cp -p $save "$RC_LIBEXECDIR"/cache + rc=$? fi - rc=$? if yesno "${RC_GOINGDOWN}"; then - rc=0 + if [ $rc -ne 0 ]; then + eerror "Unable to save dependency cache" + fi + eend 0 fi - eend $rc + eend $rc "Unable to save dependency cache" } diff --git a/init.d/sysfs b/init.d/sysfs index 5dc62cd8..70eaaa9e 100755 --- a/init.d/sysfs +++ b/init.d/sysfs @@ -116,7 +116,7 @@ mount_cgroups() mount -n -t cgroup \ -o none,${sysfs_opts},name=openrc,release_agent="$agent" \ openrc /sys/fs/cgroup/openrc - echo 1 > /sys/fs/cgroup/openrc/notify_on_release + printf 1 > /sys/fs/cgroup/openrc/notify_on_release fi yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0 -- 2.39.5