Automatically Update Host Files across several machines on a network (OS X)
Other *NIXThis forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I don't quite remember but if you connect to a remote server using SSH you get connected to the home directory of the user you are connecting as. So you should put for the second root statement:
if Users is in the root (/) of your remote server. I just checked my config to verify. I run it as root, connect as root to the remote server and syncronise directories under /opt so I had to put //opt as the second root reference.
Maybe this causes also the disconnection since you try to synchronise a non-existing directory/file combination.
Also you can put:
Code:
log = true
logfile = /var/log/yourunison.log
in your profile so that everything gets logged, just to debug/troubleshoot.
Ok, I've got this syncing host files on the desktop by doing the following
sudo unison -ui text profilename
however, when I set up a profile to sync within /private/etc/ (host file) on my two Macs, it throws a permission denied and fails to sync the host files. Any idea how to get around this as I'm already in super user mode?
Last edited by filterfann; 09-09-2010 at 03:25 PM.
Again, I'm not familiar with Mac in any way, but I'm thinking about encryption. Is the 'private' directory in any way encrypted? Don't see any other reason for why it woun't work, since you're already in super user mode.
You can open the directory but it's hidden. You can view it's contents through a text editor or terminal. However, you can only modify in super user mode via terminal. They have a terminal based text editor called Pico. I'm almost positive it's a permissions issue. I just have no idea how to get around it.
Bad news is, after doing a sync of host files, it somehow breaks the alias on my local host file rendering it non-functional. I had to grab my snow leopard disk to repair the host file.
I'm not exactly sure why it turns that file into an alias however since that is the location of the host file itself but in any case it dumps everything out of the file and when I click on it I get a fix alias error dialog box. When I try to view it in a terminal based text editor the file is completely empty and when I attempt to save it says the file is missing.
This is strange because I can already ssh into the other machine and remotely run a terminal base text editor and update the host file myself. I don't understand why this isn't working right. Both files have read/write permissions.
That's indeed a strange behavior, one I haven't come across yet. Maybe this from the Unison manual can help you:
Quote:
Symbolic Links
Ordinarily, Unison treats symbolic links in Unix replicas as “opaque”: it considers the contents of the link to be just the string specifying where the link points, and it will propagate changes in this string to the other replica.
It is sometimes useful to treat a symbolic link “transparently,” acting as though whatever it points to were physically in the replica at the point where the symbolic link appears. To tell Unison to treat a link in this manner, add a line of the form
follow = pathspec
to the profile, where pathspec is a path pattern as described in the Path Patterns section.
Windows file systems do not support symbolic links; Unison will refuse to propagate an opaque symbolic link from Unix to Windows and flag the path as erroneous. When a Unix replica is to be synchronized with a Windows system, all symbolic links should match either an ignore pattern or a follow pattern.
Ok, I got rid of the Unison software as it kept wiping out my host file. I did however find a solution that works perfect. Here it is.
tell application "Terminal"
do script "ssh Graphics3@192.168.1.54" in window 1
delay 3
do script "password" in window 1
delay 3
do script "sudo cp \"//Volumes//My X Server Drive//conf/hosts.txt\" /etc/hosts" in window 1
delay 3
do script "jdi123" in window 1
delay 3
do script "exit" in window 1
end tell
This AppleScript when ran will copy the new host file and paste it into the /etc directory. I can use CronTab to run these scripts automatically every 15 minutes. My question to you Eric now pertains to the Windows side of things.
What ssh client do you prefer for Windows? Also, what do I need to do as far as permissions go to copy the host file as Windows does not use sudo? I know of the admin account but XP doesn't have the user account control to elevate user privileges like Vista/7.
Ok, I got rid of the Unison software as it kept wiping out my host file. I did however find a solution that works perfect. Here it is.
tell application "Terminal"
do script "ssh Graphics3@192.168.1.54" in window 1
delay 3
do script "password" in window 1
delay 3
do script "sudo cp \"//Volumes//My X Server Drive//conf/hosts.txt\" /etc/hosts" in window 1
delay 3
do script "jdi123" in window 1
delay 3
do script "exit" in window 1
end tell
This AppleScript when ran will copy the new host file and paste it into the /etc directory. I can use CronTab to run these scripts automatically every 15 minutes. My question to you Eric now pertains to the Windows side of things.
What ssh client do you prefer for Windows? Also, what do I need to do as far as permissions go to copy the host file as Windows does not use sudo? I know of the admin account but XP doesn't have the user account control to elevate user privileges like Vista/7.
Thanks
Hello,
Glad to hear you got that part solved and sad to hear that Unison caused you problems. Has to be something typical to the OSX platform I think (or at least the version of Unison for that OS), at least I've never encountered that behaviour in Debian and/or RedHat.
I know Windows is strict on permissions. If I ssh in as admin, can I modify the host file without Windows throwing permissions denied messages? From what I'm familiar with, even though logged in as admin, Windows doesn't allow all admin privileges. I would have to log in to safe mode in order to have FULL admin rights. This is what I was after with the question. I hope this helps. I don't want to over complicate this as it is most likely not an issue.
Last edited by filterfann; 09-29-2010 at 11:15 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.