[How to] Master/Slave system with Crystalbuntu2/Pi or XBMCBuntu/Pi
#1
For the latest updated version of this, please see http://teknogeekz.com/blog/?p=560. It has been updated and simplified and tested with Gotham

I was looking to better synchronize the systems so I would not have to install and configure all add ons multiple times. Also I wanted to avoid having to configure all sources and media sources across multiple systems in the same house.

After beating my head against the wall and always determining it must be a brick wall , I came up with the method below which mounts the folders from the ATV1 to the corresponding locations on the Pi, and via use of symlinks even allows the configuration for most add ons to work on either system. An New Network media source can be added to either the pi or the ATV1, and would be valid for both. We now need add the source to one system, and it will be recognized by all systems, and works for system favourites too. It allows sharing add ons and synchronizing between Crystalbuntu2 (master) and RaspBMC (slave). This even works for system favourites!

It may Also work with xbmcbuntu as master, see notes and use /home/xbmc in place of /home/atv in commands below.

My Apple TV 1 runs crystalbuntu 2 . My Pi is running Raspbmc . ATV Is running mysql server and has a fixed IP of 192.168.1.2

First make sure you are configured for a shared database

my advancedsettings.xml is the basic (no path substitution)
Code:
<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>192.168.1.2</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </videodatabase>
    <musicdatabase>
        <type>mysql</type>
        <host>192.168.1.2</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </musicdatabase>
    <videolibrary>
        <importwatchedstate>true</importwatchedstate>
    </videolibrary>
</advancedsettings>


Log into ATV1 via SSH

install and configure nfs server
Code:
sudo apt-get install nfs-kernel-server

Make symlink so that add ons configured for Pi Paths work on ATV so even if you import addon data from either pi or ATV, they will work. (change destination path to /home/xbmc for xbmcbuntu)
Code:
sudo ln -s /home/pi /home/atv

sudo nano /etc/exports
Add the following lines to the end of the file
Code:
/home/atv/  *(rw,async,no_root_squash,no_subtree_check)
/media      *(rw,async,no_root_squash,no_subtree_check)

Log into raspberry Pi via ssh
Make symlink so that add ons configured for ATV Paths work on Pi (change symlink to /home/xbmc if xbmcbuntu is master)
Code:
ln -s /home/pi /home/atv

the following mounts the ATV folders on the Raspberry Pi
Code:
sudo nano /etc/fstab

create empty folders for mount points (some of these folders may not exist on your Pi system unless you created them
Code:
mv /home/pi/.xbmc/addons home/pi/.xbmc/addonsOLD
mv /home/pi/.xbmc/userdata/addon_data /home/pi/.xbmc/userdata/addon_dataOLD
mv /home/pi/Videos /home/pi/VideosOLD
mv /home/pi/Pictures  /home/pi/PicturesOLD
mv /home/pi/Music  /home/pi/MusicOLD
mkdir /home/pi/.xbmc/addons
mkdir /home/pi/.xbmc/userdata/addon_data
mkdir /home/pi/Videos
mkdir /home/pi/Pictures
mkdir /home/pi/Music
mkdir /home/pi/Pictures
mkdir /home/pi/.xbmc/shareduserdata

edit fstab to mount ATV disk on Pi
Code:
sudo nano /etc/fstab

Add the following lines to the end of the file you may not need all of these or may have different needs
Code:
192.168.1.2:/home/atv/.xbmc/addons                /home/pi/.xbmc/addons               nfs     _netdev,defaults,user,auto,noatime,intr   0 0
192.168.1.2:/home/atv/.xbmc/userdata/addon_data   /home/pi/.xbmc/userdata/addon_data  nfs     _netdev,defaults,user,auto,noatime,intr   0 0
192.168.1.2:/home/atv/Videos                      /home/pi/Videos                     nfs     _netdev,defaults,user,auto,noatime,intr   0 0
192.168.1.2:/home/atv/Pictures                    /home/pi/Pictures                   nfs     _netdev,defaults,user,auto,noatime,intr   0 0
192.168.1.2:/home/atv/Music                       /home/pi/Music                      nfs     _netdev,defaults,user,auto,noatime,intr   0 0
192.168.1.2:/home/atv/.xbmc/userdata              /home/pi/.xbmc/shareduserdata       nfs     _netdev,defaults,user,auto,noatime,intr   0 0

(SKIP THE STEP BELOW IF XBMCBUNTU IS MASTER! XBMC does not run as root on xbmcbuntu)
Now we will make xbmc run as root on the pi , as the user folders o ATV created by xbmc are root:root this ensures we can access them all on ATV without issues

edit
Code:
nano /scripts/xbmc-watchdog.sh
there are three lines that say "su - pi" . We need to change these to "su - root"

(SKIP THE STEP BELOW FOR XBMCBUNTU AS MASTER! XBMC does not run as root on xbmcbuntu)
Next we clear out the old user folders (if they exist) from the root user . If you have not yet run xbmc as root thdey probably do not exist
Code:
cd /root/.xbmc
sudo mv addons addonsOLD
sudo mv media mediaOLD
sudo mv sounds  soundsOLD
sudo mv system  systemOLD
sudo mv temp tempOLD
sudo mv userdata userdataOLD
sudo mv wizard wizardOLD


(SKIP THE STEP BELOW FOR XBMCBUNTU AS MASTER! XBMC does not run as root on xbmcbuntu)
Create softlinks from root user to pi user

Code:
cd /root
sudo ln -s /home/pi/.xbmc .xbmc
sudo ln -s /opt/xbmc-bcm .xbmc-current
sudo ln -s /home/pi/.upgrade .upgrade    
sudo ln -s /home/pi/.smb .smb  
sudo cd /root/.xbmc
sudo ln -s /home/pi/.xbmc/addons addons
sudo ln -s /home/pi/.xbmc/media media
sudo ln -s /home/pi/.xbmc/sounds sounds
sudo ln -s /home/pi/.xbmc/system system
sudo ln -s /home/pi/.xbmc/temp temp
sudo ln -s /home/pi/.xbmc/userdata userdata
sudo ln -s /home/pi/.xbmc/wizard wizard

Now reboot atv and after it has rebooted completely (wait several minutes after xbmc GUI appears on ATV1) , then reboot the Pi. After the Pi reboots you should see the addos installled on ATV1 on the raspberry Pi. If not you have done something wrong

Now we can make symlinks from userdata to shared versions on shareduserdata on the Pi (IMPORTANT FOR A WORKING SHARED MYSQL DATABASE AS THIS SYNCHRONIZES THE SOURCES!)
Code:
cd /home/pi/.xbmc/userdata
sudo ln -s /home/pi/.xbmc/shareduserdata/passwords.xml passwords.xml
sudo ln -s /home/pi/.xbmc/shareduserdata/sources.xml sources.xml
sudo ln -s /home/pi/.xbmc/shareduserdata/mediasources.xml mediasources.xml


in the end we configure either the master system (ATV1) or slave system (pi) so that we are looking at Video and music files from LOCAL FOLDERS, contrary to typical documentation for a shared database. ex; /home/atv/Videos/Movies and not smb://192.168.5.1/home/videos. Since the database only cares that the path is consistemt, we can now have consistent paths on Pi and ATV because of softlinks created earlier. It does not matter if we do this on Pi or ATV


I also added some symlinks as follows. In the example below , this causes system favourites to be synchronized. You may also want to symlink playlists and thumbnails from userdata to shareduserdata in the same way.
Code:
sudo mv /home/pi/.xbmc/userdata/favourites.xml /home/pi/.xbmc/userdata/favourites.old
sudo ln -s /home/pi/.xbmc/shareduserdata/favourites.xml /home/pi/.xbmc/userdata/favourites.xml


Some add ons can be configured for a mysql database and this is highly recommended. Some Add ons have proven problematic but you might avoid problems if you do not use the remote addon_data folder and instead maintain a local set of addon_data files for each system

If you add an add on you may need to reboot the other machine before it is recognized. It is highly recommended to always reboot the ATV1 (master) then after it has started completely start the Pi (slave).

I had no luck accessing the NFS shares from ATV1 on the Pi with the XBMC GUI, so you will need to add them to /etc/fstab if you want to mount an ATV USB disk . If you use consistent mount points on both systems the shared database will work. (remember the atv/pi symlinks surmount the path differences)
Reply

Logout Mark Read Team Forum Stats Members Help
[How to] Master/Slave system with Crystalbuntu2/Pi or XBMCBuntu/Pi0