Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sed command for /etc/hosts #72

Closed
hamhpc opened this issue Dec 8, 2017 · 7 comments
Closed

sed command for /etc/hosts #72

hamhpc opened this issue Dec 8, 2017 · 7 comments
Assignees
Labels
Documentation Update the docs or kind request for documentation. enhancement QC/UAC Quality Control and User Acceptance Required and Requested question

Comments

@hamhpc
Copy link
Member

hamhpc commented Dec 8, 2017

Hi.. I worked out this sed command to update /etc/hosts in CentOS 7. It might be easier to have in the documentation to do this than to have to explain how to do it in an editor. Plus helpful when those want to do scripted installs if we can come up with methods that help facilitate that.

sed -i 's|127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4|127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4\n127.0.0.1 islandora-docker.com fedora.islandora-docker.com apache.islandora-docker.com fedora apache|g' /etc/hosts

This is also a little different in that I'm adding a second 127.0.0.1 line after the localhost line to contain the ISLE names. This way they won't mess with their primary localhost entry for their OS.
So the end result is this:

[root@islandora-dev ISLE]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 islandora-docker.com fedora.islandora-docker.com apache.islandora-docker.com fedora apache
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@islandora-dev ISLE]#

@hamhpc hamhpc added Documentation Update the docs or kind request for documentation. enhancement labels Dec 8, 2017
@g7morris
Copy link
Member

g7morris commented Dec 11, 2017

@hamhpc I like the thinking here.

Tested the command locally:

Output after running command:

sed: 1: "/etc/hosts": extra characters at the end of h command

End result: (updated /etc/hosts file)

127.0.0.1 localhost
#127.0.0.1 localhost islandora-docker.com fedora web fedora.islandora-docker.com web.islandora-docker.com
255.255.255.255 broadcasthost

Does this look correct to you? @hamhpc

@hamhpc
Copy link
Member Author

hamhpc commented Dec 11, 2017

actually it doesn't. The logic here is to find the match for the first line:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

and replace it with the same line followed by a carriage return and the second line containing the isle host info. I think the tricky part here is that I think there needs to be a tab in the line and a copy paste might not copy properly. You can look at: https://github.com/hamhpc/ISLE-ks/blob/master/ks_ISLE.cfg for the version I'm using and appears to work when running it via kickstart.

The only issue is that the first line looks like this for CentOS:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

But I'm not sure it's the same convention for other OS's so that might need to be handled.

@g7morris
Copy link
Member

@hamhpc @McFateM @br2490 I've not heard back on how to advance with this command. Wondering if still needed given in isle.localdomain we use the extra_hosts: command to give the containers the appropriate DNS resolution. @br2490 Does this match your experience during your community alpha?

@g7morris g7morris assigned McFateM and br2490 and unassigned g7morris Jan 24, 2018
@g7morris g7morris added question QC/UAC Quality Control and User Acceptance Required and Requested labels Jan 24, 2018
@hamhpc
Copy link
Member Author

hamhpc commented Jan 24, 2018 via email

@br2490
Copy link
Member

br2490 commented Jan 25, 2018

@g7morris, yes my experience in Alpha2.

I'll add I've also had success using separately defined docker networks - I'm behind on my pre-alpha-alpha (Barnard was set for Feb, I jumped the gun) testing so hopefully by Monday I have something more meaningful to say.

I think there are several ways to accomplish this and extra_hosts is probably the fastest. I'd still like to investigate separate docker networks, one internal (all containers sit on this), and one external (such that only outward facing containers go here, i.e.: isle-apache).

@hamhpc in trying to keep with Docker practice we try to avoid editing the host file directly and let docker handle it. Gavin mentions extra_hosts which adds an unlimited number of entries into hosts, I'll mention hostname and domainname params too, but I fail to remember if compose respects them. knowing compose, it's like a 50/50.

edit, specifying which alpha.

@hamhpc
Copy link
Member Author

hamhpc commented Jan 25, 2018 via email

@g7morris
Copy link
Member

g7morris commented Feb 8, 2018

Closing ticket as requested.

@g7morris g7morris closed this as completed Feb 8, 2018
marksandford added a commit to ColgateUniversity/ISLE that referenced this issue May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Update the docs or kind request for documentation. enhancement QC/UAC Quality Control and User Acceptance Required and Requested question
Projects
None yet
Development

No branches or pull requests

5 participants