Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    Windows shares and Squeezebox server

    Hi

    I'm a long-time user of Squeezebox server on the Windows platform having had various Squeezeboxes for about 7 years.

    I'm now trying to build a Linux-based (Ubuntu 10.04) server, knowing very little about this OS, but trying hard to get to grips with it.

    On the ubuntu machine I can access shared drives and read files on a networked Windows machine. However, these mounted shared drives do not show up in Squeezebox Server when browsing for the Music Folder.

    Is it possible for Squeezebox server running on this Ubuntu platform to use music files on a shared Windows drive? If it is, what do I need to do in order that this happens?

    Pardon the rather simplistic question but I'm right at the bottom of a steep learning curve!

    Thanks

  2. #2
    Senior Member aubuti's Avatar
    Join Date
    Oct 2005
    Posts
    8,824
    It is possible to browse shares on other machines without actually (logically) mounting the drives, but SBS requires the shares to be mounted to a mount point. Try setting up a mount point (usually on /mnt) for your Windows share and then mounting it. I usually use the command line, but there is probably a gui way to do it. After you get it working this way you will probably want to add a line in your /etc/fstab file so that the share is mounted automatically whenever Ubuntu boots.

    You also need to make sure that the music folders on the share are readable and "executable" (meaning a user can descend into the folder tree) by everyone, and that the music files themselves are readable by everyone. You can control this via the options on the "mount" command.

  3. #3
    Senior Member gharris999's Avatar
    Join Date
    Apr 2005
    Location
    Santa Fe, NM
    Posts
    3,495
    An example of what aubuti is talking about:

    On Ubuntu, open a terminal window and perform the following commands:

    Code:
    cd /mnt
    sudo mkdir /mnt/remotedir
    sudo chmod 777 /mnt/remotedir
    sudo mount -t cifs //windowsbox/sharename /mnt/remotedir -o user=username,pass=userpassword
    ..of course fixing up the 'windowsbox', 'sharename', 'username' and 'userpassword' strings to match your system. If the windows box is at a static ip address, you can substitute that ip address for the 'windowsbox' name.

    To unmount the share, do:

    sudo umount /mnt/remotedir

    To have the windows share mounted automatically every time ubuntu boots, see:

    http://ubuntuforums.org/showthread.php?t=288534

    Assuming that the share you want to connect to is password protected and you've created the /root/.smbcredentials file as outlined in those instructions, then you'll add a line like the following to your /etc/fstab file:

    Code:
    //windowsbox/sharename    /mnt/remotedir        cifs    credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
    SBS on your ubuntu box will then happily "see" all the files at /mnt/remotedir.

  4. #4
    Junior Member
    Join Date
    Feb 2011
    Posts
    5
    Thanks so much for those speedy responses.

    Followed your advice and got things working perfectly.

    What a great resource these forums are!

  5. #5
    Junior Member
    Join Date
    Mar 2011
    Posts
    6
    One thought on your setup...

    I did the same, installing Ubuntu Server on a Shuttle box I found on eBayŚworks nice.
    However, I considered that the reason why I wanted SBS was so that I didn't have to have other stuff running.

    Since HDs are huge these days, I decided to mirror my NAS music library onto the Ubuntu server. That way, besides cutting the dependency on the NAS, it reduces the amount of network traffic (SB=>SBS=>NAS becomes SB=>SBS).

    I have a cron job that runs daily on Ubuntu, mounts the NAS drive, kicks off rsync to perform the synchronization, unmounts the NAS drive, and then pings SBS to tell it to refresh the music library.

    If you are interested, say so and I'll post my shell scripts.

  6. #6
    Senior Member gharris999's Avatar
    Join Date
    Apr 2005
    Location
    Santa Fe, NM
    Posts
    3,495
    Quote Originally Posted by minor7flat5 View Post
    If you are interested, say so and I'll post my shell scripts.
    I'm interested! Post 'em please!

  7. #7
    Junior Member
    Join Date
    Mar 2011
    Posts
    6
    Since you asked...

    Code:
    #!/bin/bash
    #----------------------------------------------------------------------
    # Name:     rsync-music.sh
    #
    # Purpose:  Uses rsync to copy any new music from the "boron" NAS to
    #           the local Squeezebox server library and forces a rescan.
    #
    # Author:   Tad Harrison
    # Date:     2011-02-21
    #
    # Copyright 2011 by Tad Harrison
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 1, or (at your option)
    # any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #----------------------------------------------------------------------
    
    PATH=/bin:/usr/bin
    set -e
    logger "Begin: rsync music library"
    TEMP_DIR=$(mktemp -d)
    SOURCE_DIR=$TEMP_DIR/media/Music
    TARGET_DIR=/srv/squeezebox/music
    
    # A cleanup function that will unmount and remove the temporary directory.
    cleanup() {
      umount $TEMP_DIR || { echo "failed to unmount $TEMP_DIR"; exit 1; } 
      rmdir $TEMP_DIR
    }
    
    # Mount the Windows shared drive
    echo "Mounting media share to $TEMP_DIR"
    mount -t cifs -o guest,ro,iocharset=utf8 //boron.myhome.local/common $TEMP_DIR || { echo "failed to nmount $TEMP_DIR"; exit 1; } 
    
    # Trap errors so we can force cleanup of our mount point on error
    trap "cleanup; exit 1" INT TERM EXIT
    
    # -r        recurse into directories
    # -l        copy symlinks as symlinks
    # -t        preserve modification times
    # -v        verbose; shows each file moved over
    # --delete  deletes any files that have been deleted locally
    # --exclude excludes certain files from the rsync process
    # --chmod   applies permissions to target files
    COMMAND="rsync -rltv --delete --exclude=._*mp3 --chmod=Do=rx,Dg=rx,Du=rwx,Fo=r,Fg=r,Fu=rw $SOURCE_DIR/ $TARGET_DIR/"
    
    # Run the rsync command as "nobody" so the user and group are correct
    sudo -u nobody $COMMAND
    
    # Force a rescan of the library
    echo 'rescan' | nc magnesium.myhome.local 9090 -w1 >>/dev/null
    
    # Turn off trap so that we don't go into some loop here
    trap - INT TERM EXIT
    
    # Cleanup our mount point
    cleanup
    
    logger "End: rsync music library"
    The script is not too fancy, but I will add some notes here in the hope that it clarifies some of the more annoying details for others.

    This script was written to run under bash on an Ubuntu server as root. My NAS is a typical network appliance, a DNS-323.
    I initially tried using rsync-to-rsync, running rsync server on the DNS-323, but was underwhelmed by the performance.
    I then switched to using Samba to mount the Windows share locally, then used rsync local-to-local. This current script runs quite quickly.

    I have a local DNS that provides name resolution. The NAS is "boron.myhome.local" and the Ubuntu server is "magnesium.myhome.local" (I like element names). Replace these with IP addresses if you wish.
    The SOURCE_DIR points to the place on the NAS (under the mount point) where the root of my music library is.
    The TARGET_DIR points to the root of the local copy, /srv/squeezebox/music

    set -e

    Makes sure that errors cause the script to exit

    TEMP_DIR=$(mktemp -d)

    Used to create a temporary directory to use as a mount point. Use of /mnt for temporary stuff like this seems to be discouraged.

    cleanup()
    This function is designed to unmount the NAS and remove the temporary mount point. It is created as a function so that it can be referenced in a "trap" command further on.

    mount -t cifs ...
    Some key points here: the iocharset part was critical for me. This is what makes a song like ┴guas de Maršo.mp3 come across without messed up characters. The setting might need to be tweaked for your own situation.

    In my case, the share was "common" and it was configured as anonymous read.

    I added "ro" to the options for safety.

    trap ...
    This makes sure that no matter what happens with the rsync command, the mount is cleaned up.

    COMMAND="rsync ..."
    Each of the selected options is noted in the comments.
    I didn't use the "-a" option because it includes "-rlptgoD". Specifically, I wanted to exclude the "p", "g", and "o" options: these preserve permissions, group, and owner respectively. The problem is that the files on the NAS don't necessarily have the settings I want.
    The "--exclude" option skips dot-underscore files (._*.mp3) that my Macintosh loves to put in directories on the NAS—these are OS X metadata files.

    I used additional settings to set the target permissions of each file.

    sudo -u nobody $COMMAND

    This runs the rsync process as nobody. I have configured my Squeezebox server so that my full music library is owned by nobody:nogroup, but public read.

    echo 'rescan' ...

    This line is what pings the Squeezebox server to rescan the library.

    My crontab entry:
    Code:
    # m h  dom mon dow   command
    0 23 * * * /root/bin/rsync-music.sh 2>&1 >/dev/null
    Last edited by minor7flat5; 2011-03-09 at 18:56.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •