Parkteknia / wp_monitor

Monitor WordPress installations outside cPanel or Plesk (WP-Toolkit)
GNU General Public License v3.0
0 stars 2 forks source link

Cuando se actualizan las variables globales en wpm_jobs.sh no se guarda valor para PANEL #32

Closed P3r4nD closed 3 months ago

P3r4nD commented 3 months ago

...luego la interfaz da error en esa variable.

Puesto que en el scope principal ya tenemos :

# 1. Detect control panel
detect_control_panel
control_panel=$?

No hace falta volver a escribir en update_wpm_jobs_file()

# Detect the control panel
cp=$(detect_control_panel)

Simplemente llamamos así:

if [ "$check" = false ]; then
    update_wpm_jobs_file $control_panel
fi

Por lo que update_wpm_jobs_file()queda así:

update_wpm_jobs_file() {
    local CONTROL_PANEL=$1
    WPM_JOBS_FILE="$BASE_DIR/wpm_bash/wpm_jobs.sh"

    # Ensure the wpm_jobs.sh file exists
    if [[ ! -f "$WPM_JOBS_FILE" ]]; then
        echo "Error: $WPM_JOBS_FILE not found!"
        exit 1
    fi

    # Update paths and panel in wpm_jobs.sh
    sed -i "s|^JOBS_FILE=.*|JOBS_FILE=\"$BASE_DIR/jobs\"|" "$WPM_JOBS_FILE"
    sed -i "s|^JOBS_EXECUTED_FILE=.*|JOBS_EXECUTED_FILE=\"$BASE_DIR/jobs_executed\"|" "$WPM_JOBS_FILE"
    sed -i "s|^LOCK_FILE=.*|LOCK_FILE=\"$BASE_DIR/wpm_data/tmp/wp_monitor.lock\"|" "$WPM_JOBS_FILE"
    sed -i "s|^LOG_FILE=.*|LOG_FILE=\"$BASE_DIR/wpm_data/logs/jobs.log\"|" "$WPM_JOBS_FILE"
    sed -i "s|^PANEL=.*|PANEL=\"$CONTROL_PANEL\"|" "$WPM_JOBS_FILE"
}