English – Page 2 – jozefmares.com
Home Tags Posts tagged with "English"
Tag:

English

Introduction

It really sucks to keep two computers in sync. I am personally not able to keep anything in sync – that’s why I have to always find way how to automate stuff.

So, I have MacBook Air and Hack Pro. Both of computers are in active service (e.g. every day use). Hack Pro is utilised for very serious work which require at least dual-head, Air for creative (coffee shop) and external work. I want them in sync but not in full sync.

In my case there is also issue that Hack Pro have plenty of power to handle all tasks like filtering 10 000 of incoming mails from automated systems, build some of my software, play music with iTunes and even play full-hd video in the same time. On contrary, Air is just road warrior thing. Not so much of power but great portability. Thus, I do not want to do exactly same things on both but there are some essential things like keychain, some app configuration and so on which I want on both of them.

Prerequisites

  1. two Macs;
  2. own server / VPS, NAS, whatever;
  3. spare time;
  4. you are not afraid of terminal.

Basically we are going to setup ownCloud, setup sync via Unison and enjoy simpler life.

Unison

I talked about Unison before – check it here. It is very cool tool, and if you are user of some sort of Unix OS you really should check it!

When I talked about ownCloud I did not mentioned why I’m setting it up. If there is Unison, why do I need ownCloud? Simple answer – I want web access to data and I am using ownCloud for calendar and contacts synchronisation. Other cool thing is one-click sharing with ownCloud – I’m using it extensively.

Let’s go to terminal. Open your terminal emulator:

cd
mkdir .unison

Start your favourite text editor and go to .unison folder. We are going to create Unison configuration files. I have two profiles: dotfiles and files. These two profiles shares some common configuration.

common.prf

# Common options for Unison
fastcheck               = true
sortnewfirst            = true
rsrc                    = true
auto                    = true
confirmbigdeletes       = true
silent                  = true

# What to ignore
ignore = Name *~
ignore = Name *.lock
ignore = Name .DS_Store
ignore = Name .tmp
ignore = Name *.swp
ignore = Name *._localized

dotfiles.prf

# Sync roots
root = /Users/$USERNAME
root = ssh://YOUR-USER@YOUR-SERVER//home/USERNAME/TrustedPoint/dotfiles
include common

# What to synchronize
path = .bin
path = .ssh
path = .bashrc
path = .bash_profile
path = .gnupg
path = Library/Application Support/Adium 2.0
path = Library/Keychains/login.keychain
path = Library/Application Support/NetNewsWire

# Ignore these paths
ignore = Path {.gnupg/S.gpg-agent}

# Keep backup copy of every file on server
backuplocation = central
backup = Name *
backupprefix = $VERSION.
backupsuffix =

# Log actions
logfile = /Users/USERNAME/.unison/sync-dotfiles.log

files.prf

Sync roots
root = /Users/USERNAME
root = ssh://YOUR-USER@YOUR-SERVER//home/USERNAME/TrustedPoint/files
include common

# What to synchronize
path = Documents
path = Downloads

# Ignore these paths
ignore = Path Documents/Virtual Machines.localized

# Keep backup copy of every file on server
backuplocation = central
backup = Name *
backupprefix = $VERSION.
backupsuffix =

# Log actions
logfile = /Users/USERNAME/.unison/sync-files.log

Login via SSH to your server, install Unison (same version as you have on your Mac), create folder structure:

mkdir -p TrustedPoint/files
mkdir -p TrustedPoint/dotfiles

Please notice, I’m using SSH access – for automation use keys and password-less login.

ownCloud

I recommend use your own server or NAS or something like that because I’m assuming that you can use SSH and install Unison. Consider buying VPS if you do not have your own server.

About ownCloud installation: installation is simple as uploading application to web hosting folder, visiting folder in browser and fill your desired login info and optional MySQL database login info. Just check it for yourself.

After installation keep only these modules enabled:

  • Archive support;
  • Calendar (if you want to use it);
  • Contacts (same as calendar);
  • Share files;

It is good idea to disable Versions plugin. Unison keeps own versions (and I think Unison does it better) so it is redundant. For me it is even more useless because I use owncloud only as a web front-end to my data.

You might ask why I’m not using ownCloud native clients? Simple reason –Inotify and FSEvents.
There is problem with way how ownCloud client works – it polls and scans whole synchronised file tree which is CPU heavy and thus is eating my in MacBook Air battery. Using ownCloud native client can drain my Air battery in one hour. Guys from ownCloud project are currently implementing two technologies mentioned above, so there is a hope that Unison step will be unnecessary soon. But for now – it is a must.

Your data on ownCloud server are located in folder:

$INSTALL_DIR/data/$USERNAME

Go to folder and create symlink:

ln -s /home/$USERNAME/TrustedPoint/files files

Fire it up!

Pre-flight check list:

  1. ownCloud is running;
  2. you have tested Unison;
  3. you have enough of space on your server/NAS/whatever;
  4. you backed up your files;

Go for it:

unison dotfiles
unison files

Everything working? Congratulations! Run it on second Mac.

Create script to run it in batch

Put it whenever you want, I have mine in $HOME/.bin/.

#!/usr/bin/env bash

PID=$(pgrep unison)

[ -z $PID ] && unison dotfiles -batch && [ -z $PID ] && unison files -batch

Create boot plist files

Now to automate Unison via Launchd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

<dict>
<key>Label</key>
<string>org.azoy.Unison_sync</string>

<key>Program</key>
<string>/Users/$USERNAME/.bin/unison_sync.sh</string>

<key>LowPriorityIO</key>
<true/>

<key>RunAtLoad</key>
<true/>

<key>StartInterval</key>
<integer>1200</integer>

</dict>
</plist>

And save it to /Users/USERNAME/Library/LaunchAgents/unison_sync.plist.

Load it with plutil:

plutil -lint ~/Library/LaunchAgents/unison_sync.plist

You can try to reboot to check if everything is working as expected.

Conclusion

So you are in the end and this setup is working for you? I’m glad to hear it. I’m using it over 3 months I’m pretty happy with it.

To answer few questions:

  • Yes, you can achieve same thing with DropBox – I’m not using public “cloud” services;
  • Yes, you do not need Unison if you do not care about your battery. It’s up to you;
  • Yes, I enjoy DIY;

My post series about building true Mac-based workstation is coming to the end. Hack Pro has been working fine but one last thing was not done – sleep.

It wasn’t deal breaker but I like it when things work just like a charm. So I needed to add a little magic to boot process of my Hack Pro.

But first things first – check my hardware in this post as ways how to achieve correct sleep vary. This post is just about my motherboard and setup.

I hoped that my motherboard will work without patching DSDT but this is just not true. You need custom DSDT for Asrock Z68 Pro3-M, where you will patch wake function. Computer goes correctly to sleep but wont wake up.

First – make sure you have working hardware (sound card, ethernet, wifi, system definition and so on).

Second – try reboot few times to make sure everything is working. Boot with -v (check these boot flags) and check everything is working as expected.

Got it? Let’s go!

Get your copy DSDT Editor. You know what is DSDT is, right? You know how to work with it? If not, read something about it – you can harm your computer. :)

Patching DSDT for Asrock Z68 Pro3-M is very easy. Just extract DSDT from your machine, find line containing something like this:

PCI0.SBRG.SIOW (Arg0)

and delete it. Your line may vary, try search in file. Build DSDT.aml, copy it to /Extra and reboot.

Your machine should now sleep and resume like native Macs.

You can find few obstacles during basic steps with your Hackintosh. This post covers what you can do to resolve ones.

Your Hack Pro won’t boot after install on integrated graphic adapter

Go to BIOS / UEFI and change primary graphic adapter to discrete (PCI, PCI Express). I haven’t dig into problem but I think it has something with GraphicsEnabler.

Your Hack Pro won’t boot after install at all

You should try to boot with -v option to see what is going on. Usually if there is a problem with kernel extension (kext) you can try to boot with -x -v.

You see error with AppleIntelCPUPowerManagement.kext

You did not installed some utils from Multibeast like patched kexts. You do not need to reinstall whole system as some forums suggests. Just boot with install USB key, mount drive (it is in top menu – you need to remount it to read-write mode), start terminal and execute:

mv /System/Library/Extensions/AppleIntelCPUPowerManagement.kext /Users/YOUR_USERNAME/

Reboot with -f parameter passed to bootloader.

You see error related to ACPI_SMC_PlatformPlugin

You can even see in boot log (if you are debugging some problem always boot with -v):

ACPI_SMC_PlatformPlugin: :start - waitforservice(resourcematching(appleintelcpupower management) timed out...)

Try pass these parameters to boot loader:

PCIRootUID=1 -v

Sometimes is restart only thing you need.

You see just spinning wheel during boot

Try booting with GrahphicsEnabler=No

I’m desperate

Ask on forum, but give people informations like your hardware, OS X version, boot parameters, what you have installed from Multibeast and so on. Good luck!

You can try these forums and sites for example:

tonymacx86
InsanelyMac
Olarila