| 1 | #!/sbin/openrc-run |
| 2 | # Copyright 1999-2010 Gentoo Foundation |
| 3 | # Distributed under the terms of the GNU General Public License v2 |
| 4 | # $Header: /var/cvsroot/gentoo-x86/sys-fs/cachefilesd/files/cachefilesd.init,v 1.2 2010/09/20 08:45:22 jlec Exp $ |
| 5 | |
| 6 | depend() { |
| 7 | need localmount |
| 8 | use logger |
| 9 | before nfsmount |
| 10 | } |
| 11 | |
| 12 | checkxattr() { |
| 13 | local testpath testfile ret |
| 14 | testpath=$(awk '/^[[:space:]]*dir/ {print $2}' /etc/cachefilesd.conf) |
| 15 | testfile="${testpath}/.tmp-xattr-test.cachefilesd" |
| 16 | touch "${testfile}" |
| 17 | # creates a file in the testpath and tries to set an attribute on it to check |
| 18 | # if the support is available |
| 19 | attr -s test -V xattr "${testfile}" 2>&1 > /dev/null |
| 20 | ret=$? |
| 21 | rm -f "${testfile}" |
| 22 | [ ${ret} -ne 0 ] && eerror "xattr support missing on the ${testpath} filesystem" |
| 23 | return ${ret} |
| 24 | } |
| 25 | |
| 26 | start() { |
| 27 | ebegin "Starting cachefilesd" |
| 28 | checkxattr || return $? |
| 29 | # check if the cachefiles modules is loaded (or builtin) |
| 30 | if [ ! -c /dev/cachefiles ] ; then |
| 31 | local ret |
| 32 | einfo "/dev/cachefiles doesn't exist, trying to modprobe cachefiles" |
| 33 | modprobe cachefiles |
| 34 | ret=$? |
| 35 | if [ $ret -ne 0 ] ; then |
| 36 | eerror "cachefiles modules cannot be loaded so cachefilesd " |
| 37 | eerror "cannot be started, aborting. Did you build fscache in your " |
| 38 | eerror "kernel? Note that you need a 2.6.30 or better kernel" |
| 39 | return $ret |
| 40 | fi |
| 41 | fi |
| 42 | start-stop-daemon --start --pidfile /var/run/cachefilesd.pid --exec /usr/bin/cachefilesd -- ${OPTIONS} |
| 43 | eend $? "Failed to start cachefilesd. Check the system log to see the error" |
| 44 | |
| 45 | } |
| 46 | |
| 47 | stop() { |
| 48 | ebegin "Stopping cachefilesd" |
| 49 | start-stop-daemon --stop --exec /usr/bin/cachefilesd --pidfile /var/run/cachefilesd.pid |
| 50 | eend $? "Failed to stop cachefilesd" |
| 51 | } |
| 52 | |
| 53 | |