#!/usr/bin/env miaou-recipe # CONSTANTS SYMPA_GENERATOR=/usr/share/sympa/lib/Sympa/WWW/Tools.pm SYMPA_CSS=/usr/share/sympa/default/web_tt2/css.tt2 # FUNCTIONS function override_topbar { if ! grep -q '.top-bar button:hover' "$SYMPA_CSS"; then sed -i "1661i\\.top-bar button:hover{\\n color: white;\\n}" "$SYMPA_CSS" echo 'topbar changed successfully' fi } function apply_theme { local fqdn=$(hostname -f) [[ $fqdn == *cemea* ]] && apply_cemea_style || apply_zourit_style } function apply_cemea_style { sed -i "s/.*005ab2.*/\t\tdefault => '#000000', # '#005ab2' replaced by CEMEA-COLOR-1/" "$SYMPA_GENERATOR" sed -i "s/.*004b94.*/\t\tdefault => '#e30613', # '#004b94' replaced by CEMEA-COLOR-2/" "$SYMPA_GENERATOR" sed -i "s/.*0090e9.*/\t\tdefault => '#184857', # '#0090e9' replaced by CEMEA-COLOR-3/" "$SYMPA_GENERATOR" sed -i "s/.*66aaff.*/\t\tdefault => '#00a19a', # '#66aaff' replaced by CEMEA-COLOR-4/" "$SYMPA_GENERATOR" echo "CEMEA style applied successfully!" } function apply_zourit_style { sed -i "s/.*005ab2.*/\t\tdefault => '#ad0c78', # '#005ab2' replaced by ZOURIT-COLOR-1/" "$SYMPA_GENERATOR" sed -i "s/.*004b94.*/\t\tdefault => '#1f2937', # '#004b94' replaced by ZOURIT-COLOR-2/" "$SYMPA_GENERATOR" sed -i "s/.*0090e9.*/\t\tdefault => '#535786', # '#0090e9' replaced by ZOURIT-COLOR-3/" "$SYMPA_GENERATOR" sed -i "s/.*66aaff.*/\t\tdefault => '#949ba7', # '#66aaff' replaced by ZOURIT-COLOR-4/" "$SYMPA_GENERATOR" echo "ZOURIT style applied successfully!" } function clear_custom_styles { for i in /var/lib/sympa/css/*; do if [[ "$i" != '/var/lib/sympa/css/style.css' ]] && [[ -d "$i" ]]; then rm -rf "$i" echo "customized style: $i removed!" fi done } function refresh_style { systemctl restart wwsympa.socket } # MAIN set -Eue override_topbar apply_theme clear_custom_styles refresh_style