#!/bin/sh
# This script is run after the package files are transferred to @appstore

# Run Archiware P5 auto installation script
#/var/packages/ArchiwareP5/target/install.sh lexxsrv 20000

# Volume where package is installed
PKG_VOLUME=$SYNOPKG_PKGDEST_VOL
# Target directory where the P5 package is installed.
INSTALL_DIR=$SYNOPKG_PKGDEST
# Package name
PACKAGE_NAME=$SYNOPKG_PKGNAME

# The backup directory
BACKUP_DIR="$PKG_VOLUME/@p5_backup"

# Diretories to copy back
CONFIG_DIR="$BACKUP_DIR/config"
LOG_DIR="$BACKUP_DIR/log"


if [ -d "$BACKUP_DIR" ]; then
    # Copy configuration and log folders back to place
    exit_msg=$( cp -fR $CONFIG_DIR $LOG_DIR $INSTALL_DIR )
    exit_stat=${?}
    if [ "$exit_stat" -ne "0" ]; then
        echo "Error occured during restoring configuration files! Please try again!" > $SYNOPKG_TEMP_LOGFILE
        exit 1
    fi
fi

exit 0
