#!/bin/bash

cpver=$(cat /usr/local/cpanel/version)
cpver_maj=${cpver%%.*}
cpver_min=${cpver#*.}
cpver_min=${cpver_min%%.*}
if [[ ${cpver_maj} -ge 11 ]] ; then
    if [[ ${cpver_min} -lt 44 ]] ; then
        echo -e "Executing register_cpanelplugin...."
        /usr/local/cpanel/bin/register_cpanelplugin $CPANEL/3rdparty/quickinstall/quickinstall.cpanelplugin
    elif [[ ${cpver_min} -ge 44 ]] ; then
        echo -e "Executing install_plugin for Paper Lantern theme...."
        /usr/local/cpanel/scripts/install_plugin /usr/local/cpanel/3rdparty/quickinstall/plugin_quickinstall.pl.tar.bz2 --theme paper_lantern
        for theme in x3 x rvskin rvskinlight rvneo bluehost hostmonster justhost; do
            if [[ -d /usr/local/cpanel/base/frontend/${theme} ]] ; then
                echo -e "Executing install_plugin...."
                /usr/local/cpanel/scripts/install_plugin /usr/local/cpanel/3rdparty/quickinstall/plugin_quickinstall.x3.tar.bz2 --theme ${theme}
            fi
        done
    fi
fi
echo -e "Executing rebuild_sprites...."
/usr/local/cpanel/bin/sprite_generator --all
if [[ -d /var/cpanel/customizations/styled/hostgator ]]; then
  /usr/local/cpanel/bin/sprite_generator --all --style hostgator
fi
