#!/bin/sh

# Copyright C 2002-2013 by Isilon Systems LLC. 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.

# This script should be run only from isi_post_ifs and all commands run
# in it must be idempotent, as a failure could occur midway through execution
# and this script will be re-run during the next boot.

# Pre-conditions: ifs is mounted, node has quorum, /ifs/.ifsvar is created

if [ -f /usr/libdata/patchmgr/jaws_je_phase2_upgrade ]; then
    # Post upgrade JE script to enable new jobs
    /usr/libdata/patchmgr/jaws_je_phase2_upgrade
fi

# Post upgrade NFS script to disable continuous config updates
if [ -f /usr/libdata/patchmgr/moby-nfs-upgrade ]; then
    /usr/libdata/patchmgr/moby-nfs-upgrade --cleanup
fi

if [ -f /usr/libdata/patchmgr/jaws-smb-upgrade ]; then
    # Post upgrade cleanup of old SMB config
    /usr/libdata/patchmgr/jaws-smb-upgrade -d
fi

if [ -f /usr/libdata/patchmgr/purposedb-upgrade ]; then
    # Fully Upgrade the drive_purpose_db
    /usr/libdata/patchmgr/purposedb-upgrade
fi

if [ -f /usr/libdata/patchmgr/smartpools-upgrade ]; then
    # SmartPools upgrade post steps.
    /usr/libdata/patchmgr/smartpools-upgrade -p
fi

if [ -f /usr/sbin/isi_auth_upgrade ]; then
    # Upgrade to zonified id map
    /usr/sbin/isi_auth_upgrade --idmap
fi

if [ -f /usr/libdata/patchmgr/moby_audit_nfs_upgrade ]; then
    # Post upgrade turns on NFS auditing if SMB auditing is enabled
    /usr/libdata/patchmgr/moby_audit_nfs_upgrade
fi
