I maintain a bunch of apache vhosts on my computer for webdev, and thus have a bunch of "127.0.0.1 hostname" entries in my /etc/hosts file. However, since I ran updates a few days ago, my /etc/hosts file gets emptied on every reboot. I'm not really sure what other details to post about the issue... does anyone have any ideas?
Last edited by ojensen5115 (2012-07-14 19:34:24)
The new OpenRC will auto-update the localhost entries in /etc/hosts based on the hostname of the configured system, set in /etc/conf.d/hostname. What do you have in there and are you doing anything special with /etc/hosts?
I have, or rather had, about 15 entries of the form:
127.0.0.1 somehostname 127.0.0.1 someotherhostname 127.0.0.1 yetanotherhostname 127.0.0.1 yougettheidea ...
I have Apache set up such that I can access a local version of each website I work on by accessing http://somehostname/ (and http://somehostname.com/ for the live version). This lets me work locally then sync. Only, since my last update they all get wiped on every reboot, so now when I want to work on one of the sites, I edit /etc/hosts and add its entry back in, and then get to work.
Last edited by ojensen5115 (2012-07-09 22:55:08)
Don't know if this will work with openrc/baselayout or not, but did you try a one-liner?
127.0.0.1 MAIN-hostname someotherhostname yetanotherhostname yougettheide
Try alocating the vhosts to a different local address
127.0.0.1 MAIN-host 127.0.0.2 someotherhostname yetanotherhostname yougettheide
or use your actual IP address for the vhosts/aliases
127.0.0.1 main-host 192.168.1.123 someotherhostname yetanotherhostname yougettheide
@Overkill thanks! putting my vhosts on 127.0.0.2 makes them persist across reboots
Right now i filled a bug demanding such feature: http://bugs.funtoo.org/browse/FL-227
For any one who can be interested, i think a nicer workaround would be creating an executable hosts.start file inside /etc/local.d/ with someting like echo -e '127.0.0.1 local.foo\n127.0.0.1 local.var' >> /etc/hosts so after /etc/hosts boot generation your hosts would be added. Note you must run rc-update add local default.