I got it! Solution below. It isn't perfect; if I'm ever in range of my home network and not connected to it (probably not going to happen), it'll give me a bad host. But other than that, this should work:
Code:
wifi=`iwlist wlan0 scan|grep SSID`
if [[ $wifi == *MiWiFi* ]]
then
#Use special host file
echo "mydomain.homelinux.org 192.168.1.200" >> /etc/hosts
else
#Use the normal host file
cp /etc/hosts.bak /etc/hosts
fi
Just replace MiWiFi with my wireless network SSID, and replace mydomain.homelinux.org with my hostname, then put it in /etc/NetworkManager/dispatcher.d and I'm good! I'm hoping the NetworkManager scripts run as root, otherwise it won't work...