LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-14-2013, 10:21 AM   #1
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Rep: Reputation: 19
Running a Script on if-up?


I have several scripts I need to run when an interface comes up. (Debian Testing)

We are supposed to be able to put them in /etc/network/if-up.d
... but unfortunately this does not work.

Has anyone been able to get this working?
 
Old 04-14-2013, 11:00 AM   #2
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 341

Rep: Reputation: 34
Did you tried to run the script manually first?. Does it gave any error?. May be the file does not have execute permissions? . You can show the content of interface file here
 
Old 04-14-2013, 11:17 AM   #3
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
Yes it runs fine of I run it manually. It is set to +x.

Code:
#! /bin/sh

echo "sshcygnus0"

# Don't bother to restart sshd when lo is configured.
if [ "$IFACE" = lo ]; then
	exit 0
fi
echo "sshcygnus0a"

# Only run from ifup.
if [ "$MODE" != start ]; then
	exit 0
fi
echo "sshcygnus0b"

# We only care about inet and inet6. Get ye gone, strange people
# still using ipx.
if [ "$ADDRFAM" != inet ]; then
	exit 0
fi
echo "sshcygnus0c"

# Is the bin there?
if [ ! -e /usr/local/bin/sshcygnus ]; then
	exit 0
fi


echo "sshcygnus1"
  sleep 6
  exec /usr/local/bin/sshcygnus
echo "sshcygnus2"
echo "********* IFACE=$IFACE *********"

mount /media/hex
mount /media/droog
echo "sshcygnus3"


exit 0
sshcygnus is a script which sets up reverse SSH tunnels to remotely provide services to my other machines. hex and droog are remote share mounts through sshfs.

But here's a clue: Running from the command-line, it dumps out after sshcygnus0a. (Only run from ifup) It does run on boot, but not on wake from sleep or from the command-line.

So I comment out the ifup test, and then it dumps out after sshcygnus0b. (inet and inet6)

So I comment that out, and then it runs from the command-line.

Why would this be?

Last edited by Quantumstate; 04-14-2013 at 11:20 AM.
 
Old 04-14-2013, 03:53 PM   #4
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 341

Rep: Reputation: 34
interface file means /etc/network/interfaces. Where you have defined if-up. Also long listing of script showing it is in correct directory with correct permissions. User root should also have execute permissions. Also look for /var/log/messages or /var/log/syslog for any clue about the issue.
 
Old 04-15-2013, 10:16 AM   #5
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
interfaces:
Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

#********************************************************

# The primary network interface
# See /etc/wpa_supplicant/wpa_supplicant.conf
# See /usr/share/doc/wpa_supplicant, man wpa_supplicant and man interfaces
# If card not responding: ifdown wlan0 && ifconfig wlan0 down  ifup wlan0
auto wlan0
iface wlan0 inet manual
	# The file contains roaming information on all preferred networks
	# to which wpa_supplicant will connect automatically.
	wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

	# "home" is a keyword which is used in /etc/wpa_supplicant/wpa_supplicant.conf
	#  to tie this entry and a network definition in wpa_supplicant.conf
iface home inet static
	pre-up /sbin/iwconfig wlan0 txpower 5
	#pre-up /sbin/iwconfig wlan0 power saving 3
	#pre-up ip link set wlan0 up
	address 192.168.11.1
	netmask 255.255.255.0
	network 192.168.11.0
	broadcast 192.168.11.255
	gateway 192.168.11.5
	up ip addr add 192.168.1.1/28 brd 192.168.1.255 dev wlan0 label wlan0:1
	# Power-saving Mode
	#iwconfig wlan0 min period 0
	#iwconfig wlan0 max period 0
I've always edited this manually. NM is deinstalled. I have never been able to get this set up to be multi-homed. (for a Home profile and Any profile)

Code:
# ls -al /etc/network/if-up.d/
total 32
drwxr-xr-x. 2 root root 4096 Apr 14 13:27 ./
drwxr-xr-x. 6 root root 4096 Nov 12 15:54 ../
-rwxr-xr-x  1 root root  881 Mar  6 14:04 avahi-autoipd*
-rwxr-xr-x  1 root root  484 Mar  6 14:04 avahi-daemon*
-rwxr-xr-x. 1 root root 1677 Oct  8  2012 clamav-freshclam-ifupdown*
-rwxr-xr-x. 1 root root 1089 Jul  9  2008 ntpdate*
-rwxr-xr-x. 1 root root  849 Aug 23  2010 openssh-server*
lrwxrwxrwx  1 root root   32 Nov  7 05:14 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh*
-rwxr-xr-x. 1 root root  676 Apr 14 13:26 z-sshcygnus*
Code:
# ls -al /usr/local/bin/sshcygnus
-rwxr-xr-x. 1 root staff 2189 Apr 14 13:23 /usr/local/bin/sshcygnus*
Wow, something went wrong with my logging on 27 Feb. All that's in messages is:
14 Apr 10:00:07 ntpdate[14069]: step time server 128.249.1.10 offset 0.016603 sec
syslog has been empty since 27 Feb.

Tracing this, it turns out that somehow /etc/init.d/rsyslog got pointed to an Upstart script. Well Upstart is busted in Debian, but there was an rsyslogd.dpkg-new file so I renamed that. Logging is running again. (-Thank- you, once again, Debian)

Last edited by Quantumstate; 04-15-2013 at 10:22 AM.
 
Old 04-15-2013, 08:29 PM   #6
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 341

Rep: Reputation: 34
In /etc/network/interfaces you have to append a line something like this

Code:
post-up /usr/local/bin/sshcygnus
Add this line in /etc/network/interface under the interface definition/configuration you want to run after it is up.


In your /etc/network/interface there is no such line. Thats why it is not running
 
Old 04-15-2013, 11:56 PM   #7
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
OK I'll try it, thanks.

Can I follow that with
post-up mount /media/hex
post-up mount /media/droog

I wonder what /etc/network/if-up.d is for then?
 
Old 04-16-2013, 09:48 AM   #8
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
It seems to have ignored them all. In /etc/network/interfaces I've added:
Code:
	post-up /usr/local/bin/sshcygnus
	post-up /bin/mount /media/hex
	post-up /bin/mount /media/droog
... to the end of the wlan0 stanza.

Putting the laptop to sleep and waking, results in hex and droog not mounted, and no reverse SSH tunnels set up by sshcygnus. Here is what's in messages. No mention of sshcygnus or share mounts in dmesg either.

Last edited by Quantumstate; 04-16-2013 at 09:51 AM.
 
Old 04-18-2013, 02:21 PM   #9
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
Has anyone gotten post-up scripts to run on Debian?
 
Old 04-23-2013, 03:02 PM   #10
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: Debian Testing with xfce
Posts: 219

Original Poster
Rep: Reputation: 19
OK I've figured it out.

Don't worry about me anymore, LOL.
 
Old 04-23-2013, 05:24 PM   #11
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 341

Rep: Reputation: 34
For the help of others, if possible post your solution here.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue in running commands in expect script from shell script yadvinder Programming 0 05-31-2012 04:07 AM
Shell Script to start a program either not running or kill if running avataratar Linux - Newbie 1 03-29-2012 02:45 AM
Difference between running script (.sh) from .bash_profile and running from login dsimha Linux - General 4 01-17-2012 10:06 AM
Shell Script: Getting signal handlers to work when running an application by script pkjss Programming 4 09-14-2011 04:23 AM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM


All times are GMT -5. The time now is 05:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration