maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   Running script when network interface is up (https://talk.maemo.org/showthread.php?t=88976)

sargas 2013-02-03 16:29

Running script when network interface is up
 
Hi all,

i am trying to run this script when network interface is up on my N9:

Code:

#!/bin/sh
date >> /root/data

The script path is:

Code:

/etc/network/if-up.d/50_connect_home
The file /root/data is an existing empty file.


Upon connecting to my wlan, the file /root/data is still empty, which suggests the script does not run.

Any pointers?

Thanks,
sargas.

ffha 2013-02-03 16:35

Re: Running script when network interface is up
 
Forgive me if I'm wrong, for I don't have a N9 myself, but doesn't Aegis prevent modification of files owned by root, even by root itself?

Try to append the data to a file in your home folder.

sargas 2013-02-03 18:26

Re: Running script when network interface is up
 
Quote:

Originally Posted by ffha (Post 1320457)
Forgive me if I'm wrong, for I don't have a N9 myself, but doesn't Aegis prevent modification of files owned by root, even by root itself?

I guess not since i can execute the script manually, as root, and the file gets modified.

Quote:

Originally Posted by ffha (Post 1320457)
Try to append the data to a file in your home folder.

Trying with /home/user/data, like sugested, has no effect either.
I think there is something more to be done than just putting the script in /etc/network/if-up.d/ but i can't figure it out.

Wikiwide 2013-02-03 22:33

Re: Running script when network interface is up
 
Quick reply...
Look up file "/etc/network/interfaces". Besides lines "address ...", "netmask ....", "gateway ...", there can also be lines "up ...." and "down ..." - to run scripts when a connection starts and stops.
Best wishes.

anthonie 2013-02-03 22:57

Re: Running script when network interface is up
 
So, what does your check for ifup look like? The condition itself, if you like, not what you do if and when the condition is met.

Wikiwide 2013-02-04 03:56

Re: Running script when network interface is up
 
Quick reply...
Contents of file "/etc/network/interaces":
Code:

auto usb0
iface usb0 inet static
        address 192.168.2.15
        netmask 255.255.255.0
        gateway 192.168.2.14
        up /usr/lib/sdk-connectivity-tool/usbdhcpd.sh 192.168.2.14
        down /usr/lib/sdk-connectivity-tool/usbdhcpd.sh stop

With appropriate setup on PC, it allows to give Internet from PC to Harmattan device.
Best wishes.

ii343hbka 2013-02-04 04:37

Re: Running script when network interface is up
 
try to set a execute bit
Code:

sudo chmod +x path_to_script
also you can try to use full path for echo instead of it's binary name
or jsut set up a PATH variable
Code:

#!/bin/sh
PATH=$PATH:/bin


peterleinchen 2013-02-04 09:43

Re: Running script when network interface is up
 
Quote:

Originally Posted by ii343hbka (Post 1320612)
try to set a execute bit
Code:

sudo chmod +x path_to_script

This could be the cause here.

sargas 2013-02-04 18:25

Re: Running script when network interface is up
 
Quote:

Originally Posted by Wikiwide (Post 1320558)
Quick reply...
Look up file "/etc/network/interfaces". Besides lines "address ...", "netmask ....", "gateway ...", there can also be lines "up ...." and "down ..." - to run scripts when a connection starts and stops.
Best wishes.

Thanks, but still not working. I have tried to add:
Code:

 
auto wlan0
        iface wlan0 inet dhcp
        up /etc/network/if-up.d/50_connect_home

to /etc/network/interfaces

Also tried just one line at end of file:
Code:

up /etc/network/if-up.d/50_connect_home
The script does not run.

Edit: fixed code tags.

sargas 2013-02-04 18:27

Re: Running script when network interface is up
 
Quote:

Originally Posted by peterleinchen (Post 1320663)
This could be the cause here.

Thanks, but first thing i've tried was to set the script executable.

ii343hbka 2013-02-04 20:14

Re: Running script when network interface is up
 
may be /var/log/syslog might show something

Wikiwide 2013-02-04 22:51

Re: Running script when network interface is up
 
Quick reply...
Copy your script from if-up.d directory to another directory, and change file's name. Point "up ..." line of "/etc/network/interfaces" to the copy outside if-up.d . See if it helps. If no, reboot and see if it helps.
http://manpages.ubuntu.com/manpages/...erfaces.5.html
Best wishes.

sargas 2013-02-05 16:43

Re: Running script when network interface is up
 
Thanks all for your time.
Since i am not able to pull this off i'm thinking to do it old school: daemon runs in background, pings 8.8.8.8 at regular interval and, if network is up, sends some data to a remote ssh server. This way it doesn't matter which interface is up - data gets sent anyway.
If you're wandering, this is poor man's "track and protect". :D

Edit: typo.

peterleinchen 2013-02-06 10:02

Re: Running script when network interface is up
 
Quote:

Originally Posted by ffha (Post 1320457)
Forgive me if I'm wrong, for I don't have a N9 myself, but doesn't Aegis prevent modification of files owned by root, even by root itself?

Not fully correct. but the hint with Aegis should have notified all of us.

Here is the answer from thedead1440 about this specific problem.
This is a new to-be-executed binary/shell and this needs to be entered to refhashlist to be excuted by system (afaiu).

Quote:

Originally Posted by thedead1440
That's because its not added to refhashlist; check refhashlist and other files have their hashes in there (cat /var/lib/aegis/refhashlist | grep etc/network)

The hash needs to be added and then refhashlist signed; if in open mode adding the hash w/o resigning would work too

Let me know how it goes

Thanks to him!


All times are GMT. The time now is 03:06.

vBulletin® Version 3.8.8