Symbolic Link

Black Hole

May contain traces of nut
In case anybody's interested, I have added a symbolic link in /media to my [Unclassified] sweeper folder. I have HDR1 shared by SMB with my other machines, and at the top share level My Video, My Music, My Photo, plus any connected drives and virtual mounts are listed. This means to get to the general pool of recordings I have to click through My Video to [Unclassified] and then to the recording I want. With the symbolic link, [Unclassified] now appears in the top share level too (though I notice not in the WebIF), saving a layer of navigation.

How to:

Via the Telnet command prompt: ln -s "/media/My Video/[Unclassified]" /media/[Unclassified]

Adapt to your needs. Any string containing spaces needs to be enclosed in quotes or speech marks.

Update: read on!
 
OP
Black Hole

Black Hole

May contain traces of nut
Oh. It's disappeared. Perhaps that's why I couldn't see it in the WebIF media browser - it appears not to have survived a reboot, and yet a simlink I added to the streamer buffer (in My Video) is still there after months.
 

xyz321

Well-Known Member
That's because /media is mounted as a tmpfs. Everything in there has to be recreated at startup.
 

af123

Administrator
Staff member
You just need to create a script in /mod/etc/init.d that starts with a capital S followed by a sequence number. Something like /mod/etc/init.d/S99blackhole would do the job. S99 means it happens late on in the boot process but that's good as it ensures things like /media are available.
Code:
#!/bin/sh
 
ln -s "/media/My Video/[Unclassified]" "/media/[Unclassified]"
or
Code:
#!/bin/sh
 
video="/media/My Video"
folder="[Unclassified]"
[ -d "$video/$folder" ] && ln -s "$video/$folder" "/media/$folder"

if you want to get fancy, and make it executable

Code:
chmod 755 /mod/etc/init.d/S99blackhole
 
OP
Black Hole

Black Hole

May contain traces of nut
:thumbsup:

Good education.

For the benefit of other readers, it is worth commenting that the WebIF >> DIagnostics >> File Editor offers the options to create a file and to make it executable, no command line needed.
 
Last edited:
OP
Black Hole

Black Hole

May contain traces of nut
So, what does the line starting "[" (in the second example) do?? I get the "&&" (don't wait for previous command to complete), and the "ln -s" is creating the symbolic link from pre-declared string substitutions, but "[ -d ... ]" ?

My guess is it somehow tests whether the link target exists and does not process the bit after "&&" if not.
 

dandnsmith

Forum Supporter
Specifically tests for the existence of a directory of name
$video/$folder
where some substitution from the start of the script is to be performed
 
OP
Black Hole

Black Hole

May contain traces of nut
What's the matter here?:

On the HD-FOX, I created /mod/etc/init.d/S99blackhole:
Code:
#!/bin/sh
ln -s "/media/drive1/Video" "/media/My Video"
...and made it executable:
Code:
humax# ls -l /mod/etc/init.d
-rwxr-xr-x    1 root     root           276 Apr 24  2014 S00swapper
-rwxr-xr-x    1 root     root           207 May 13  2011 S01cifs
-rwxr-xr-x    1 root     root           142 Sep 25  2011 S01crond
-rwx------    1 root     root           734 May  7  2014 S01lighttpd
-rwxr-xr-x    1 root     root           104 Oct  8  2011 S02anacron
-rwxr-xr-x    1 root     root           193 Aug 21  2011 S02portmap
-rwxr-xr-x    1 root     root           300 Dec  4  2013 S30posttvcrash
-rwxr-xr-x    1 root     root           266 Sep 30 17:48 S40ir
-rwxr-xr-x    1 root     root           428 May  3 08:24 S54recmon
-rwx------    1 root     root           217 Feb 17  2015 S59webif
-rwxr-xr-x    1 root     root           320 Jan 12  2015 S60parseepg
-rwxr-xr-x    1 root     root           140 Oct 27  2011 S90netshares
-rwxr-xr-x    1 root     root            57 Oct 10 13:43 S99blackhole
-rwxr-xr-x    1 root     root           147 Jul 30  2011 Z99smartd
humax#
...and rebooted, but there is no "My Video" shortcut appearing in my Media list (just the usual "drive1" plus the auto-mounts HDRFOX1, HDRFOX2, HDRFOX3).

Is there something different about the HD-FOX file system which stops this working, maybe in that I am trying to create this symbolic link at the drive level rather than the folder level? Could network-shares-automount be tricked into mounting the Video folder if I install samba and use the loop-back IP address?

Curiously, /media/My Video is present when viewed via the WebIF media browser - so what's different about the auto-mounts?
 
Last edited:
OP
Black Hole

Black Hole

May contain traces of nut
Nope, I don't seem to be able to get network-shares-automount to do its stuff (for the local storage) either. The HD-FOX shows up in Windows Explorer, so samba must be doing its job.

The only other variable is what the modsettings should be; I have tried every combination of:

host=127_0_0_1 | host=192_168_1_23

folder=drive1_Video | folder=media_drive1_Video| folder=Media_drive1_Video

Anybody got any ideas?
 
Last edited:
OP
Black Hole

Black Hole

May contain traces of nut
This works (but does not achieve the desired result):

host=192_168_1_23
folder=drive1

And so does this:

host=127_0_0_1
folder=drive1
 

MontysEvilTwin

Well-Known Member
The smb mount point for 'media' is included by default in /mod/etc/smb.conf and a mount point for 'drive1' appears in smb-hotplug.conf. If you want to mount the video folder on the HD-FOX you need to define it in smb.conf. Pasting the following at the end of smb.conf should do the trick;
Code:
[Video]
   comment = Video
   path = /media/drive1/Video
   public = yes
   writable = yes
   browsable = yes
   create mask = 0644
   directory mask = 0755
   hide dot files = no
With the above example set 'folder=Video' in the configuration folder on the remote machine to access it.
If you want a 'My Video' folder in the USB section of the HD-FOX GUI, you can do it with a 'network' share. I've done this with NFS. If you call the share 'My Video', set 'folder=_media_drive1_Video' and 'host=' to the units own IP address it will work. You could probably also do this as an smb share once you have made the above modification to smb.conf.
 
Last edited:
OP
Black Hole

Black Hole

May contain traces of nut
Problem solved using an NFS auto-mount. It remains a mystery why the symbolic link works on an HDR-FOX, and shows up in the WebIF media browser on a HD-FOX, but does not get listed in the SUI media browser on a HD-FOX.
 

cdmackay

Active Member
No, && is a logical short-circuiting and. If the bit before the && evaluates to false the right hand side will not be evaluated/executed.

In layman's terms, this is used to conditionally do something if something else succeeds. It's just like "if THIS succeeds then do THAT".

e.g for the '&&' AND case:

Code:
mkdir test_dir && echo "test directory successfully created"

use '||' for the OR case, i.e. if something fails:

Code:
mkdir test || echo "unable to create test directory"

You wouldn't normally see both || and && used together; that would normally be done with a traditional if/then/else clause; although it could be fiddled with || and &&.
 

af123

Administrator
Staff member
I don't think it's uncommon, I've often seen statements like

Code:
[ "$1" = "-d" ] && debug=1 || debug=0
 
OP
Black Hole

Black Hole

May contain traces of nut
In layman's terms, this is used to conditionally do something if something else succeeds. It's just like "if THIS succeeds then do THAT"...
Thanks for that, but you have replied to something from a long time ago.

The way I have interpreted these constructs is conditional execution by a quirk of implementation: the && and || are logical AND and OR respectively, not in themselves IF or IF NOT, but by optimisation if the first term in a AND statement is false there is no need to evaluate the second term (because its result is irrelevant), and if the first term in an OR statement is true there is no need to evaluate the second term - hence the optimisation sets up conditional execution without having to explicitly state IF... THEN or IF NOT.. THEN.

However, as discovered by my initial introduction to this concept, it is a programmers shorthand which does not make for self-documenting code.

Now, back to the plot, can anyone explain this?:
It remains a mystery why the symbolic link works on an HDR-FOX, and shows up in the WebIF media browser on a HD-FOX, but does not get listed in the SUI media browser on a HD-FOX.
 

af123

Administrator
Staff member
The way I have interpreted these constructs is conditional execution by a quirk of implementation:
No, it's explicitly by design and common across many programming languages. Take the following example from C

Code:
If (val && strlen(val))

That's something you'll see in pretty much every C program. Calling strlen with a null argument would crash the program. The fact that the strlen call is not done if val is false is absolutely essential.

it is a programmers shorthand which does not make for self-documenting code.

To those familiar with the language, it's as clear as any other construct.

Now, back to the plot, can anyone explain this?:
Not at present but I intend to experiment when I get back home.
 
Top