diff options
author | Doug Freed <dwfreed@mtu.edu> | 2015-08-10 14:11:27 +0000 |
---|---|---|
committer | Doug Freed <dwfreed@mtu.edu> | 2015-08-10 14:51:15 +0000 |
commit | c256a7aa80c683eca6194c80b57294e4d51c9a16 (patch) | |
tree | cf84ea394277c4e2d630b3423528af1ca95ff4e9 /init.d/savecache.in | |
parent | 6a422982579786cb8308af04ccca6622afa06e50 (diff) |
savecache: clean up implementation
X-Gentoo-Bug: 557222
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=557222
Diffstat (limited to 'init.d/savecache.in')
-rw-r--r-- | init.d/savecache.in | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/init.d/savecache.in b/init.d/savecache.in index e185e5a4..5ec1028b 100644 --- a/init.d/savecache.in +++ b/init.d/savecache.in @@ -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_LIBEXECDIR/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" } |