~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to etc/init.d/savecache

  • Committer: Dimitri John Ledkov
  • Date: 2014-05-06 18:45:46 UTC
  • Revision ID: dimitri.ledkov@canonical.com-20140506184546-5toyx56xxrue0f0v
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/sbin/openrc-run
2
 
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
3
 
# Released under the 2-clause BSD license.
4
 
 
5
 
description="Saves the caches OpenRC uses to non volatile storage"
6
 
 
7
 
start()
8
 
{
9
 
        if [ -e "$RC_SVCDIR"/clock-skewed ]; then
10
 
                ewarn "WARNING: clock skew detected!"
11
 
                if ! yesno "${RC_GOINGDOWN}"; then
12
 
                        eerror "Not saving deptree cache"
13
 
                        return 1
14
 
                fi
15
 
        fi
16
 
        if ! checkpath -W "$RC_LIBEXECDIR"; then
17
 
                ewarn "WARNING: ${RC_LIBEXECDIR} is not writable!"
18
 
                if ! yesno "${RC_GOINGDOWN}"; then
19
 
                        ewarn "Unable to save deptree cache"
20
 
                        return 1
21
 
                fi
22
 
                return 0
23
 
        fi
24
 
        ebegin "Saving dependency cache"
25
 
        local rc=
26
 
        if [ ! -d "$RC_LIBEXECDIR"/cache ]; then
27
 
                rm -rf "$RC_LIBEXECDIR"/cache
28
 
                if ! mkdir "$RC_LIBEXECDIR"/cache; then
29
 
                        rc=$?
30
 
                        if yesno "${RC_GOINGDOWN}"; then
31
 
                                rc=0
32
 
                        fi
33
 
                        eend $rc
34
 
                        return $rc
35
 
                fi
36
 
        fi
37
 
        local save=
38
 
        for x in deptree depconfig shutdowntime softlevel nettree rc.log; do
39
 
                [ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x"
40
 
        done
41
 
        if [ -n "$save" ]; then
42
 
                cp -p $save "$RC_LIBEXECDIR"/cache 2>/dev/null
43
 
        fi
44
 
        rc=$?
45
 
        if yesno "${RC_GOINGDOWN}"; then
46
 
                rc=0
47
 
        fi
48
 
        eend $rc
49
 
}