Copia de seguridad al

main
Simon Hurtado 4 months ago
parent 9f6f54ae96
commit 386f54db2c

File diff suppressed because it is too large Load Diff

@ -4,6 +4,10 @@
# Ubicación: agc/css/installer/
# =============================================================================
#
# Referencias CSS: vicidial_stylesheet, admin_header, VERM_admin, VERM_header.inc
# (VERM_main_report_page), VERM_wallboards, VERM_custom_report; importación directa:
# realtime_report.php, welcome.php, hci_screen.php.
#
# CONTENIDO DE installer/:
# - custom.css → hoja de estilos (se copia a agc/css/custom.css)
# - LogoHome.png → logo para Welcome y Agent login
@ -16,11 +20,13 @@
# 3. Link en VERM/VERM_admin.php (tras VERM_stylesheet.php) para la interfaz VERM admin.
# 4. Link en VERM/VERM_wallboards.php (tras VERM_wallboard_stylesheet.php) para el wallboard.
# 5. Link en VERM/VERM_custom_report.php (tras VERM_stylesheet.php) para el formulario de custom report.
# 6. Welcome y agent login usan el logo en vicidial/images y agc/images respectivamente.
# 7. La página de agente usa el logo en agc/images (mismo archivo que login por defecto).
# 6. Link en VERM/VERM_header.inc (tras VERM_stylesheet.php) para VERM_main_report_page.php y páginas que usan este header.
# 7. Importación directa en vicidial/realtime_report.php, vicidial/welcome.php, vicidial/hci_screen.php (no usan solo admin_header/vicidial_stylesheet).
# 8. Welcome y agent login usan el logo en vicidial/images y agc/images respectivamente.
# 9. La página de agente usa el logo en agc/images (mismo archivo que login por defecto).
#
# LOGOS:
# - LogoHome.png → Solo Welcome y Admin (vicidial/images + .gif en raíz vicidial).
# - LogoHome.png → Welcome, Admin (vicidial/images + .gif en raíz vicidial) y VERM (VERM/images para VERM_admin.php).
# - LogoAgent.png → Solo agente: login (agc/images/vicidial_admin_web_logo.png) y
# panel una vez logueado (agc/images/agc_agent_logo.png).
#
@ -45,12 +51,18 @@ CUSTOM_CSS_DEST="${AGC_DIR}/css/custom.css"
IMAGES_AGC="${AGC_DIR}/images"
VICIDIAL_STYLESHEET="${VICIDIAL_DIR}/vicidial_stylesheet.php"
ADMIN_HEADER="${VICIDIAL_DIR}/admin_header.php"
REALTIME_REPORT_PHP="${VICIDIAL_DIR}/realtime_report.php"
WELCOME_PHP="${VICIDIAL_DIR}/welcome.php"
HCI_SCREEN_PHP="${VICIDIAL_DIR}/hci_screen.php"
VERM_DIR="${HTDOCS}/VERM"
VERM_IMAGES="${VERM_DIR}/images"
VERM_ADMIN_PHP="${VERM_DIR}/VERM_admin.php"
VERM_HEADER_INC="${VERM_DIR}/VERM_header.inc"
VERM_WALLBOARDS_PHP="${VERM_DIR}/VERM_wallboards.php"
VERM_CUSTOM_REPORT_PHP="${VERM_DIR}/VERM_custom_report.php"
VICIDIAL_PHP="${AGC_DIR}/vicidial.php"
TIMECLOCK_PHP="${AGC_DIR}/timeclock.php"
VDC_SCRIPT_NOTES_PHP="${AGC_DIR}/vdc_script_notes.php"
# Nombres de logos en destino (sin ruta)
LOGO_WELCOME_NAME="vicidial_admin_web_logo.png"
@ -147,6 +159,24 @@ installed_verm_custom_report_ref() {
[[ -f "$VERM_CUSTOM_REPORT_PHP" ]] && grep -q "agc/css/custom.css" "$VERM_CUSTOM_REPORT_PHP"
}
installed_verm_header_ref() {
[[ -f "$VERM_HEADER_INC" ]] && grep -q "agc/css/custom.css" "$VERM_HEADER_INC"
}
installed_realtime_report_ref() {
[[ -f "$REALTIME_REPORT_PHP" ]] && grep -q "agc/css/custom.css" "$REALTIME_REPORT_PHP"
}
installed_welcome_ref() {
[[ -f "$WELCOME_PHP" ]] && grep -q "agc/css/custom.css" "$WELCOME_PHP"
}
installed_hci_screen_ref() {
[[ -f "$HCI_SCREEN_PHP" ]] && grep -q "agc/css/custom.css" "$HCI_SCREEN_PHP"
}
installed_vdc_script_notes_ref() {
[[ -f "$VDC_SCRIPT_NOTES_PHP" ]] && grep -q 'css/custom\.css' "$VDC_SCRIPT_NOTES_PHP"
}
# --- Copiar custom.css: hacer backup del destino si existe, luego copiar desde installer ---
copy_custom_css() {
if [[ ! -f "$CUSTOM_CSS_SOURCE" ]]; then
@ -269,6 +299,113 @@ install_verm_custom_report_ref() {
info "Añadido <link> custom.css en VERM_custom_report.php"
}
install_verm_header_ref() {
if installed_verm_header_ref; then
info "VERM_header.inc: custom.css ya referenciado."
return 0
fi
if [[ ! -f "$VERM_HEADER_INC" ]]; then
warn "No existe: $VERM_HEADER_INC (se omite VERM main report page)."
return 0
fi
save_pre_agc_backup "$VERM_HEADER_INC"
local line_num
# VERM_header.inc usa comillas escapadas en PHP (\"); buscar solo el nombre del archivo
line_num=$(grep -n 'VERM_stylesheet\.php' "$VERM_HEADER_INC" | head -1 | cut -d: -f1)
[[ -n "$line_num" ]] || { warn "No se encontró VERM_stylesheet.php en VERM_header.inc"; return 1; }
local insert_line='$HTML_header.="<link rel=\"stylesheet\" type=\"text/css\" href=\"../agc/css/custom.css\">\n";'
head -n "$line_num" "$VERM_HEADER_INC" > "${VERM_HEADER_INC}.tmp"
echo "$insert_line" >> "${VERM_HEADER_INC}.tmp"
tail -n +$((line_num + 1)) "$VERM_HEADER_INC" >> "${VERM_HEADER_INC}.tmp"
mv "${VERM_HEADER_INC}.tmp" "$VERM_HEADER_INC"
info "Añadido <link> custom.css en VERM_header.inc (VERM_main_report_page.php)"
}
# --- Importación directa: realtime_report.php, welcome.php, hci_screen.php ---
install_realtime_report_ref() {
if installed_realtime_report_ref; then
info "realtime_report.php: custom.css ya referenciado."
return 0
fi
if [[ ! -f "$REALTIME_REPORT_PHP" ]]; then
warn "No existe: $REALTIME_REPORT_PHP (se omite)."
return 0
fi
save_pre_agc_backup "$REALTIME_REPORT_PHP"
local line_num
line_num=$(grep -n 'META HTTP-EQUIV.*Content-Type.*charset=utf-8' "$REALTIME_REPORT_PHP" | head -1 | cut -d: -f1)
[[ -n "$line_num" ]] || { warn "No se encontró ancla META Content-Type en realtime_report.php"; return 1; }
local insert_line='echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../agc/css/custom.css\" />\n";'
head -n "$line_num" "$REALTIME_REPORT_PHP" > "${REALTIME_REPORT_PHP}.tmp"
echo "$insert_line" >> "${REALTIME_REPORT_PHP}.tmp"
tail -n +$((line_num + 1)) "$REALTIME_REPORT_PHP" >> "${REALTIME_REPORT_PHP}.tmp"
mv "${REALTIME_REPORT_PHP}.tmp" "$REALTIME_REPORT_PHP"
info "Añadido <link> custom.css en realtime_report.php"
}
install_welcome_ref() {
if installed_welcome_ref; then
info "welcome.php: custom.css ya referenciado."
return 0
fi
if [[ ! -f "$WELCOME_PHP" ]]; then
warn "No existe: $WELCOME_PHP (se omite)."
return 0
fi
save_pre_agc_backup "$WELCOME_PHP"
local line_num
line_num=$(grep -n 'agc/css/style.css' "$WELCOME_PHP" | head -1 | cut -d: -f1)
[[ -n "$line_num" ]] || { warn "No se encontró style.css en welcome.php"; return 1; }
local insert_line='echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../agc/css/custom.css\" />\n";'
head -n "$line_num" "$WELCOME_PHP" > "${WELCOME_PHP}.tmp"
echo "$insert_line" >> "${WELCOME_PHP}.tmp"
tail -n +$((line_num + 1)) "$WELCOME_PHP" >> "${WELCOME_PHP}.tmp"
mv "${WELCOME_PHP}.tmp" "$WELCOME_PHP"
info "Añadido <link> custom.css en welcome.php"
}
install_hci_screen_ref() {
if installed_hci_screen_ref; then
info "hci_screen.php: custom.css ya referenciado."
return 0
fi
if [[ ! -f "$HCI_SCREEN_PHP" ]]; then
warn "No existe: $HCI_SCREEN_PHP (se omite)."
return 0
fi
save_pre_agc_backup "$HCI_SCREEN_PHP"
local line_num
line_num=$(grep -n 'agc/css/style.css' "$HCI_SCREEN_PHP" | head -1 | cut -d: -f1)
[[ -n "$line_num" ]] || { warn "No se encontró style.css en hci_screen.php"; return 1; }
local insert_line=' <link rel="stylesheet" type="text/css" href="../agc/css/custom.css" />'
head -n "$line_num" "$HCI_SCREEN_PHP" > "${HCI_SCREEN_PHP}.tmp"
echo "$insert_line" >> "${HCI_SCREEN_PHP}.tmp"
tail -n +$((line_num + 1)) "$HCI_SCREEN_PHP" >> "${HCI_SCREEN_PHP}.tmp"
mv "${HCI_SCREEN_PHP}.tmp" "$HCI_SCREEN_PHP"
info "Añadido <link> custom.css en hci_screen.php"
}
install_vdc_script_notes_ref() {
if installed_vdc_script_notes_ref; then
info "vdc_script_notes.php: custom.css ya referenciado."
return 0
fi
if [[ ! -f "$VDC_SCRIPT_NOTES_PHP" ]]; then
warn "No existe: $VDC_SCRIPT_NOTES_PHP (se omite iframe de notas)."
return 0
fi
save_pre_agc_backup "$VDC_SCRIPT_NOTES_PHP"
local line_num
line_num=$(grep -n 'href="calendar.css"' "$VDC_SCRIPT_NOTES_PHP" | head -1 | cut -d: -f1)
[[ -n "$line_num" ]] || { warn "No se encontró calendar.css en vdc_script_notes.php"; return 1; }
local insert_line='echo "<link rel=\"stylesheet\" href=\"css/custom.css\">\n";'
head -n "$line_num" "$VDC_SCRIPT_NOTES_PHP" > "${VDC_SCRIPT_NOTES_PHP}.tmp"
echo "$insert_line" >> "${VDC_SCRIPT_NOTES_PHP}.tmp"
tail -n +$((line_num + 1)) "$VDC_SCRIPT_NOTES_PHP" >> "${VDC_SCRIPT_NOTES_PHP}.tmp"
mv "${VDC_SCRIPT_NOTES_PHP}.tmp" "$VDC_SCRIPT_NOTES_PHP"
info "Añadido <link> custom.css en vdc_script_notes.php (iframe de notas)"
}
# --- Logo .gif en raíz vicidial (admin usa este cuando SSweb_logo=default_old) ---
install_logo_gif_vicidial_root() {
local logo_home="${INSTALADOR_DIR}/LogoHome.png"
@ -297,13 +434,19 @@ restore_logo_gif_vicidial_root() {
return 0
}
# --- Instalar logos: LogoHome solo Welcome y Admin; LogoAgent solo para agente (login + panel) ---
# --- Instalar logos: LogoHome Welcome, Admin y VERM; LogoAgent solo para agente (login + panel) ---
install_logos() {
local logo_home="${INSTALADOR_DIR}/LogoHome.png"
local logo_agent="${INSTALADOR_DIR}/LogoAgent.png"
# LogoHome → Welcome y Admin panel (vicidial/images + .gif)
install_logo_file "$logo_home" "$VICIDIAL_IMAGES" "$LOGO_WELCOME_NAME"
install_logo_gif_vicidial_root
# LogoHome → VERM (VERM_admin.php y páginas que incluyen admin_header desde /VERM/ usan VERM/images/)
if [[ -d "$VERM_IMAGES" ]]; then
install_logo_file "$logo_home" "$VERM_IMAGES" "$LOGO_WELCOME_NAME"
else
warn "No existe directorio $VERM_IMAGES (logo VERM no instalado)."
fi
# LogoAgent → solo agente: login (vicidial_admin_web_logo en agc) y panel (agc_agent_logo)
install_logo_file "$logo_agent" "$IMAGES_AGC" "$LOGO_AGENT_LOGIN_NAME"
install_logo_file "$logo_agent" "$IMAGES_AGC" "$LOGO_AGENT_PAGE_NAME"
@ -387,9 +530,79 @@ uninstall_verm_custom_report_ref() {
info "Referencia eliminada en VERM_custom_report.php"
}
uninstall_verm_header_ref() {
if ! installed_verm_header_ref; then
info "VERM_header.inc: no había referencia a custom.css."
return 0
fi
if [[ ! -f "$VERM_HEADER_INC" ]]; then
return 0
fi
if restore_from_pre_agc_backup "$VERM_HEADER_INC"; then
return 0
fi
warn "No hay backup .bak.pre_agc; quitando referencia con sed."
sed -i '/agc\/css\/custom\.css/d' "$VERM_HEADER_INC"
info "Referencia eliminada en VERM_header.inc"
}
uninstall_realtime_report_ref() {
if ! installed_realtime_report_ref; then
info "realtime_report.php: no había referencia a custom.css."
return 0
fi
if [[ ! -f "$REALTIME_REPORT_PHP" ]]; then return 0; fi
if restore_from_pre_agc_backup "$REALTIME_REPORT_PHP"; then
return 0
fi
sed -i '/agc\/css\/custom\.css/d' "$REALTIME_REPORT_PHP"
info "Referencia eliminada en realtime_report.php"
}
uninstall_welcome_ref() {
if ! installed_welcome_ref; then
info "welcome.php: no había referencia a custom.css."
return 0
fi
if [[ ! -f "$WELCOME_PHP" ]]; then return 0; fi
if restore_from_pre_agc_backup "$WELCOME_PHP"; then
return 0
fi
sed -i '/agc\/css\/custom\.css/d' "$WELCOME_PHP"
info "Referencia eliminada en welcome.php"
}
uninstall_hci_screen_ref() {
if ! installed_hci_screen_ref; then
info "hci_screen.php: no había referencia a custom.css."
return 0
fi
if [[ ! -f "$HCI_SCREEN_PHP" ]]; then return 0; fi
if restore_from_pre_agc_backup "$HCI_SCREEN_PHP"; then
return 0
fi
sed -i '/agc\/css\/custom\.css/d' "$HCI_SCREEN_PHP"
info "Referencia eliminada en hci_screen.php"
}
uninstall_vdc_script_notes_ref() {
if ! installed_vdc_script_notes_ref; then
info "vdc_script_notes.php: no había referencia a custom.css."
return 0
fi
if [[ ! -f "$VDC_SCRIPT_NOTES_PHP" ]]; then return 0; fi
if restore_from_pre_agc_backup "$VDC_SCRIPT_NOTES_PHP"; then
return 0
fi
warn "No hay backup .bak.pre_agc; quitando referencia con sed."
sed -i '/css\/custom\.css/d' "$VDC_SCRIPT_NOTES_PHP"
info "Referencia eliminada en vdc_script_notes.php"
}
restore_logos() {
restore_logo_file "$VICIDIAL_IMAGES" "$LOGO_WELCOME_NAME" || true
restore_logo_gif_vicidial_root || true
restore_logo_file "$VERM_IMAGES" "$LOGO_WELCOME_NAME" || true
restore_logo_file "$IMAGES_AGC" "$LOGO_AGENT_LOGIN_NAME" || true
if restore_logo_file "$IMAGES_AGC" "$LOGO_AGENT_PAGE_NAME"; then
:
@ -512,8 +725,13 @@ do_install() {
install_stylesheet_ref
install_admin_header_ref
install_verm_ref
install_verm_header_ref
install_verm_wallboard_ref
install_verm_custom_report_ref
install_realtime_report_ref
install_welcome_ref
install_hci_screen_ref
install_vdc_script_notes_ref
install_placeholders
install_relogin_placeholders
install_campaign_placeholders
@ -528,8 +746,13 @@ do_uninstall() {
uninstall_stylesheet_ref
uninstall_admin_header_ref
uninstall_verm_ref
uninstall_verm_header_ref
uninstall_verm_wallboard_ref
uninstall_verm_custom_report_ref
uninstall_realtime_report_ref
uninstall_welcome_ref
uninstall_hci_screen_ref
uninstall_vdc_script_notes_ref
uninstall_placeholders
uninstall_timeclock_placeholders
restore_logos
@ -556,12 +779,27 @@ do_status() {
if [[ -f "$VERM_ADMIN_PHP" ]]; then
installed_verm_ref && info "VERM_admin.php: referenciado" || warn "VERM_admin.php: no referenciado"
fi
if [[ -f "$VERM_HEADER_INC" ]]; then
installed_verm_header_ref && info "VERM_header.inc (VERM_main_report_page): referenciado" || warn "VERM_header.inc: no referenciado"
fi
if [[ -f "$VERM_WALLBOARDS_PHP" ]]; then
installed_verm_wallboard_ref && info "VERM_wallboards.php: referenciado" || warn "VERM_wallboards.php: no referenciado"
fi
if [[ -f "$VERM_CUSTOM_REPORT_PHP" ]]; then
installed_verm_custom_report_ref && info "VERM_custom_report.php: referenciado" || warn "VERM_custom_report.php: no referenciado"
fi
if [[ -f "$REALTIME_REPORT_PHP" ]]; then
installed_realtime_report_ref && info "realtime_report.php: referenciado" || warn "realtime_report.php: no referenciado"
fi
if [[ -f "$WELCOME_PHP" ]]; then
installed_welcome_ref && info "welcome.php: referenciado" || warn "welcome.php: no referenciado"
fi
if [[ -f "$HCI_SCREEN_PHP" ]]; then
installed_hci_screen_ref && info "hci_screen.php: referenciado" || warn "hci_screen.php: no referenciado"
fi
if [[ -f "$VDC_SCRIPT_NOTES_PHP" ]]; then
installed_vdc_script_notes_ref && info "vdc_script_notes.php (iframe notas): referenciado" || warn "vdc_script_notes.php: no referenciado"
fi
if [[ -f "$VICIDIAL_PHP" ]]; then
has_placeholders && info "vicidial.php: placeholders Phone (size=10) presentes" || warn "vicidial.php: placeholders Phone no presentes"
has_relogin_placeholders && info "vicidial.php: placeholders Re-Login presentes" || warn "vicidial.php: placeholders Re-Login no presentes"
@ -570,7 +808,8 @@ do_status() {
if [[ -f "$TIMECLOCK_PHP" ]]; then
has_timeclock_placeholders && info "timeclock.php: placeholders presentes" || warn "timeclock.php: placeholders no presentes"
fi
for dir in "$VICIDIAL_IMAGES" "$IMAGES_AGC"; do
for dir in "$VICIDIAL_IMAGES" "$VERM_IMAGES" "$IMAGES_AGC"; do
[[ -d "$dir" ]] || continue
for name in "$LOGO_WELCOME_NAME" "$LOGO_AGENT_LOGIN_NAME" "$LOGO_AGENT_PAGE_NAME"; do
base="${name%.*}"
ext="${name##*.}"
@ -589,8 +828,8 @@ case "$ACTION" in
*)
echo "Uso: $0 { install | uninstall | status }"
echo " Ruta absoluta: /srv/www/htdocs/agc/css/installer/install_custom_css.sh"
echo " install - Copia custom.css, instala logos (LogoHome, LogoAgent) y referencias CSS."
echo " uninstall - Restaura referencias en vicidial y logos desde *_OldCustom (no restaura custom.css)."
echo " install - Copia custom.css, instala logos y referencias CSS (vicidial, admin, VERM admin/main report/wallboard/custom report)."
echo " uninstall - Restaura referencias y logos desde backup (no restaura custom.css)."
echo " status - Estado de archivos y referencias."
echo ""
echo "Contenido de installer/: custom.css, LogoHome.png, LogoAgent.png, este script."

Loading…
Cancel
Save