Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Automatically Wake Server and Mount Shares in Mac OS X

Featured Replies

I setup my server to automatically sleep when inactive and I wanted it to automatically wake up when I accessed one of the shares.  I was able to get it working using AutoFS and an executable map file.

 

Hopefully other Mac users will find this useful.

 

Contents of the executable map file are pasted below and attached in a zip

 

 

#!/usr/bin/perl

#--------------------------------------------------------------#

# AutoFS executable map to wake server when accessing a share. #

#                                                              #

# When a share is accessed we check to see if the server is    #

# awake and if not then a magic packet is sent to wake it up.  #

# The share is mounted when a successful ping response is      #

# received from the server.                                    #

#                                                              #

# Quick Setup:                                                #

#                                                              #

# 1. Set the values below to match your unRAID setup for      #

#    $host, $hwaddr, @shares, $user and $passwd                #

#                                                              #

# 2. Copy to /etc and set execute bit                          #

#    sudo cp auto_unraid /etc                                  #

#    sudo chmod +x /etc/auto_unraid                            #

#                                                              #

# 3. Add the following line to /etc/auto_master                #

#    /Volumes/unraid      auto_unraid                        #

#                                                              #

# 4. Load your changes                                        #

#    sudo automount -vc                                        #

#                                                              #

#--------------------------------------------------------------#

use strict;

 

# hostname or IP of unRAID server

my $host  = '192.168.1.100';

 

# MAC Address for unRAID server

my $hwaddr = 'XX:XX:XX:XX:XX:XX';

 

# array of AFP share names

my @shares = ("Documents","Development","Movies","TimeMachine");

 

# username and password for mounting shares

# set to empty string if not needed

my $user  = '';

my $passwd = '';

 

 

# =============================================================

# You should not need to modify anything below this point

# =============================================================

 

if (@ARGV == 0) {

    print join("\n", @shares)."\n";

    exit;

}

 

my $is_asleep = "ping -c1 -t1 ".$host." >/dev/null 2>&1";

system($is_asleep);

if ($? != 0) {

    use Socket;

    my $port        = getservbyname('discard', 'udp');

    my $hostaddr    = gethostbyname('255.255.255.255');

    my $sockaddr_in = pack_sockaddr_in($port, $hostaddr);

    my $proto      = getprotobyname('udp');

    my $pkt        = chr(0xFF) x 6 . join("", map {chr(hex($_))} split(/:/,$hwaddr)) x 16;

    my $count      = 0;

    socket(S, AF_INET, SOCK_DGRAM, $proto);

    setsockopt(S, SOL_SOCKET, SO_BROADCAST, 1);

    send(S, $pkt, 0, $sockaddr_in);

    do {

        $count++;

        system($is_asleep);

    } while ($? != 0 && $count < 15);

}

 

if ($user && $passwd) {

    print "-fstype=afp afp://".$user.":".$passwd."@".$host."/".$ARGV[0]."\n";

} else {

    print "-fstype=afp afp://".$host."/".$ARGV[0]."\n";

}

 

exit;

 

auto_unraid.zip

  • 4 weeks later...

I have been looking for exactly this, thanks! Need to try and implement something similar on my Vista laptop too :)

  • 3 months later...

This is exactly what I've been looking for too, thanks.

 

I've ran into a little difficulty though... I think I have it all set up properly but it doesn't wake my server.

 

I think it may be to do with the way I've mounted my shares on osx, I have just done it through go > connect to server. Do they have to be mounted so osx 'remembers' them somehow?

 

My end goal is to use the shares in xbmc. I have a mac mini attached to my tv but I am not experienced in osx. Any help appreciated!

  • Author

This is exactly what I've been looking for too, thanks.

 

I've ran into a little difficulty though... I think I have it all set up properly but it doesn't wake my server.

 

I think it may be to do with the way I've mounted my shares on osx, I have just done it through go > connect to server. Do they have to be mounted so osx 'remembers' them somehow?

 

My end goal is to use the shares in xbmc. I have a mac mini attached to my tv but I am not experienced in osx. Any help appreciated!

 

This will only wake the server if the share are accessed at the mount point you setup in your /etc/auto_master.  If you used /Volumes/unraid like the example in the script, then the server will only wake when you access /Volumes/unraid/Documents for example.

 

Instead of using "Go > Connect to Server"  use "Go > Go to Folder" and enter "/Volumes/unraid" or whatever you setup in your /etc/auto_master.  You should see a list of the shares you defined and clicking one of them will wake the server.

 

If you setup xbmc to point to the server through the mount point you setup it will wake the server when the share is accessed, just use the /Volumes/unraid/sharename paths.

 

Greg

Fantastic, thanks, I had a feeling it was something very basic about the process that had bypassed me  ::)

 

Working great now.

 

Thanks for the script and the help!

  • 4 weeks later...

Hello.

I'm glad someone made this script :-) As a complete n00b, I'm wondering if I run it on my mac or on the server. Obviously, it should be on the Mac, right?

 

I really want to use it because I'm storing all my music on the server and when I got micro-cut or complete disconnection, iTunes keeps reverting back the folder location of my library locally, thus all the music is "not found", I have to manually reset the location and do all the presets once again.

 

Envoyé depuis mon HTC Sensation XE with Beats Audio Z715e avec Tapatalk

  • Author

you set this up on your Mac

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.