Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / afsd / afs.rc.fbsd
CommitLineData
805e021f
CE
1#!/bin/sh
2#
3# PROVIDE: afsd
4# REQUIRE: named
5# KEYWORD: shutdown
6#
7# Symlink from /usr/local/etc/rc.d/afsd to /usr/vice/etc/afs.rc.fbsd
8# and add the following lines to /etc/rc.conf.local or /etc/rc.conf
9# to enable this service:
10#
11# afsd_enable (bool): Set to NO by default.
12# Set it to YES to enable afsd.
13#
14# Suggested values for a "large" configuration:
15# afsd_flags="-stat 2800 -daemons 5 -volumes 128"
16#
17# Suggested values for a "medium" configuration:
18# afsd_flags="-stat 2000 -daemons 3 -volumes 70"
19#
20# Suggested values for a "small" configuration:
21# afsd_flags="-stat 300 -daemons 2 -volumes 50"
22
23. /etc/rc.subr
24
25name="afsd"
26rcvar="afsd_enable"
27
28command="/usr/vice/etc/afsd"
29command_args="-dynroot -fakestat-all -afsdb -memcache"
30
31start_precmd="afsd_prestart"
32start_postcmd="afsd_poststart"
33stop_cmd="afsd_stop"
34
35kmod="libafs"
36vicedir="/usr/vice/etc"
37required_modules="libafs:afs"
38required_files="${vicedir}/cacheinfo ${vicedir}/ThisCell ${vicedir}/CellServDB"
39
40load_rc_config "$name"
41
42: ${afsd_enable:="NO"}
43: ${afsd_flags:="-stat 2800 -daemons 6 -volumes 128"}
44
45afsd_prestart()
46{
47 local dir
48
49 # need a mountpoint and a cache dir (well, if we have a disk cache)
50 # Should use required_dirs, but no good way to extract from cacheinfo
51 for dir in $(awk -F: '{print $1, $2}' ${vicedir}/cacheinfo); do
52 if [ ! -d "${dir}" ]; then
53 err 1 "Directory ${dir} does not exist. Not starting AFS client."
54 fi
55 done
56}
57
58afsd_poststart()
59{
60 /usr/local/bin/fs setcrypt -crypt on
61}
62
63afsd_stop()
64{
65 local afsdir
66
67 afsdir=$(awk -F: '{print $1}' ${vicedir}/cacheinfo)
68 if ! umount $afsdir; then
69 [ -n "${rc_force}" ] && umount -f ${afsdir}
70 fi
71 kldunload ${kmod}
72}
73
74run_rc_command "$1"