#!/bin/bash
####################################################################
#
# Copyright (c) 2015-2016 by cisco Systems, Inc.
# All rights reserved.
#####################################################################

# This init script runs /pkg/bin/app_install program, which will install the
# rpms/yum packages from the third-party repo stored on the hard disk.

APP_INSTALL_SCRIPT="/pkg/bin/app_install"
LOG="/var/log/install-apps.log"

case "$1" in
 status)
    pid=(`pidof -x $0`)
    if [ ${#pid[@]}  -gt 1 ]; then
        echo "$0 (pid $pid) is running ..."
    else
        echo "$0 is not running"
    fi
    exit 0
    ;;
esac

test -f $APP_INSTALL_SCRIPT || exit 0

. /etc/init.d/functions

action "Installing third party apps from app-repo" $APP_INSTALL_SCRIPT >& $LOG

if [ "$?" -ne "0" ]; then
    echo "Error occured in installing third party packages from app-repo"
    echo "Please see $LOG for details"
    exit 1
fi

