#!/bin/bash
#
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../coda/coda-utils.init
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
#
# Desc: The CODA filesystem helper utility daemons
# Runlevel: 30 rcX
#
# (C) FEB 2002 by René Rebe <rene.rebe@gmx.net>
#

if [ "$(cat /vice/hostname)" == "$(cat /vice/db/scm)" ]; then
	IS_SCM=yes
fi

main_begin

    block_begin(start, `starting CODA helper utilities (auth2, rpc2, ...)')
	if [ "$IS_SCM" == "yes" ]; then
	    check(`/opt/coda/sbin/auth2 -chk')
	    check(`/opt/coda/sbin/rpc2portmap')
	    check(`/opt/coda/sbin/updatesrv')
	else
	    check(`/opt/coda/sbin/auth2')
	fi
	    check(`/opt/coda/sbin/updateclnt -h $(cat /vice/db/scm)')
    block_end

    block_begin(stop, `stopping CODA helpers utilities (auth2, rpc2, ...)')
	if [ "$IS_SCM" == "yes" ]; then
	    check(`killall -9 rpc2portmap')
	    check(`killall -9 updatesrv')
	    check(`killall -9 auth2')
	fi
	check(`killall -9 updateclnt')
    block_end

main_end