#!/bin/bash

input_file="/etc/my.cnf"

# List of removed MySQL variables
removed_variables=(
"com_alter_db_upgrade"
"innodb_available_undo_logs"
"Qcache_free_blocks"
"Qcache_free_memory"
"Qcache_hits"
"Qcache_inserts"
"Qcache_lowmem_prunes"
"Qcache_not_cached"
"Qcache_queries_in_cache"
"Qcache_total_blocks"
"Slave_heartbeat_period"
"Slave_last_heartbeat"
"Slave_received_heartbeats"
"Slave_retried_transactions"
"Slave_running"
"bootstrap"
"date_format"
"datetime_format"
"des-key-file"
"group_replication_allow_local_disjoint_gtids_join"
"have_crypt"
"ignore-db-dir"
"ignore_builtin_innodb"
"ignore_db_dirs"
"innodb_checksums"
"innodb_disable_resize_buffer_pool_debug"
"innodb_file_format"
"innodb_file_format_check"
"innodb_file_format_max"
"innodb_large_prefix"
"innodb_locks_unsafe_for_binlog"
"innodb_scan_directories"
"innodb_stats_sample_pages"
"innodb_support_xa"
"innodb_undo_logs"
"internal_tmp_disk_storage_engine"
"log-warnings"
"log_builtin_as_identified_by_password"
"log_error_filter_rules"
"log_syslog"
"log_syslog_facility"
"log_syslog_include_pid"
"log_syslog_tag"
"max_tmp_tables"
"metadata_locks_cache_size"
"metadata_locks_hash_instances"
"multi_range_count"
"myisam_repair_threads"
"old_passwords"
"partition"
"query_cache_limit"
"query_cache_min_res_unit"
"query_cache_size"
"query_cache_type"
"query_cache_wlock_invalidate"
"secure_auth"
"show_compatibility_56"
"skip-partition"
"sync_frm"
"temp-pool"
"time_format"
"tx_isolation"
"tx_read_only"
)

# Comment out the removed variables in the input file
for variable in "${removed_variables[@]}"; do
    sed -i "s/^$variable/#$variable/g" "$input_file"
done

echo "Removed MySQL variables commented out in $input_file"
