#!/bin/bash

. ./param_bash.ini

if [ ! -w /etc/passwd ] ; then
   ERROR "Please run the script as root user only" "ikit_2_6"
fi

#############################creating /exlibris/dps #########################
if [ ! -d ${APP_HOME} ] ; then
    mkdir -p ${APP_HOME}
    chown ${MAIN_USER}:${GROUP} ${APP_HOME} > /dev/null 2>&1
    if [ -d ${APP_HOME} ] ; then
        INFORM "Directory ${APP_HOME} successfully created."
    fi
else
    INFORM "Directory ${APP_HOME} already exist."
fi
########################creating /exlibris/dps/ora_dps##################
if [ ! -d ${APP_HOME}/ora_${MAIN_PRODUCT} ] ; then
    mkdir -p ${APP_HOME}/ora_${MAIN_PRODUCT}
    chown ${MAIN_USER}:${GROUP} ${APP_HOME}/ora_${MAIN_PRODUCT} > /dev/null 2>&1
    if [ -d ${APP_HOME}/ora_${MAIN_PRODUCT} ] ; then
        INFORM "Directory ${APP_HOME}/ora_${MAIN_PRODUCT} successfully created."
    fi
else
    INFORM "Directory ${APP_HOME}/ora_${MAIN_PRODUCT} already exist."
fi
########################creating /exlibris/dps/backup_temp##################
if [ ! -d ${APP_HOME}/backup_temp ] ; then
    mkdir -p ${APP_HOME}/backup_temp
    chown ${MAIN_USER}:${GROUP} ${APP_HOME}/backup_temp > /dev/null 2>&1
    if [ -d ${APP_HOME}/backup_temp ] ; then
        INFORM "Directory ${APP_HOME}/backup_temp successfully created."
    fi
else
    INFORM "Directory ${APP_HOME}/backup_temp already exist."
fi
########################creating /exlibris/tmp#################################
if [ ! -d ${TMP} ] ; then
    mkdir -p ${TMP}
    chown ${MAIN_USER}:${GROUP} ${TMP} > /dev/null 2>&1
    chmod 777 ${TMP} > /dev/null 2>&1
    if [ -d ${TMP} ] ; then
        INFORM "Directory ${TMP} successfully created."
    fi
else
    INFORM "Directory ${TMP} already exist."
fi
########################creating /exlibris/startup#############################
if [ ! -d ${BASE}/startup ] ; then
    mkdir -p ${BASE}/startup
    chown ${MAIN_USER}:${GROUP} ${BASE}/startup > /dev/null 2>&1
    chmod 755 ${BASE}/startup > /dev/null 2>&1
    if [ -d ${TMP} ] ; then
        INFORM "Directory ${BASE}/startup successfully created."
    fi
else
    chown ${MAIN_USER}:${GROUP} $STARTUP > /dev/null 2>&1
    INFORM "Directory ${BASE}/startup already exist."
fi
########################creating /exlibris/product#############################
if [ ! -d ${PRODUCT} ] ; then
    mkdir -p ${PRODUCT}
    chown ${MAIN_USER}:${GROUP} ${PRODUCT} > /dev/null 2>&1
    if [ -d ${PRODUCT} ] ; then
        INFORM "Directory ${PRODUCT} successfully created."
    fi
else
    INFORM "Directory ${PRODUCT} already exist."
fi
###################delete oracle file from previous inst#######################
if [ -f /tmp/is_user ] ; then 
    rm -f /tmp/is_user > /dev/null 2>&1
fi
###############################################################################
chown -R ${MAIN_USER}:${GROUP} $IKIT_DIR > /dev/null 2>&1
chmod -R 777 $IKIT_DIR
chown ${MAIN_USER}:${GROUP} $IKIT_FTP_DIR > /dev/null 2>&1
exit 0
###############################################################################
