2 # Copyright (C) 2014 by Benjamin Kaduk
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 # OF THE POSSIBILITY OF SUCH DAMAGE.
29 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
31 # Gather up options and post startup script name, if present
32 if [ -f /etc
/openafs
/afs.conf
]; then
33 .
/etc
/openafs
/afs.conf
36 CACHEINFO
=${CACHEINFO:-/etc/openafs/cacheinfo}
37 MODULEROOT
=${MODULEROOT:-/lib/modules/`uname -r`}
40 cat > /var
/cache
/openafs-client
/openafs-client.env
<<EOF
48 # Exit if the package is not installed.
49 [ -x /sbin
/afsd
] ||
exit 1
51 # Do some other checks for prerequisites
52 if ! [ -f "${CACHEINFO}" ]; then
53 echo "required cacheinfo file does not exist" >&2
56 if ! [ -d "$(awk -F : '{print $1}' < "${CACHEINFO}")" ]; then
57 echo "AFS mountpoint is not a directory or does not exist" >&2
60 if pidof
/sbin
/afsd || pidof
/usr
/sbin
/afsd
; then
61 echo "afsd is already running, continuing" >&2
66 # Ensure that the kernel module is loaded.
67 if ! /sbin
/lsmod |
grep -Fq openafs
; then
71 if [ $status -ne 0 ] ; then
72 echo "Failed to load openafs.ko. Does it need to be built?" >&2
73 # We cannot fail hard on a missing module, though, as that will
74 # cause our unit to be put in a disabled state.
75 if grep -q openafs
"$MODULEROOT/modules.dep"; then
84 # Determine which afsd options to use. /etc/openafs/afs.conf contains the
85 # settings that are checked here.
86 if [ -z "$OPTIONS" ] ||
[ "$OPTIONS" = "AUTOMATIC" ] ; then
87 AFSD_OPTIONS
="$VERBOSE"
89 AFSD_OPTIONS
="$OPTIONS $VERBOSE"
92 # These variables are from /etc/openafs/afs.conf.client and are managed
93 # automatically by debconf.
95 [Yy
][Ee
][Ss
]|
[Tt
][Rr
][Uu
][Ee
])
96 AFSD_OPTIONS
="$AFSD_OPTIONS -afsdb"
98 case "$AFS_DYNROOT" in
99 [Yy
][Ee
][Ss
]|
[Tt
][Rr
][Uu
][Ee
])
100 AFSD_OPTIONS
="$AFSD_OPTIONS -dynroot"
102 [Ss
][Pp
][Aa
][Rr
][Ss
][Ee
])
103 AFSD_OPTIONS
="$AFSD_OPTIONS -dynroot-sparse"
105 case "$AFS_FAKESTAT" in
106 [Yy
][Ee
][Ss
]|
[Tt
][Rr
][Uu
][Ee
])
107 AFSD_OPTIONS
="$AFSD_OPTIONS -fakestat"
111 [Yy
][Ee
][Ss
]|
[Tt
][Rr
][Uu
][Ee
])
118 # Generate an EnvironmentFile for use by systemd.
119 cat > /var
/cache
/openafs-client
/openafs-client.env
<<EOF
120 AFSD_ARGS=${AFSD_OPTIONS}
121 AFS_SETCRYPT=${AFS_SETCRYPT}
122 AFS_SYSNAME=${AFS_SYSNAME}