HEX
Server: nginx/1.18.0
System: Linux hqnl0246134.online-vm.com 5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: phpinfo,disk_free_space,disk_total_space,diskfreespace,dl,exec,opcache_get_configuration,opcache_get_status,passthru,pclose,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_waitpid,pcntl_wait,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,show_source,system,exec,passthru,shell_exec,system,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
Upload Files
File: /var/lib/dpkg/info/imunify-ui-generic.postinst
#!/bin/bash
# postinst script for imunify-antivirus-generic

set -e

is_imunify360_installed()
{
    test -f /var/imunify360/.i360
    return $?
}

update_config(){
    config_path=$1
    if is_imunify360_installed ; then
        sed -i -E "s/IMUNIFY_PACKAGE = 'AV'/IMUNIFY_PACKAGE = '360'/" "${config_path}"
        /usr/share/av-userside-plugin.sh -update-package
    else
        sed -i -E "s/IMUNIFY_PACKAGE = '360'/IMUNIFY_PACKAGE = 'AV'/" "${config_path}"
    fi
}

case "$1" in
    configure)
        generic_folder=/var/imunify360/generic
        generic_integration_config=/etc/sysconfig/imunify360/integration.conf
        generic_ui_path=$(\
            cat $generic_integration_config | /opt/imunify360/venv/bin/python3 -c 'import sys, configparser, pathlib; config = configparser.ConfigParser(); config.read_file(sys.stdin); p = pathlib.Path(config.get("paths", "ui_path", fallback="")); print(p if p.is_absolute() else "")' \
        )

        generic_ui_path_owner=$(\
            cat $generic_integration_config | /opt/imunify360/venv/bin/python3 -c 'import sys, configparser; config = configparser.ConfigParser(); config.read_file(sys.stdin); print(config.get("paths", "ui_path_owner", fallback=""))' \
        )

        if [ -z "${generic_ui_path}" ]; then
            echo "ERROR: could not get ui_path from ${generic_integration_config}. UI will not be installed."
            exit 0
        fi
        if [ ! -d ${generic_ui_path} ]; then
            echo "ERROR: ${generic_ui_path} is not a directory (it should be created by the imunify deploy script). UI will not be installed."
            exit 0
        fi

        mkdir -p -m 0700 $generic_ui_path.unzipped
        unzip -o "${generic_folder}/imunify-plugin.zip" -d "${generic_ui_path}.unzipped"
        generic_old_path="$generic_ui_path.old.$(date +%s)"
        mkdir -p -m 0700 $generic_old_path
        mv -fT $generic_ui_path $generic_old_path
        mv -fT $generic_ui_path.unzipped $generic_ui_path
        rm -rf $generic_old_path
        chmod -R 644 $generic_ui_path
        chmod -R +X $generic_ui_path # 755 for folders only.
        chmod +x $generic_ui_path/bin/execute.py

        if [ ! -z ${generic_ui_path_owner} ]; then
            chown -R $generic_ui_path_owner $generic_ui_path
        fi

        # install UI static
        cd $generic_ui_path
        chmod +x i360deploy-ui.sh
        ./i360deploy-ui.sh --module core
        cd -

        chmod 0644 /var/imunify360/generic/imunify-plugin.zip
        chmod 0600 /etc/sysconfig/imunify360/auth.admin
        if [ -f /etc/cagefs/cagefs.mp ] && [ -d /var/run/defence360agent ] ; then
            if ! grep '^/var/run/defence360agent' /etc/cagefs/cagefs.mp ; then
                echo "/var/run/defence360agent" >> /etc/cagefs/cagefs.mp
                /usr/sbin/cagefsctl -M
            fi
        fi

        update_config "${generic_ui_path}/assets/js/config.js"
    ;;

    triggered)
        generic_integration_config=/etc/sysconfig/imunify360/integration.conf
        generic_ui_path=$(\
            cat $generic_integration_config | /opt/alt/python311/bin/python3 -c 'import sys, configparser, pathlib; config = configparser.ConfigParser(); config.read_file(sys.stdin); p = pathlib.Path(config.get("paths", "ui_path", fallback="")); print(p if p.is_absolute() else "")' \
        )
        config_path="${generic_ui_path}/assets/js/config.js"
        if [ -f "$config_path" ]; then
            update_config "${generic_ui_path}/assets/js/config.js"
        else
            echo "WARNING: could not find $config_path"
        fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;

esac

exit 0