Author Topic: Autostart / Stop Samba On Wifi Card Insertion  (Read 2862 times)

lpetroni

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« on: January 20, 2007, 06:32:11 pm »
Just installed Cacko/Crow ROM (home on SD) + Cacko Kernel Update.

My WiFi Card is recognized with no problems and I was able to configure Samba over WiFi based on the guidelines posted on ZUG. The only problem is that Samba only auto starts on USB but I would like it to autostart when I insert my WiFi card and autostop when the card is removed.

So far I can only start Samba manually using samba start and stop commands.

Code: [Select]
#su
#/etc/rc.d/init.d/samba start

Complete Linux newbie here  
 
How do I write a script and where should it be placed?

Thanks!
Zaurus SL-5500
Cacko/CrowROM (64/0)

PQI 4GB CF
Lexar 128MB SD
Sandisk 256MB CF
Trellis WiFi CF

bam

  • Hero Member
  • *****
  • Posts: 1213
    • View Profile
    • http://thegrinder.ws
Autostart / Stop Samba On Wifi Card Insertion
« Reply #1 on: January 20, 2007, 10:26:05 pm »
you might look for network helper applet
SL-C3100 current: Stock/Tetsu 18h
Socket BT CF Card
Linksys WCF-12 802.11b/Cheapie USB Ethernet

The Grinder

lpetroni

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« Reply #2 on: January 21, 2007, 07:47:14 am »
Thanks for the reply bam.

For networkd helper applet you mean the Network Config Applet used to setup configurations (LAN/Wireless/IrDA) which is already installed with the system or a new ipk that I should install?

I did not find any option to autostart/stop Samba on Network Config Applet.

Thanks!


Quote
you might look for network helper applet
[div align=\"right\"][a href=\"index.php?act=findpost&pid=151853\"][{POST_SNAPBACK}][/a][/div]
Zaurus SL-5500
Cacko/CrowROM (64/0)

PQI 4GB CF
Lexar 128MB SD
Sandisk 256MB CF
Trellis WiFi CF

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3703
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« Reply #3 on: January 21, 2007, 09:59:48 am »
take a look in the /etc/pcmcia directory, lots of interesting scripts in there. be sure to take a backup copy before changing
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

lpetroni

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« Reply #4 on: January 25, 2007, 08:24:55 am »
Quote
take a look in the /etc/pcmcia directory, lots of interesting scripts in there. be sure to take a backup copy before changing
[div align=\"right\"][a href=\"index.php?act=findpost&pid=151903\"][{POST_SNAPBACK}][/a][/div]

Thanks for reply speculatrix. I will check your suggestion.

I suppose that a script is a plain text file with some kind of extension added to its name to identify it as a script. Is it right?

Is there any way to create a applet or a icon associated with this script ?

My idea was to plug my wifi card, start samba (using this applet/icon) and then make a connection with my mac.
Zaurus SL-5500
Cacko/CrowROM (64/0)

PQI 4GB CF
Lexar 128MB SD
Sandisk 256MB CF
Trellis WiFi CF

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3703
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« Reply #5 on: January 25, 2007, 10:23:08 am »
Quote
Thanks for reply speculatrix. I will check your suggestion.

I suppose that a script is a plain text file with some kind of extension added to its name to identify it as a script. Is it right?

Is there any way to create a applet or a icon associated with this script ?

My idea was to plug my wifi card, start samba (using this applet/icon) and then make a connection with my mac.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152377\"][{POST_SNAPBACK}][/a][/div]

a script is a text file whose first line identifies the intepreter, e.g. "#!/bin/bash" or "#!/bin/perl", where the magic part is the #!, and is then set executable, so when you "ls -la" it will look like this

-rwxr-xr-x ......

it's not like DOS/Windows where the file extension is implicit in the execution

adding icons to the desktop to run scripts is a different thing altogether, but yes, it is possible. There are various discussions about it here on the forum, I don't have a link to hand.
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

lpetroni

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Autostart / Stop Samba On Wifi Card Insertion
« Reply #6 on: January 25, 2007, 03:09:33 pm »
Quote
a script is a text file whose first line identifies the intepreter, e.g. "#!/bin/bash" or "#!/bin/perl", where the magic part is the #!, and is then set executable, so when you "ls -la" it will look like this

-rwxr-xr-x ......

[div align=\"right\"][a href=\"index.php?act=findpost&pid=152392\"][{POST_SNAPBACK}][/a][/div]


Speculatrix,

I created a simple text file using TextEdit:


#! /bin/bash
cd /
/etc/rc.d/init.d/samba start


Thens saved it under Documents/MyScripts/sambaup.txt
Renamed the file deleting the .txt extension.

Opened terminal and cd to Documents/MyScripts, then ls -la

It shows sambaup as

-rw-r--r-- .... so, no "x" (executable?)...

Is there any additional step to make the script executable so that I can run it in terminal and later assign it to a icon?

Sorry but I'm having a hard time with Linux  
Zaurus SL-5500
Cacko/CrowROM (64/0)

PQI 4GB CF
Lexar 128MB SD
Sandisk 256MB CF
Trellis WiFi CF

grog

  • Hero Member
  • *****
  • Posts: 692
    • View Profile
    • http://
Autostart / Stop Samba On Wifi Card Insertion
« Reply #7 on: January 25, 2007, 03:42:47 pm »
Quote
#! /bin/bash
cd /
/etc/rc.d/init.d/samba start
Make sure there's no space in the first line:

Code: [Select]
#!/bin/bashWhy the 'cd /' line? Shouldn't be necessary.

Quote
Thens saved it under Documents/MyScripts/sambaup.txt
Renamed the file deleting the .txt extension.

Opened terminal and cd to Documents/MyScripts, then ls -la

It shows sambaup as

-rw-r--r-- .... so, no "x" (executable?)...

Is there any additional step to make the script executable so that I can run it in terminal and later assign it to a icon?

Code: [Select]
chmod 755 ~/Documents/MyScripts/sambaup.txt
Quote
Sorry but I'm having a hard time with Linux 
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152436\"][{POST_SNAPBACK}][/a][/div]
No need to apologize. We all started from the same place
HTH
GROG!