cachefilesd-3.init 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2014 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. depend() {
  5. need localmount
  6. use logger
  7. before nfsmount
  8. }
  9. checkxattr() {
  10. local testpath testfile ret
  11. # SELinux requires xattrs, so we can assume things work already
  12. [ -f /sys/fs/selinux/status ] && return 0;
  13. testpath=$(awk '/^[[:space:]]*dir/ {print $2}' /etc/cachefilesd.conf)
  14. checkpath -d "${testpath}"
  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. start() {
  26. ebegin "Starting cachefilesd"
  27. checkxattr || return $?
  28. # check if the cachefiles modules is loaded (or builtin)
  29. if [ ! -c /dev/cachefiles ] ; then
  30. local ret
  31. einfo "/dev/cachefiles doesn't exist, trying to modprobe cachefiles"
  32. modprobe cachefiles
  33. ret=$?
  34. if [ $ret -ne 0 ] ; then
  35. eerror "cachefiles modules cannot be loaded so cachefilesd "
  36. eerror "cannot be started, aborting. Did you build fscache in your "
  37. eerror "kernel? Note that you need a 2.6.30 or better kernel"
  38. return $ret
  39. fi
  40. fi
  41. start-stop-daemon --start --pidfile /run/cachefilesd.pid --exec /sbin/cachefilesd -- ${OPTIONS}
  42. eend $? "Failed to start cachefilesd. Check the system log to see the error"
  43. }
  44. stop() {
  45. ebegin "Stopping cachefilesd"
  46. start-stop-daemon --stop --exec /sbin/cachefilesd --pidfile /run/cachefilesd.pid
  47. eend $? "Failed to stop cachefilesd"
  48. }