#!/bin/bash
# Ahsay Offsite Backup Server and Replication Server 
# Version: 5.5.1.0

# $1 is the PKG path
PKG_HOME=$1

###############################################################################
#       D E F I N E          D E P L O Y M E N T       C O N S T A N T S      #
###############################################################################

# Define APP_NAME for current installation
APP_NAME="Ahsay Offsite Backup Server and Replication Server"

# Define APP_HOME for current installation
APP_HOME="/Applications/AhsayOBS and AhsayRPS"

# Define SERVICE_NAME for current installation
SERVICE_NAME="AhsayOBS and AhsayRPS"

# Define PKG_NAME for current installation
PKG_NAME="obsr.pkg"

###############################################################################
#       D E F I N E         F R A M E W O R K       P R O C E D U R E         #
###############################################################################

# Use customized procedure to cleanup before installing the software
# The "/Applications/AhsayOBS and AhsayRPS" path
# and "/Library/StartupItems/AhsayOBS and AhsayRPS" path
# must be cleaned up before installation

TIMESTAMP_LOG="`date "+%y%m%d%H%M%S"`"
CLEANUP_LOG="/Applications/${PKG_NAME}-cleanup-${TIMESTAMP_LOG}.log"

sh "${PKG_HOME}/Contents/Resources/custom-cleanup" "${PKG_HOME}" "${TIMESTAMP_LOG}" >> "${CLEANUP_LOG}"