#Download Various Config Files wget -4 -q -np -nH -nd --cut-dirs=3 -A conf -r http://mirror.beyondhosting.net/provisioning/cpanel-automated-provisioning/mysql-conf/ -P /usr/local/beyondhosting/tmp/mysqlconf/ #Calculate checksums and store them in an array i=0 conf= cksum= for conf in $(find /usr/local/beyondhosting/tmp/mysqlconf/ -name "*.conf") ; do conf[${i}]=${conf} cksum[${i}]=$(md5sum ${conf} | cut -c1-32) let i+=1 done #Calculate checksum of active config md5mycnf=$(md5sum /etc/my.cnf | cut -c1-32) #Compare current MySQL Config to deployed configs. if [[ " ${cksum[@]} " =~ " ${md5mycnf} " ]] then #Do Things Here, configs are unmodified #Get VM's current memory ramsize=$( free -m | sed -n -e '/^Mem:/s/^[^0-9]*\([0-9]*\) .*/\1/p' ) #Define config flavor variables ram128gb=$(( 128*1024 * 7 / 8 )) ram64gb=$(( 64*1024 * 7 / 8 )) ram48gb=$(( 48*1024 * 7 / 8 )) ram24gb=$(( 24*1024 * 7 / 8 )) ram12gb=$(( 12*1024 * 7 / 8 )) ram6gb=$(( 6*1024 * 7 / 8 )) ram4gb=$(( 4*1024 * 7 / 8 )) # 128GB RAM if [ "$ramsize" -gt "$ram128gb" ] then configtype="128" # 64GB RAM elif [ "$ramsize" -gt "$ram64gb" ] then configtype="64" # 48GB RAM elif [ "$ramsize" -gt "$ram48gb" ] then configtype="48" # 24GB RAM elif [ "$ramsize" -gt "$ram24gb" ] then configtype="24" # 12GB RAM elif [ "$ramsize" -gt "$ram12gb" ] then configtype="12" # 6GB RAM elif [ "$ramsize" -gt "$ram6gb" ] then configtype="6" # 4GB RAM elif [ "$ramsize" -gt "$ram4gb" ] then configtype="4" else configtype="standard" fi # Calculate checksum of target config target_cksum=$(md5sum /usr/local/beyondhosting/tmp/mysqlconf/base-mysql-${configtype}.conf | cut -c1-32) if [ "${md5mycnf}" != "${target_cksum}" ] then # Grab the MySQL config cp /usr/local/beyondhosting/tmp/mysqlconf/base-mysql-$configtype.conf /etc/my.cnf # Restart MySQL systemctl restart mariadb fi fi #Clean up temp files rm -f /usr/local/beyondhosting/tmp/mysqlconf/*