2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
2015-12-05 04:22:19 +05:30
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
|
|
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2008-11-03 21:01:01 +05:30
|
|
|
|
|
|
|
description="Saves the caches OpenRC uses to non volatile storage"
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
2009-04-27 13:21:18 +05:30
|
|
|
if [ -e "$RC_SVCDIR"/clock-skewed ]; then
|
2015-08-10 19:41:27 +05:30
|
|
|
ewarn "Clock skew detected!"
|
2011-03-06 23:20:06 +05:30
|
|
|
if ! yesno "${RC_GOINGDOWN}"; then
|
2009-01-13 05:23:13 +05:30
|
|
|
eerror "Not saving deptree cache"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-08-10 19:41:27 +05:30
|
|
|
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
|
2012-09-08 05:48:51 +05:30
|
|
|
return 1
|
|
|
|
fi
|
2009-05-24 01:08:12 +05:30
|
|
|
rm -rf "$RC_LIBEXECDIR"/cache
|
2015-04-22 05:26:39 +05:30
|
|
|
if ! mkdir -p "$RC_LIBEXECDIR"/cache; then
|
2015-08-10 19:41:27 +05:30
|
|
|
eerror "Unable to create $RC_LIBEXECDIR/cache"
|
|
|
|
eerror "Unable to save dependency cache"
|
2011-03-06 23:20:06 +05:30
|
|
|
if yesno "${RC_GOINGDOWN}"; then
|
2015-08-10 19:41:27 +05:30
|
|
|
return 0
|
2011-03-06 23:20:06 +05:30
|
|
|
fi
|
2015-08-10 19:41:27 +05:30
|
|
|
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
|
2008-11-03 21:01:01 +05:30
|
|
|
fi
|
2015-08-10 19:41:27 +05:30
|
|
|
return 1
|
2008-11-03 21:01:01 +05:30
|
|
|
fi
|
2015-08-10 19:41:27 +05:30
|
|
|
ebegin "Saving dependency cache"
|
|
|
|
local rc=0 save=
|
2016-09-09 21:42:32 +05:30
|
|
|
for x in shutdowntime softlevel rc.log; do
|
2009-04-27 13:21:18 +05:30
|
|
|
[ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x"
|
2008-11-03 21:01:01 +05:30
|
|
|
done
|
2009-04-27 13:21:18 +05:30
|
|
|
if [ -n "$save" ]; then
|
2015-08-10 19:41:27 +05:30
|
|
|
cp -p $save "$RC_LIBEXECDIR"/cache
|
|
|
|
rc=$?
|
2008-11-03 21:01:01 +05:30
|
|
|
fi
|
2011-03-06 23:20:06 +05:30
|
|
|
if yesno "${RC_GOINGDOWN}"; then
|
2015-08-10 19:41:27 +05:30
|
|
|
if [ $rc -ne 0 ]; then
|
|
|
|
eerror "Unable to save dependency cache"
|
|
|
|
fi
|
|
|
|
eend 0
|
2011-03-06 23:20:06 +05:30
|
|
|
fi
|
2015-08-10 19:41:27 +05:30
|
|
|
eend $rc "Unable to save dependency cache"
|
2008-11-03 21:01:01 +05:30
|
|
|
}
|