#!/bin/sh
#
# $Id: isi_post_network 329266 2013-06-27 00:26:24Z cjohnson $
# stuff to do after network, but before IFS is mounted

# Copyright C 2002-2003 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

# PROVIDE: isi_post_network
# REQUIRE: NETWORKING isi_configwatch
 
. /etc/rc.subr

name="isi_post_network"
start_cmd="isi_post_network_start"

isi_post_network_start()
{
    echo -n "Pre-IFS daemons:"

    # Start isi_watchdog_d
    case ${isi_watchdog_enable} in
    [Yy][Ee][Ss])
	    ${isi_watchdog_program:-/usr/bin/isi_watchdog_d}
	    echo -n ' isi_watchdog_d'
	    ;;
    esac

    # Start isi_hangdump
    /usr/bin/isi_hangdump start
    echo -n ' isi_hangdump'

    # Assign the password for the Remote Support user
    REMOTE_SUPPORT_USER=remotesupport
    if grep -q "${REMOTE_SUPPORT_USER}:\*:" /etc/master.passwd; then
        /usr/sbin/isi_generate_remote_support_password | pw user mod "${REMOTE_SUPPORT_USER}" -h 0
    fi

    # We should have our large MTU routes configured before IFS comes up.
    case ${isi_eth_mixer_enable} in
    [Yy][Ee][Ss])
	    ${isi_eth_mixer_program:-/usr/bin/isi_eth_mixer_d} start > /dev/null 2>&1
	    echo -n ' isi_eth_mixer_d'
	    # TODO:  verify whether ethmixer configures routes before forking.
	    ;;
    esac
    
    # isi_flexnet_d is smart enough to use a local copy of the config file
    # if it can't reach the one on /ifs. Start isi_flexnet_d right after
    # the network is brought up so applications can talk over the external
    # networks as early as possible.
    case ${isi_flexnet_enable} in
    [Yy][Ee][Ss])
	    ${isi_flexnet_program:-/usr/sbin/isi_flexnet_d}
	    echo -n ' isi_flexnet_d'
	    ;;
    esac

    #
    # Make sure we have the files telling us what we need to preserve for an
    # update.
    #
    #if [ ! -f /etc/ifs/patchmgr/files_to_preserve ] ||\
    #   [ ! -f /etc/ifs/patchmgr/files_to_discard ]; then
    #	echo "Setting up conditions for updates"
    #	/usr/libdata/patchmgr/preserve-user-changes NULL /
    #fi
    
    # Make sure sshd configuration is there
    /etc/mcp/scripts/generic_copy.py /etc/mcp/templates/sshd_config /etc/ssh/sshd_config

    # Make sure vsftpd configuration is there
    /etc/mcp/scripts/vsftpd.py /etc/mcp/sys/vsftpd_config.xml /etc/mcp/override/vsftpd_config.xml /etc/mcp/templates/vsftpd.conf /usr/local/etc/vsftpd.conf

    # done with the echo -n lines:
    echo '.'
}

load_rc_config $name
run_rc_command "$1"
