Unbreak make dest for FBSD
[openafs.git] / src / afsd / afs.rc.fbsd
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
25 name="afsd"
26 rcvar="afsd_enable"
27
28 command="/usr/vice/etc/afsd"
29 command_args="-dynroot -fakestat-all -afsdb -memcache"
30
31 start_precmd="afsd_prestart"
32 start_postcmd="afsd_poststart"
33 stop_cmd="afsd_stop"
34
35 kmod="libafs"
36 vicedir="/usr/vice/etc"
37 required_modules="libafs:afs"
38 required_files="${vicedir}/cacheinfo ${vicedir}/ThisCell ${vicedir}/CellServDB"
39
40 load_rc_config "$name"
41
42 : ${afsd_enable:="NO"}
43 : ${afsd_flags:="-stat 2800 -daemons 6 -volumes 128"}
44
45 afsd_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
58 afsd_poststart()
59 {
60         /usr/local/bin/fs setcrypt -crypt on
61 }
62
63 afsd_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
74 run_rc_command "$1"