Co-authored-by: Cursor <cursoragent@cursor.com>main
parent
4cb29a3df8
commit
b9a758716b
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 29 KiB |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,455 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Instalador AGC: custom.css + logos (LogoHome, LogoAgent)
|
||||
# Ubicación: agc/css/installer/
|
||||
# =============================================================================
|
||||
#
|
||||
# CONTENIDO DE installer/:
|
||||
# - custom.css → hoja de estilos (se copia a agc/css/custom.css)
|
||||
# - LogoHome.png → logo para Welcome y Agent login
|
||||
# - LogoAgent.png → logo para la página de agente (una vez logueado)
|
||||
# - install_custom_css.sh (este script)
|
||||
#
|
||||
# GUÍA DE INSTALACIÓN (también en custom.css al inicio):
|
||||
# 1. Import en vicidial_stylesheet.php (al inicio del CSS) para la mayoría de pantallas.
|
||||
# 2. Link en admin_header.php (antes de </head>) para pantallas que usan admin_header.
|
||||
# 3. Welcome y agent login usan el logo en vicidial/images y agc/images respectivamente.
|
||||
# 4. 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).
|
||||
# - LogoAgent.png → Solo agente: login (agc/images/vicidial_admin_web_logo.png) y
|
||||
# panel una vez logueado (agc/images/agc_agent_logo.png).
|
||||
#
|
||||
# BACKUP DE IMÁGENES: antes de sustituir, se guarda la actual como *NombreOriginal*_OldCustom.ext.
|
||||
# BACKUP DE custom.css: si agc/css/custom.css ya existe, se guarda como custom.css.bak.pre_agc antes de copiar.
|
||||
# RESTAURAR (uninstall): restaura referencias CSS desde .bak.pre_agc y logos desde *_OldCustom; custom.css se deja en blanco con comentario "Custom desinstalado".
|
||||
#
|
||||
# Uso (ruta absoluta):
|
||||
# /srv/www/htdocs/agc/css/installer/install_custom_css.sh [ install | uninstall | status ]
|
||||
# HTDOCS=/ruta/htdocs /srv/www/htdocs/agc/css/installer/install_custom_css.sh install # otro ViciDial
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
INSTALADOR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
AGC_DIR="$(dirname "$(dirname "$INSTALADOR_DIR")")"
|
||||
HTDOCS="${HTDOCS:-$(dirname "$AGC_DIR")}"
|
||||
VICIDIAL_DIR="${HTDOCS}/vicidial"
|
||||
VICIDIAL_IMAGES="${VICIDIAL_DIR}/images"
|
||||
CUSTOM_CSS_SOURCE="${INSTALADOR_DIR}/custom.css"
|
||||
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"
|
||||
VICIDIAL_PHP="${AGC_DIR}/vicidial.php"
|
||||
TIMECLOCK_PHP="${AGC_DIR}/timeclock.php"
|
||||
|
||||
# Nombres de logos en destino (sin ruta)
|
||||
LOGO_WELCOME_NAME="vicidial_admin_web_logo.png"
|
||||
LOGO_AGENT_LOGIN_NAME="vicidial_admin_web_logo.png"
|
||||
LOGO_AGENT_PAGE_NAME="agc_agent_logo.png"
|
||||
LOGO_ADMIN_GIF_NAME="vicidial_admin_web_logo.gif"
|
||||
OLDCUSTOM_SUFFIX="_OldCustom"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# --- Backup/restore para archivos modificados (referencias CSS) ---
|
||||
BACKUP_SUFFIX=".bak.pre_agc"
|
||||
save_pre_agc_backup() {
|
||||
local file="$1"
|
||||
[[ -f "$file" ]] || return 0
|
||||
cp -a "$file" "${file}${BACKUP_SUFFIX}"
|
||||
info "Backup para restauración: ${file}${BACKUP_SUFFIX}"
|
||||
}
|
||||
restore_from_pre_agc_backup() {
|
||||
local file="$1"
|
||||
local backup="${file}${BACKUP_SUFFIX}"
|
||||
if [[ -f "$backup" ]]; then
|
||||
cp -a "$backup" "$file"
|
||||
rm -f "$backup"
|
||||
info "Restaurado: $file"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# --- Logo: guardar original como *Nombre*_OldCustom.ext y poner el nuevo con nombre original ---
|
||||
install_logo_file() {
|
||||
local src="$1"
|
||||
local dest_dir="$2"
|
||||
local dest_name="$3"
|
||||
local dest_path="${dest_dir}/${dest_name}"
|
||||
local ext="${dest_name##*.}"
|
||||
local base="${dest_name%.*}"
|
||||
local backup_path="${dest_dir}/${base}${OLDCUSTOM_SUFFIX}.${ext}"
|
||||
if [[ ! -f "$src" ]]; then
|
||||
warn "No encontrado: $src (se omite)."
|
||||
return 0
|
||||
fi
|
||||
if [[ ! -d "$dest_dir" ]]; then
|
||||
warn "No existe el directorio: $dest_dir (se omite)."
|
||||
return 0
|
||||
fi
|
||||
if [[ -f "$dest_path" ]] && [[ ! -f "$backup_path" ]]; then
|
||||
cp -a "$dest_path" "$backup_path"
|
||||
info "Backup de imagen (original para desinstalar): $backup_path"
|
||||
fi
|
||||
cp -a "$src" "$dest_path"
|
||||
info "Logo instalado: $dest_path"
|
||||
}
|
||||
|
||||
# --- Restaurar logo desde *_OldCustom ---
|
||||
restore_logo_file() {
|
||||
local dest_dir="$1"
|
||||
local dest_name="$2"
|
||||
local ext="${dest_name##*.}"
|
||||
local base="${dest_name%.*}"
|
||||
local backup_path="${dest_dir}/${base}${OLDCUSTOM_SUFFIX}.${ext}"
|
||||
if [[ ! -f "$backup_path" ]]; then
|
||||
return 1
|
||||
fi
|
||||
cp -a "$backup_path" "${dest_dir}/${dest_name}"
|
||||
rm -f "$backup_path"
|
||||
info "Restaurado logo: ${dest_dir}/${dest_name}"
|
||||
return 0
|
||||
}
|
||||
|
||||
installed_stylesheet() {
|
||||
[[ -f "$VICIDIAL_STYLESHEET" ]] && grep -q "agc/css/custom.css" "$VICIDIAL_STYLESHEET"
|
||||
}
|
||||
installed_admin_header() {
|
||||
[[ -f "$ADMIN_HEADER" ]] && grep -q "agc/css/custom.css" "$ADMIN_HEADER"
|
||||
}
|
||||
|
||||
# --- Copiar custom.css: hacer backup del destino si existe, luego copiar desde installer ---
|
||||
copy_custom_css() {
|
||||
if [[ ! -f "$CUSTOM_CSS_SOURCE" ]]; then
|
||||
error "No se encuentra custom.css en: $CUSTOM_CSS_SOURCE"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -f "$CUSTOM_CSS_DEST" ]]; then
|
||||
cp -a "$CUSTOM_CSS_DEST" "${CUSTOM_CSS_DEST}${BACKUP_SUFFIX}"
|
||||
info "Backup del custom.css actual: ${CUSTOM_CSS_DEST}${BACKUP_SUFFIX}"
|
||||
fi
|
||||
cp -a "$CUSTOM_CSS_SOURCE" "$CUSTOM_CSS_DEST"
|
||||
info "custom.css copiado a $CUSTOM_CSS_DEST"
|
||||
}
|
||||
|
||||
# --- Instalar referencias a custom.css (vicidial_stylesheet y admin_header) ---
|
||||
install_stylesheet_ref() {
|
||||
if installed_stylesheet; then
|
||||
info "vicidial_stylesheet.php: custom.css ya referenciado."
|
||||
return 0
|
||||
fi
|
||||
if [[ ! -f "$VICIDIAL_STYLESHEET" ]]; then
|
||||
warn "No existe: $VICIDIAL_STYLESHEET"
|
||||
return 1
|
||||
fi
|
||||
save_pre_agc_backup "$VICIDIAL_STYLESHEET"
|
||||
local line_num
|
||||
line_num=$(grep -n '?>' "$VICIDIAL_STYLESHEET" | head -1 | cut -d: -f1)
|
||||
[[ -n "$line_num" ]] || { error "No se encontró ?> en vicidial_stylesheet.php"; return 1; }
|
||||
head -n "$line_num" "$VICIDIAL_STYLESHEET" > "${VICIDIAL_STYLESHEET}.tmp"
|
||||
echo "" >> "${VICIDIAL_STYLESHEET}.tmp"
|
||||
echo "/* Importar estilos personalizados AGC (debe ir al inicio) */" >> "${VICIDIAL_STYLESHEET}.tmp"
|
||||
echo "@import url('../agc/css/custom.css');" >> "${VICIDIAL_STYLESHEET}.tmp"
|
||||
echo "" >> "${VICIDIAL_STYLESHEET}.tmp"
|
||||
tail -n +$((line_num + 1)) "$VICIDIAL_STYLESHEET" >> "${VICIDIAL_STYLESHEET}.tmp"
|
||||
mv "${VICIDIAL_STYLESHEET}.tmp" "$VICIDIAL_STYLESHEET"
|
||||
info "Añadido @import en vicidial_stylesheet.php"
|
||||
}
|
||||
|
||||
install_admin_header_ref() {
|
||||
if installed_admin_header; then
|
||||
info "admin_header.php: custom.css ya referenciado."
|
||||
return 0
|
||||
fi
|
||||
if [[ ! -f "$ADMIN_HEADER" ]]; then
|
||||
warn "No existe: $ADMIN_HEADER"
|
||||
return 1
|
||||
fi
|
||||
save_pre_agc_backup "$ADMIN_HEADER"
|
||||
local line_num
|
||||
line_num=$(grep -n 'echo "</head>' "$ADMIN_HEADER" | head -1 | cut -d: -f1)
|
||||
[[ -n "$line_num" ]] || { error "No se encontró echo \"</head>\" en admin_header.php"; return 1; }
|
||||
local insert_line='echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../agc/css/custom.css\" />\n";'
|
||||
head -n $((line_num - 1)) "$ADMIN_HEADER" > "${ADMIN_HEADER}.tmp"
|
||||
echo "$insert_line" >> "${ADMIN_HEADER}.tmp"
|
||||
tail -n +"$line_num" "$ADMIN_HEADER" >> "${ADMIN_HEADER}.tmp"
|
||||
mv "${ADMIN_HEADER}.tmp" "$ADMIN_HEADER"
|
||||
info "Añadido <link> en admin_header.php"
|
||||
}
|
||||
|
||||
# --- 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"
|
||||
local dest_gif="${VICIDIAL_DIR}/${LOGO_ADMIN_GIF_NAME}"
|
||||
local backup_gif="${VICIDIAL_DIR}/vicidial_admin_web_logo${OLDCUSTOM_SUFFIX}.gif"
|
||||
[[ -f "$logo_home" ]] || return 0
|
||||
if [[ -f "$dest_gif" ]] && [[ ! -f "$backup_gif" ]]; then
|
||||
cp -a "$dest_gif" "$backup_gif"
|
||||
info "Backup logo .gif (original para desinstalar): $backup_gif"
|
||||
fi
|
||||
if command -v convert &>/dev/null; then
|
||||
convert "$logo_home" "$dest_gif" && info "Logo .gif instalado: $dest_gif" || cp -a "$logo_home" "$dest_gif"
|
||||
else
|
||||
cp -a "$logo_home" "$dest_gif"
|
||||
info "Logo .gif instalado: $dest_gif"
|
||||
fi
|
||||
}
|
||||
|
||||
restore_logo_gif_vicidial_root() {
|
||||
local backup_gif="${VICIDIAL_DIR}/vicidial_admin_web_logo${OLDCUSTOM_SUFFIX}.gif"
|
||||
local dest_gif="${VICIDIAL_DIR}/${LOGO_ADMIN_GIF_NAME}"
|
||||
if [[ ! -f "$backup_gif" ]]; then return 1; fi
|
||||
cp -a "$backup_gif" "$dest_gif"
|
||||
rm -f "$backup_gif"
|
||||
info "Restaurado logo .gif original: $dest_gif"
|
||||
return 0
|
||||
}
|
||||
|
||||
# --- Instalar logos: LogoHome solo Welcome y Admin; 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
|
||||
# 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"
|
||||
}
|
||||
|
||||
# --- Desinstalar: quitar referencias CSS y restaurar logos desde *_OldCustom ---
|
||||
uninstall_stylesheet_ref() {
|
||||
if ! installed_stylesheet; then
|
||||
info "vicidial_stylesheet.php: no había referencia a custom.css."
|
||||
return 0
|
||||
fi
|
||||
if restore_from_pre_agc_backup "$VICIDIAL_STYLESHEET"; then
|
||||
return 0
|
||||
fi
|
||||
warn "No hay backup .bak.pre_agc; quitando referencias con sed."
|
||||
sed -i '/\/\* Importar estilos personalizados AGC \*\//d' "$VICIDIAL_STYLESHEET"
|
||||
sed -i '/\/\* Importar estilos personalizados AGC (debe ir al inicio) \*\//d' "$VICIDIAL_STYLESHEET"
|
||||
sed -i "/@import url('\.\.\/agc\/css\/custom\.css');/d" "$VICIDIAL_STYLESHEET"
|
||||
sed -i '/@import url.*agc\/css\/custom\.css/d' "$VICIDIAL_STYLESHEET"
|
||||
info "Referencias eliminadas en vicidial_stylesheet.php"
|
||||
}
|
||||
|
||||
uninstall_admin_header_ref() {
|
||||
if ! installed_admin_header; then
|
||||
info "admin_header.php: no había referencia a custom.css."
|
||||
return 0
|
||||
fi
|
||||
if restore_from_pre_agc_backup "$ADMIN_HEADER"; then
|
||||
return 0
|
||||
fi
|
||||
warn "No hay backup .bak.pre_agc; quitando referencia con sed."
|
||||
sed -i '/agc\/css\/custom\.css/d' "$ADMIN_HEADER"
|
||||
info "Referencia eliminada en admin_header.php"
|
||||
}
|
||||
|
||||
restore_logos() {
|
||||
restore_logo_file "$VICIDIAL_IMAGES" "$LOGO_WELCOME_NAME" || true
|
||||
restore_logo_gif_vicidial_root || true
|
||||
restore_logo_file "$IMAGES_AGC" "$LOGO_AGENT_LOGIN_NAME" || true
|
||||
if restore_logo_file "$IMAGES_AGC" "$LOGO_AGENT_PAGE_NAME"; then
|
||||
:
|
||||
else
|
||||
if [[ -f "${IMAGES_AGC}/${LOGO_AGENT_PAGE_NAME}" ]]; then
|
||||
rm -f "${IMAGES_AGC}/${LOGO_AGENT_PAGE_NAME}"
|
||||
info "Eliminado logo de agente (no existía original): ${IMAGES_AGC}/${LOGO_AGENT_PAGE_NAME}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Placeholders en vicidial.php (Phone Login size=10) ---
|
||||
has_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] && grep -q 'placeholder=.*_QXZ.*Phone Login' "$VICIDIAL_PHP"
|
||||
}
|
||||
|
||||
install_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] || { warn "vicidial.php no encontrado."; return 0; }
|
||||
if has_placeholders; then
|
||||
info "Placeholders Phone Login ya presentes en vicidial.php."
|
||||
return 0
|
||||
fi
|
||||
save_pre_agc_backup "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"phone_login\\" size=\\"10\\"/s/ value=\\"\\" \/>/ value=\\"\\" placeholder=\\""._QXZ("Phone Login")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"phone_pass\\" size=\\"10\\"/s/ value=\\"\\" \/>/ value=\\"\\" placeholder=\\""._QXZ("Phone Password")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
info "Placeholders Phone Login añadidos en vicidial.php."
|
||||
}
|
||||
|
||||
# --- Placeholders Re-Login (phone_login/phone_pass size=20) ---
|
||||
has_relogin_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] && grep -q 'phone_login.*size="20".*placeholder' "$VICIDIAL_PHP"
|
||||
}
|
||||
|
||||
install_relogin_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] || return 0
|
||||
if has_relogin_placeholders; then
|
||||
info "Placeholders Re-Login ya presentes."
|
||||
return 0
|
||||
fi
|
||||
[[ -f "${VICIDIAL_PHP}${BACKUP_SUFFIX}" ]] || save_pre_agc_backup "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"phone_login\\" size=\\"20\\"/s/ value=\\"\$phone_login\\" \/>/ value=\\"\$phone_login\\" placeholder=\\""._QXZ("Phone Login")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"phone_pass\\" size=\\"20\\"/s/ value=\\"\$phone_pass\\" \/>/ value=\\"\$phone_pass\\" placeholder=\\""._QXZ("Phone Password")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
info "Placeholders Re-Login añadidos."
|
||||
}
|
||||
|
||||
# --- Placeholders Campaign Login (VD_login/VD_pass) ---
|
||||
has_campaign_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] && grep -q 'VD_login.*placeholder.*User Login' "$VICIDIAL_PHP"
|
||||
}
|
||||
|
||||
install_campaign_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] || return 0
|
||||
if has_campaign_placeholders; then
|
||||
info "Placeholders Campaign Login ya presentes."
|
||||
return 0
|
||||
fi
|
||||
[[ -f "${VICIDIAL_PHP}${BACKUP_SUFFIX}" ]] || save_pre_agc_backup "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"VD_login\\" size=\\"20\\"/s/ value=\\"\$VD_login\\" \/>/ value=\\"\$VD_login\\" placeholder=\\""._QXZ("User Login")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
sed -i '/name=\\"VD_pass\\" size=\\"20\\"/s/ value=\\"\$VD_pass\\" \/>/ value=\\"\$VD_pass\\" placeholder=\\""._QXZ("User Password")."\\" \/>/' "$VICIDIAL_PHP"
|
||||
info "Placeholders Campaign Login añadidos."
|
||||
}
|
||||
|
||||
uninstall_placeholders() {
|
||||
[[ -f "$VICIDIAL_PHP" ]] || return 0
|
||||
if restore_from_pre_agc_backup "$VICIDIAL_PHP"; then
|
||||
info "vicidial.php restaurado (placeholders quitados)."
|
||||
return 0
|
||||
fi
|
||||
if ! has_placeholders && ! has_relogin_placeholders && ! has_campaign_placeholders; then
|
||||
return 0
|
||||
fi
|
||||
sed -i 's/ placeholder=\\""._QXZ("Phone Login")."\\"//' "$VICIDIAL_PHP"
|
||||
sed -i 's/ placeholder=\\""._QXZ("Phone Password")."\\"//' "$VICIDIAL_PHP"
|
||||
sed -i 's/ placeholder=\\""._QXZ("User Login")."\\"//' "$VICIDIAL_PHP"
|
||||
sed -i 's/ placeholder=\\""._QXZ("User Password")."\\"//' "$VICIDIAL_PHP"
|
||||
info "Placeholders eliminados de vicidial.php."
|
||||
}
|
||||
|
||||
# --- Placeholders en timeclock.php ---
|
||||
has_timeclock_placeholders() {
|
||||
[[ -f "$TIMECLOCK_PHP" ]] && grep -q 'placeholder=.*_QXZ.*User Login' "$TIMECLOCK_PHP"
|
||||
}
|
||||
|
||||
install_timeclock_placeholders() {
|
||||
[[ -f "$TIMECLOCK_PHP" ]] || { warn "timeclock.php no encontrado."; return 0; }
|
||||
if has_timeclock_placeholders; then
|
||||
info "Placeholders ya presentes en timeclock.php."
|
||||
return 0
|
||||
fi
|
||||
save_pre_agc_backup "$TIMECLOCK_PHP"
|
||||
sed -i '/NAME=user SIZE=10 MAXLENGTH=20/s/VALUE=\\"\$VD_login\\">/VALUE=\\"$VD_login\\" placeholder=\\""._QXZ("User Login")."\\">/' "$TIMECLOCK_PHP"
|
||||
sed -i '/NAME=pass SIZE=10 MAXLENGTH=20/s/VALUE='"'"''"'"'>/VALUE='"'"''"'"' placeholder=\\""._QXZ("User Password")."\\">/' "$TIMECLOCK_PHP"
|
||||
info "Placeholders añadidos en timeclock.php."
|
||||
}
|
||||
|
||||
uninstall_timeclock_placeholders() {
|
||||
[[ -f "$TIMECLOCK_PHP" ]] || return 0
|
||||
if restore_from_pre_agc_backup "$TIMECLOCK_PHP"; then
|
||||
info "timeclock.php restaurado."
|
||||
return 0
|
||||
fi
|
||||
if ! has_timeclock_placeholders; then return 0; fi
|
||||
sed -i 's/ placeholder=\\""._QXZ("User Login")."\\"//' "$TIMECLOCK_PHP"
|
||||
sed -i 's/ placeholder=\\""._QXZ("User Password")."\\"//' "$TIMECLOCK_PHP"
|
||||
info "Placeholders eliminados de timeclock.php."
|
||||
}
|
||||
|
||||
# --- Dejar custom.css en blanco con solo comentario "Custom desinstalado" ---
|
||||
write_custom_css_uninstalled() {
|
||||
printf '/* Custom desinstalado */\n' > "$CUSTOM_CSS_DEST"
|
||||
info "custom.css dejado en blanco (comentario: Custom desinstalado)."
|
||||
}
|
||||
|
||||
do_install() {
|
||||
echo "=== Instalador AGC (custom.css + logos + placeholders) ==="
|
||||
info "Raíz: $HTDOCS"
|
||||
info "Instalador: $INSTALADOR_DIR"
|
||||
copy_custom_css
|
||||
install_logos
|
||||
install_stylesheet_ref
|
||||
install_admin_header_ref
|
||||
install_placeholders
|
||||
install_relogin_placeholders
|
||||
install_campaign_placeholders
|
||||
install_timeclock_placeholders
|
||||
echo ""
|
||||
info "Instalación completada. Si custom.css ya existía, se guardó en ${CUSTOM_CSS_DEST}${BACKUP_SUFFIX}"
|
||||
}
|
||||
|
||||
do_uninstall() {
|
||||
echo "=== Desinstalación AGC (restaurar referencias, logos, placeholders y custom.css) ==="
|
||||
info "Raíz: $HTDOCS"
|
||||
uninstall_stylesheet_ref
|
||||
uninstall_admin_header_ref
|
||||
uninstall_placeholders
|
||||
uninstall_timeclock_placeholders
|
||||
restore_logos
|
||||
write_custom_css_uninstalled
|
||||
echo ""
|
||||
info "Desinstalación completada."
|
||||
}
|
||||
|
||||
do_status() {
|
||||
echo "=== Estado instalador AGC ==="
|
||||
info "Raíz: $HTDOCS"
|
||||
info "Instalador: $INSTALADOR_DIR"
|
||||
[[ -f "$CUSTOM_CSS_SOURCE" ]] && info "custom.css en instalador: presente" || warn "custom.css en instalador: no encontrado"
|
||||
[[ -f "${INSTALADOR_DIR}/LogoHome.png" ]] && info "LogoHome.png: presente" || warn "LogoHome.png: no encontrado"
|
||||
[[ -f "${INSTALADOR_DIR}/LogoAgent.png" ]] && info "LogoAgent.png: presente" || warn "LogoAgent.png: no encontrado"
|
||||
if [[ -f "$CUSTOM_CSS_DEST" ]]; then info "custom.css instalado: $CUSTOM_CSS_DEST"; else warn "custom.css instalado: no"; fi
|
||||
if [[ -f "${CUSTOM_CSS_DEST}${BACKUP_SUFFIX}" ]]; then info "Backup custom.css: ${CUSTOM_CSS_DEST}${BACKUP_SUFFIX}"; fi
|
||||
if [[ -f "$VICIDIAL_STYLESHEET" ]]; then
|
||||
installed_stylesheet && info "vicidial_stylesheet.php: referenciado" || warn "vicidial_stylesheet.php: no referenciado"
|
||||
fi
|
||||
if [[ -f "$ADMIN_HEADER" ]]; then
|
||||
installed_admin_header && info "admin_header.php: referenciado" || warn "admin_header.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"
|
||||
has_campaign_placeholders && info "vicidial.php: placeholders Campaign Login presentes" || warn "vicidial.php: placeholders Campaign no presentes"
|
||||
fi
|
||||
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 name in "$LOGO_WELCOME_NAME" "$LOGO_AGENT_LOGIN_NAME" "$LOGO_AGENT_PAGE_NAME"; do
|
||||
base="${name%.*}"
|
||||
ext="${name##*.}"
|
||||
if [[ -f "${dir}/${base}${OLDCUSTOM_SUFFIX}.${ext}" ]]; then
|
||||
info "Backup logo: ${dir}/${base}${OLDCUSTOM_SUFFIX}.${ext}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
ACTION="${1:-install}"
|
||||
case "$ACTION" in
|
||||
install) do_install ;;
|
||||
uninstall) do_uninstall ;;
|
||||
status) do_status ;;
|
||||
*)
|
||||
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 " status - Estado de archivos y referencias."
|
||||
echo ""
|
||||
echo "Contenido de installer/: custom.css, LogoHome.png, LogoAgent.png, este script."
|
||||
echo "Para otro ViciDial: HTDOCS=/ruta/htdocs /srv/www/htdocs/agc/css/installer/install_custom_css.sh install"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in new issue