#!/bin/bash

PVA_MN_CORE=0

scriptDir=`dirname "$0"`
. ${scriptDir}/pva-agent-helper.sh

# Stopping PVA agent
pvaagent stop

# Create "/vz/backups directory"
mkdir -p /vz/backups || abort "Can't create backup storage directory"

# Create links in old vzagent directory required for vzreport utility
mkdir -p /opt/vzagent/bin
ln -sf ${VZLCORE_BIN_DIR}/pvaprintreport.sh /opt/vzagent/bin/vzagentInfoReport.sh
ln -sf ${VZLCORE_BIN_DIR}/pvareport.sh /opt/vzagent/bin/vzagentCollectReport.sh

# Create links in old vzagent directory required for vzmigrate utility
mkdir -p /opt/vzagent/lib
ln -sf ${VZLCORE_LIB_DIR}/libVZLBackup.so /opt/vzagent/lib/libVZLBackup.so
ln -sf ${VZLCORE_LIB_DIR}/libVZLConnection.so /opt/vzagent/lib/libVZLConnection.so

# Create links in old vzagent directory required for repair containers
mkdir -p /var/vzagent/etc
ln -sf ${VZLCORE_ETC_DIR}/repair /var/vzagent/etc/repair

# Make notification script symlink
mkdir -p /usr/share/vzbackup/actions
ln -sf ${VZLCORE_BIN_DIR}/vzbackupsync /usr/share/vzbackup/actions/notify_vzagent

# Starting PVA agent
pvaagent start

