Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Watch out for missing prefs if you change your hostname' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Watch out for missing prefs if you change your hostname
Authored by: a1291762 on May 28, '01 06:32:30PM

If you look in ~/Library/Preferences/ByHost you'll see a bunch of files like screensaver.localhost.plist (just an example, I'm not near my Mac right now :)

If you change your hostname, then you'll lose all of these settings.

In case you're wondering, these settings are for people that have their user folder stored on a network so they can set up different prefs for different machines. (This is something that will probably be seen more with OS X Server)

Anyway, after editing /etc/hostconfig, you'll want to run something like:

cd ~/Library/Preferences/ByHost
sh
files=`ls`
for file in $files; do
mv $file `echo $file | sed 's/MyOldName/MyNewName/g'`
done
exit

... yes it's a horrible UNIX script but it works.

here's what happens...

cd ~/Library/Preferences/ByHost
change directory (D'uh)

sh
start a bourne shell because csh (or tcsh) suck at scripts.

files=`ls`
create a list of the files here

for file in $files; do
think "for every file"

mv $file `echo $file | sed 's/MyOldName/MyNewName/g'`
rename the file. The sed bit swaps MyOldName for MyNewName.

done
required to terminate the for loop

exit
go back to your previous shell

...

Now the bad news :(

Some apps will create preference files with spaces in them. THIS IS REALLY BAD FOR UNIX SCRIPTS!
The line "for file in $files; do" splits the list of files by looking for spaces so it can't handle files with spaces in them. (There's probably a way to get this to work nicer but it would be really long)

... basically you'll have to rename any files with spaces manually (from the Finder or the command line). using mv "File 1.localhost.plist" "File 1.Robert.plist" works because of the quote characters.

Hope that helps...

Link :)



[ Reply to This | # ]