#!/usr/bin/bash

VC_PLUGIN_DIR=/var/cpanel/plugins/monitoring
PLUGINS_RESOURCES_DIR=/usr/local/cpanel/whostmgr/docroot/addon_plugins

# Check for and create the directory for plugin and AppConfig files.
VC_APPS_DIR=/var/cpanel/apps
if [ ! -d "$VC_APPS_DIR" ]; then
    mkdir "$VC_APPS_DIR"
    chmod 755 "$VC_APPS_DIR"
fi

# TODO: Do we need this still??? or is the RPM handling this now.
TEMPLATES_DIR=/usr/local/cpanel/whostmgr/docroot/templates/monitoring
# Check for and create the directory for plugin template files.
if [ ! -d $TEMPLATES_DIR ]
  then
    mkdir $TEMPLATES_DIR
    chmod 755 $TEMPLATES_DIR
fi

# Register the plugin with AppConfig.
/usr/local/cpanel/bin/register_appconfig $VC_PLUGIN_DIR/whm-360-monitoring.conf

# Copy plugin files to their locations and update permissions.
/bin/cp $VC_PLUGIN_DIR/whm-360-monitoring.svg $PLUGINS_RESOURCES_DIR
