#!/bin/bash
# ncs_iprint_svc_start
# file version 1.0.1

# -----------------------------------------------------------------
# NOTE: Do not return FAILURE '1' on warnings. 
# This will cause the cluster resource to go comatose on a warning.
# -----------------------------------------------------------------

LOG_PATH='/var/opt/novell/log/iprint_svc_start.err'
IPRINT_ETC=/etc/opt/novell/iprint/conf

# Initialize Log file.
echo ${DATE} | tee "${ERR_LOG}"
echo "Running ncs_iprint_svc_start" | tee -a "$LOG_PATH"

# Checking files & permissions
# The following file permissions are not set in the iprint_relocate script.
# -------------------------------------------------------------------------
echo "Checking files & permissions." | tee -a "$LOG_PATH"
# FCS requires the next two lines for backward compatability.
rm /var/opt/novell/iprint/ipc/*   # delete anything in this directory
chown -R iprint.www     /var/opt/novell/iprint/ipc
# All versions require remaining permission settings.
chown -R wwwrun.www		/var/opt/novell/iprint/mod_ipp
chown -R iprint.iprint	/var/opt/novell/iprint/*.psm

# Start the iPrint driver store
# -----------------------------
if [ -f "$IPRINT_ETC"/idsd.conf ] ; then
   /usr/bin/systemctl start novell-idsd.service
   if [ $? != 0 ] ; then
      echo "WARNING: Could not start idsd daemon." | tee -a "$LOG_PATH"
   fi
else
   echo "WARNING: idsd.conf missing - idsd daemon was not started" | tee -a "$LOG_PATH"
fi

# Start the iPrint printer manager
# --------------------------------
if [ -f "$IPRINT_ETC"/ipsmd.conf ] ; then
    /usr/bin/systemctl start novell-ipsmd.service
   if [ $? != 0 ] ; then
      echo "FAILURE: Could not start ipsmd daemon." | tee -a "$LOG_PATH"
		exit 1
   fi
else
   echo "WARNING: ipsmd.conf missing - ipsmd daemon was not started" | tee -a "$LOG_PATH"
fi

echo "ncs-iprint-res-start exit code = 0" | tee -a "$LOG_PATH"
exit 0 


