This seems like a sane idea to me. I can’t imagine where THP are possibly valuable on a dedicated discourse instance, and overcommit can help avoid OOM.
Might consider offering to do each of these separately, setting them as the default response, with the non-default option to opt out?
Also, the script can use sysctl to find out whether the settings need to be changed in the first place before making a change. If someone has already made these changes with different files, it would be potentially confusing to create duplicate overrides. I think that not all Linux distros ship with memory overcommit turned off in the first place.
if $(sysctl -n vm.overcommit_memory) != 1 ; then
....
fi