#!/sbin/runscript # Copyright 2003 Clement Siu-Chung Cheung (sccheung at umich dot edu) # Distributed under the terms of the GNU General Public License v2 # available at http://www.gnu.org/copyleft/gpl.html arla_dir=${arla_dir:-/usr/arla} bin_dir=${bin_dir:-${arla_dir}/bin} etc_dir=${etc_dir:-${arla_dir}/etc} cache_dir=${cache_dir:-/var/spool/afs} depend() { need net provide afs } checkconfig() { if [ ! -f ${etc_dir}/arla.conf ]; then eerror "/etc/arla/arla.conf is missing" return 1 fi if [ ! -f ${etc_dir}/ThisCell ]; then eerror "/etc/arla/ThisCell is missing" return 1 fi if [ ! -f ${etc_dir}/CellServDB ]; then eerror "/etc/arla/CellServDB is missing" return 1 fi return 0 } start() { checkconfig || return $? if lsmod|grep nnpfs > /dev/null 2>&1; then einfo "Arla kernel module already loaded" else ebegin "Loading Arla kernel module" insmod ${bin_dir}/nnpfs.o if [ "$?" != '0' ]; then eend 1 "Failed to load Arla kernel module" return 1 else eend 0 fi # Give it some time to take effect sleep 1 fi if [ ! -r /dev/nnpfs0 ]; then einfo "Creating device..." mknod /dev/nnpfs0 c 103 0 fi chmod 600 /dev/nnpfs0 if [ ! -e ${cache_dir} ] ; then einfo "Creating cache directory..." mkdir ${cache_dir} chmod 700 ${cache_dir} chown root ${cache_dir} fi ebegin "Starting arlad" start-stop-daemon --start --quiet --exec ${arla_dir}/libexec/arlad if [ "$?" != "0" ]; then eend 1 "Failed to start arlad" return 1 else eend 0 fi if [ ! -r /afs ] ; then einfo "Creating /afs..." mkdir /afs fi # wait for arlad to completely start sleep 3 ebegin "Mounting AFS" mount -t nnpfs /dev/nnpfs0 /afs eend $? "Failed to mount AFS" } stop() { ebegin "Unmounting AFS" umount /afs eend 0 ebegin "Stopping arlad" start-stop-daemon --stop --quiet --pidfile /var/run/arlad.pid if [ -r /var/run/arlad.pid ]; then eend $? "Failed to stop arlad with PID="`cat /var/run/arlad.pid > /dev/null 2>&1` else eerror "Can't find PID file for arlad." eerror "arlad probably has not been started successfully or somehow died already!" # don't eend 1. Otherwise, the user won't be able to stop this # daemon when things goes wrong. If We're asked to stop it and # it doesn't exist, the record must be wrong. So just let is # succeed and reset the status back to "stoped", which is what # it should be. eend 0 fi ebegin "Unoading Arla kernel module" rmmod nnpfs if [ "$?" != "0" ]; then # It's fine to fail. The AFS has already stopped. No need to eend 1. eend 1 "Failed to unload Arla kernel module" else eend 0 fi }