GIF89a;
Direktori : /usr/share/ |
Current File : //usr/share/av-userside-plugin.sh |
#!/bin/bash directadmin_plugin="/usr/local/directadmin/plugins/Imunify" cpanel_plugin="/usr/local/cpanel/base/frontend/jupiter/imunify" userside_plugin_flag="/var/imunify360/av-userside-plugin.installed" # get the name of installed panel get_panel() { if [ -e /usr/local/cpanel/cpanel ]; then echo "cpanel" elif [ -e /usr/local/directadmin/directadmin ]; then echo "directadmin" else return 1 fi } panel=$(get_panel) # install user-side plugin install() ( cpanel() { for theme in $(ls -d /usr/local/cpanel/base/frontend/*/ | sed 's|/usr/local/cpanel/base/frontend/||g' | sed 's/\/$//'); do if [ "${theme}" != "jupiter" ]; then mkdir -p "/usr/local/cpanel/base/frontend/${theme}/imunify" cp -a ${cpanel_plugin} "/usr/local/cpanel/base/frontend/${theme}" fi /usr/local/cpanel/scripts/install_plugin /etc/sysconfig/imunify360/cpanel/antivirus_conf --theme "${theme}" done } directadmin() { local enabled_plugin="${directadmin_plugin}/user" local disabled_plugin="${directadmin_plugin}/.user" if [ -d "${disabled_plugin}" ] && [ ! -z "$(ls -A "${disabled_plugin}")" ]; then rm -rf "${enabled_plugin}" mv "${disabled_plugin}" "${enabled_plugin}" fi } touch ${userside_plugin_flag} ${panel} ) # remove user-side plugin remove() ( cpanel() { for theme in $(ls -d /usr/local/cpanel/base/frontend/*/ | sed 's|/usr/local/cpanel/base/frontend/||g' | sed 's/\/$//'); do /usr/local/cpanel/scripts/uninstall_plugin /etc/sysconfig/imunify360/cpanel/antivirus_conf --theme "${theme}" rm -rf "/usr/local/cpanel/base/frontend/${theme}/imunify" done } directadmin() { local enabled_plugin="${directadmin_plugin}/user" local disabled_plugin="${directadmin_plugin}/.user" if [ -d "${enabled_plugin}" ] && [ ! -z "$(ls -A "${enabled_plugin}")" ]; then rm -rf "${disabled_plugin}" mv "${enabled_plugin}" "${disabled_plugin}" fi } rm -f ${userside_plugin_flag} ${panel} ) # update user-side plugin update() ( cpanel() { if [ -e ${userside_plugin_flag} ]; then install else echo "User-side plugin is not installed. Skipping update..." fi } directadmin() { if [ ! -e ${userside_plugin_flag} ] && [ -e "${directadmin_plugin}/user" ]; then remove fi } ${panel} ) # update user-side plugin config.js update_package_config() ( cpanel() { for theme in $(ls -d /usr/local/cpanel/base/frontend/*/ | sed 's|/usr/local/cpanel/base/frontend/||g' | sed 's/\/$//'); do theme_path="/usr/local/cpanel/base/frontend/${theme}/imunify/assets/js/config.js" if [ -f ${theme_path} ]; then if ! grep -q "IMUNIFY_PACKAGE" ${theme_path}; then echo "var IMUNIFY_PACKAGE = '360'" > ${theme_path} else sed -i -E "s/IMUNIFY_PACKAGE = 'AV'/IMUNIFY_PACKAGE = '360'/" ${theme_path} fi fi done } directadmin() { install } ${panel} ) if ! get_panel >/dev/null; then echo "No supported panel detected" exit 0 fi case "${1}" in "-r") remove ;; "-u") update ;; "-update-package") update_package_config ;; "") install ;; *) echo "Unrecognized option: ${1}" exit 1 esac