September 14, 2007, 06:56:12 am
News:
  Pages: 1 [2]
Author Topic: Howto: Mount your network shares on bootup  (Read 2830 times)
yanvrno
Jr. Member

Posts: 71


« Reply #15 on: May 04, 2007, 09:45:14 am »

Ah Ha!!! found my problem

Seems my text editor was adding a hidden ^M at the end of every line (only could see it in vi editor)
By using the OSD vi editor I could see and remove them.
Now it works, Thanks Guys, I learned a few new things about scripts also.

Couple of new question:
Will this have to be recreated after each new version updates? Will it overight the directories?
Is it possible to to add an alias within this script example: alias ll="ls -l" or must that be in the bash shell script?
(eveytime I login I have to create new aliases)

I've also started to experiment with the Lua program anyone been writing scripts with it?
Now that we have a place to store scripts.  I assume we could run boot up routines using Lua.
I suppose you could direct the rc.user script to a SD card script

Thanks again for you help, this thing rocks more and more. If we could now turn on and off the record feature via the network it would be complete for me.
« Last Edit: May 04, 2007, 06:47:44 pm by yanvrno » Logged
yanvrno
Jr. Member

Posts: 71


« Reply #16 on: May 08, 2007, 12:25:16 pm »

thought I'd share my scripts to start up on a cold boot: my network shares, ftp and web server applications, thanks for your help guys.

~ # cd /mnt/OSD
/mnt/OSD # cat rc.user
   #!/bin/sh
   sh /mnt/OSD/bootscript2.sh > /mnt/OSD/boot.txt 2>&1 &
   sh /mnt/tmpfs/media/SD-card/bftpd/run-ftpserver.sh > /mnt/OSD/ftp.txt 2>&1 &
   sh /mnt/tmpfs/media/SD-card/corehttp/run_corehttp.sh > /mnt/OSD/core.txt 2>&1 &

/mnt/OSD # cat bootscript2.sh
   #!/bin/sh
   sleep 10
   mkdir /media/tigerC
   mkdir /media/tigerD
   mkdir /media/debian
   mkdir /media/laptop
   mount.cifs //192.168.1.33/OSDVideo /media/tigerC -o user=guest,pass=password,rw,nolock
   mount.cifs //192.168.1.33/D /media/tigerD -o user=guest,pass=password,rw,nolock
   mount.cifs //192.168.1.101/osd /media/debian -o user=guest,pass=password,rw,nolock
   mount.cifs //192.168.1.22/E /media/laptop -o user=guest,pass=password,rw,nolock

/mnt/OSD # cd /media/SD-card/bftpd
/mnt/tmpfs/media/SD-card/bftpd # cat run-ftpserver.sh
   #!/bin/sh
   sleep 15
   cd /mnt/tmpfs/media/SD-card/bftpd
   sleep 1
   ./bftpd -c ./bftpd.conf -D &

cd /mnt/tmpfs/media/SD-card/corehttp
/mnt/tmpfs/media/SD-card/corehttp # cat run_corehttp.sh
   #!/bin/sh
   sleep 60
   echo "Starting corehttp"
   /mnt/tmpfs/media/SD-card/corehttp/bin/corehttp /mnt/OSD/chttp.conf
Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #17 on: May 08, 2007, 01:45:43 pm »

Sweet, you're running the webserver. Do you really have to wait 60 seconds until it'll run? Have you tried getting any kind of Lua/CGI script running with it? That's a future project for me, after getting SSH going & maybe NTFS filesystem support.
-G
Logged
Tetrasys
Newbie

Posts: 1


« Reply #18 on: May 09, 2007, 05:49:46 pm »


I did notice the rc.user file is   -rwxr-Sr-t   (Sorry Im not aware of what the S attribute does)


Particularly interested in this line.  When I telnet in and execute my rc.user script, life is good.
But it does not execute on boot up.  What is the S in the file permissions, is it necessary for boot
action and what is the chmod command to get it?

If I am going down the wrong path, jump in here and tell me why rc.user is not functional at
boot time.

Thanks
Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #19 on: May 09, 2007, 07:59:00 pm »


I did notice the rc.user file is   -rwxr-Sr-t   (Sorry Im not aware of what the S attribute does)

From here, 'S' denotes the Set Userid bit, which is in the execute field. "This causes any persons or processes that run the file to have access to system resources as though they are the owner of the file."

My rc.user file does not have this, and works ok. Such a field is not necessary here, especially as the OSD really only has one user, root.

Quote
When I telnet in and execute my rc.user script, life is good.
But it does not execute on boot up.
So your script is ok, that's good. However, have you followed the guide closely? Simply putting mount commands into rc.user *does not work*. Nor did inserting a sleep command before the mounts. I don't fully understand why! Putting the mount commands in another script and calling that after a 10 second delay works.

Is this not working for you still? Are you using firmware 1.00? Just double check /etc/init.d/rc, at the bottom, that rc.user is being looked for & run.
-G

P.S. Welcome to the boards!
[/quote]
Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #20 on: May 09, 2007, 08:09:42 pm »

Couple of new question:
Will this have to be recreated after each new version updates? Will it overight the directories?
Is it possible to to add an alias within this script example: alias ll="ls -l" or must that be in the bash shell script?
(eveytime I login I have to create new aliases)
In the order they're asked:

- I'm not sure, but I'd doubt it. /mnt/OSD is mounted separately to everything else, and I think only the cramfs partition changes on firmware update. But this is just a guess, I wouldn't put my just-finished-life-story on the OSD just yet:)

- Aliases are defined in the shell. When you login via telnet, a new instance of busybox starts with default settings. I guess those settings are in the readonly part of the OSD. So I'm thinking it's not possible this way.
-G
Logged
yanvrno
Jr. Member

Posts: 71


« Reply #21 on: May 10, 2007, 08:23:04 am »

As far as the 60 second wait goes, I tried 15 seconds but after that didn't seem to work I went with 60  seconds. I never went back and fine tuned it thinking I could wait at least a minute.
As far as my questions you answered, I thought so but, wanted to be sure from someone else's experience.

Why would't your rc.user file also have the S attribute? Seems odd! Something about the process of creation or copying it from a different computer on the network?

can you explain what the following command  is doing? I understand what it is doing I just dont follow the logic.
2>&1 &

Thanks for your help.
« Last Edit: May 10, 2007, 08:35:52 am by yanvrno » Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #22 on: May 10, 2007, 10:50:11 am »

Hey,
you know you can save the std output of a command into a file using the > redirector:
"ls > listing.txt"

But this only sticks standard output into the file. If there's error messages, they're actually not included. You can get the error messages *only* using
"buggy_prog 2> errors.txt"

I think you can combine these two operations like so:
"buggy_prog > output.txt 2> errors.txt"

And "2>&1" lets you stick all error output into the same file as the standard output, as in &1 is a placeholder for the standard output file's name. Not exactly sure what's going on either,  but it's a useful thing I learned ages ago.
Hope this helps
-G
Logged
sadiekiller
Newbie

Posts: 12


« Reply #23 on: May 22, 2007, 02:15:27 am »

So I have no problem getting the script to execute, as I put the command to auto run the ftpserver on boot and it works fine, but my smb share will not load. here is my code

mount.cifs //PETENETDISK/ /media/Lacie_Media -o user=*,pass=*,rw,nolock

Is it better to use the ip? technically the stuff im trying to mount is in //PETENETDISK/media , but that didnt work either.

edit:  yeah, no matter what i do, it will not mount. it might just be my disk. I'm using the LaCie Ethernet Disk Mini. I'm pretty sure it does smb shares. as it does on my xbox in XBMC. but yeah, idk. it has stumped me.
« Last Edit: May 22, 2007, 02:30:57 am by sadiekiller » Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #24 on: May 22, 2007, 06:05:57 am »

I've found this too, and I'm not sure why this happens yet, I've not properly investigated. The only workaround I can suggest at the moment is to insert another 10 second sleep command between the mounts & starting ftp, I've found that helps.

My theory is that trying to init too many things at once slows the OSD down enough for the mounts to timeout.

Can you get any error output? I'll poke around later on today.
-G
Logged
sadiekiller
Newbie

Posts: 12


« Reply #25 on: May 22, 2007, 09:58:19 am »

I'll try the second sleep 10 command and see if it works. edit: It doesn't help at all. even putting only the mkdir and mount command doesn't work.

How would I get the error output? Edit: nvm i got it
Code:
mount error: could not find target server. TCP name PETENETDISK/media not found
No ip address specified and hostname not found

ill try the ip of the server

now i get (with //192.168.0.9/media):
Code:
could not update mount table

with only //192.168.0.9/ i get:
Code:
retrying with upper case share name
mount error 6 = No such device or address
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
« Last Edit: May 22, 2007, 10:27:29 am by sadiekiller » Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #26 on: May 22, 2007, 10:30:12 am »

now i get (with //192.168.0.9/media):
Code:
could not update mount table
Check this again, even though you get this error, the mount should be successful. The mount table can never be updated as it's on the read-only file system.

You need to specify a shared directory to mount a samba share, so trying the IP address only fails, with as you saw, an odd error message.
-G
Logged
sadiekiller
Newbie

Posts: 12


« Reply #27 on: May 22, 2007, 06:00:04 pm »

I tried it again, and again, it gave me the same error

also, it seems only to have a problem mounting on startup. if i run rc.user alone,via telnet, it mounts fine.

here is my bootscript.sh line for line:
Code:
#!/bin/sh
sleep 10

sh /media/CF-card/programs/ftpserver/run-ftpserver_spec.sh

sh /media/CF-card/programs/corehttp/run_corehttp.sh

mkdir /media/LaCie_Media
sleep 10
mount.cifs //192.168.0.9/media /media/LaCie_Media -o user=*,pass=*,rw,nolock

EDIT:: nevermind, i changed the second sleep command to 30, and when its done it still gives me that error, but mounts the drive and all.

thanks a ton for your help and the great way to mount the drives.
« Last Edit: May 22, 2007, 06:17:19 pm by sadiekiller » Logged
bagster
Newbie

Posts: 11


« Reply #28 on: September 10, 2007, 04:11:57 pm »

Maybe you can try to "mount" until the mount return code is not 0 (zero)?
Just add a sleep of 1 second to prevent hanging the osd?
I'll test it later (and i'll keep the delay it take, we can maybe use this later)...
Can be the same thing for httpd
Logged
greyback
Moderator
Sr. Member

Posts: 290


« Reply #29 on: September 11, 2007, 05:02:09 am »

Yeah, I've been finding things are funny with this. There should be no need to insert sleep commands at all really, but I've found I need to lengthen the duration of the pause as firmware update progress.

I don't believe the mount fails though. If it hung, the script would pause too surely? I found that if you wait long enough, all of a sudden those dodgy mounts just start working.

I'll bring this up on the mailing list, this can't be normal.

All I can suggest is keep sleep-ing (sorry...)
-G
Logged
  Pages: 1 [2]
Jump to: