Sponsored Content
Top Forums Shell Programming and Scripting Script to detect dynamic ip change and update to config file Post 302748647 by neutronscott on Wednesday 26th of December 2012 12:45:53 PM
Old 12-26-2012
Aside from how to invoke it, does the service config really needed changed? Could you possibly listen to 0.0.0.0 and just restart the service?

I don't deal with CentOS but I believe it has an ifup-local script. You could possibly just put service xxx restart in there.

To give details to modify the config file we'd have to know how it looks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I wanted to update a script, more dynamic (just say no to hard coding)...

currently it has the following: bdumpN=`ll /home/apps/oracle/admin/DBprod/bdump/DBprod_j* | grep "$Cdate" | wc -l` If I pass the DBname, I would not have to hardcode it in the script... I can capture the database name by adding the following: DBname=$1 The problem is, I have been unable... (2 Replies)
Discussion started by: mr_manny
2 Replies

2. UNIX and Linux Applications

Autosys Config file update on a read-only filer

Hi To All Genius out there, We are running autosys application on solaris 10. In autosys we have a configuration file that contains an Autosys instance configuration data and is located on a NFS filer on which we have a read-only access. Our Autosys environment is on a dual server... (0 Replies)
Discussion started by: whn_chips_r_dwn
0 Replies

3. Solaris

Autosys Config file update on a read-only filer

Hi To All Genius out there, We are running autosys application on solaris 10. In autosys we have a configuration file that contains an Autosys instance configuration data and is located on a NFS filer on which we have a read-only access. Our Autosys environment is on a dual server mode(Active... (0 Replies)
Discussion started by: whn_chips_r_dwn
0 Replies

4. Shell Programming and Scripting

AWK script to detect webpages from file

Hi guys I'm very new to unix and I have to create an awk script that detects webpage addresses from a file/webpage and outputs how many times each webpage was detected.e.g. if my file was: (Note: The symbol " was added to stop them being created into links) "www.google.com"... (1 Reply)
Discussion started by: ROFL
1 Replies

5. Shell Programming and Scripting

AWK script to detect webpages from file

Hi guys I'm very new to unix and I have to create an awk script that detects webpage addresses from a file/webpage and outputs how many times each webpage was detected.e.g. if my file was: www.google.com www.facebook.com www.google.com the output should be: www.google.com x2... (2 Replies)
Discussion started by: ROFL
2 Replies

6. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

7. Linux

issue on dynamic config script

I have one issue with my existing code.Actually i want to write parameter's at the end of the section not begin of section.please find my code snapshots... while read cfgfilename sectionname parameter do case "$cfgfilename" in cfgfilename) FILE=$HOME/config/$parameter unset... (1 Reply)
Discussion started by: suryanarayan
1 Replies

8. Windows & DOS: Issues & Discussions

script to change widows update permissions

I want to allow windows update when ordinary users are logged on, I'm pretty sure that adjusting the permissions registry entry HEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate to allow acces to all domins users does the trick. I already have a logon.bat that runs at... (0 Replies)
Discussion started by: barrydocks
0 Replies

9. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

10. Shell Programming and Scripting

Update config file using shell script in Solaris 5.10

hi I need to update the value in config.txt value using shell script example: lets say a value in config.txt file is as SEQUENCE=1 after some iteration as the loop ends , the SEQUENCE should get update in the config.txt file with a new value of SEQUENCE=2. also , can anyone please help me... (7 Replies)
Discussion started by: ravidwivedi2288
7 Replies
IFWATCHD(8)						    BSD System Manager's Manual 					       IFWATCHD(8)

NAME
ifwatchd -- watch for addresses added to or deleted from interfaces and call up/down-scripts for them SYNOPSIS
ifwatchd [-hiqv] [-A arrival-script] [-c carrier-script] [-D departure-script] [-d down-script] [-u up-script] [-n no-carrier-script] ifname(s) DESCRIPTION
ifwatchd is used to monitor dynamic interfaces (for example PPP interfaces) for address changes, and to monitor static interfaces for carrier changes. Sometimes these interfaces are accompanied by a daemon program, which can take care of running any necessary scripts (like pppd(8) or isdnd(8)), but sometimes the interfaces run completely autonomously (like pppoe(4)). ifwatchd provides a generic way to watch these types of changes. It works by monitoring the routing socket and interpreting 'RTM_NEWADDR' (address added), 'RTM_DELADDR' (address deleted) and 'RTM_IFINFO' (carrier detect or loss of carrier) messages. It does not need special privileges to do this. The scripts called for up or down events are run with the same user id as ifwatchd is run. The following options are available: -A arrival-script Specify the command to invoke on arrival of new interfaces (like PCMCIA cards). -c carrier-script Specify the command to invoke when the carrier status transitions from no carrier to carrier. -D departure-script Specify the command to invoke when an interface departs (for example a PCMCIA card is removed.) -d down-script Specify the command to invoke on ``interface down'' events (or: deletion of an address from an interface). -h Show the synopsis. -i Inhibit a call to the up-script on startup for all watched interfaces already marked up. If this option is not given, ifwatchd will check all watched interfaces on startup whether they are already marked up and, if they are, call the up-script with appropriate parameters. Additionally, if the interface is up and has a link, ifwatchd will run the carrier script. Since ifwatchd typically is started late in the system boot sequence, some of the monitored interfaces may already have come up when it finally starts, but their up-scripts have not been called. By default ifwatchd calls them on startup to account for this (and make the scripts easier.) -n no-carrier-script Specify the command to invoke when the carrier status transitions from carrier to no carrier. -q Be quiet and don't log non-error messages to syslog. -u up-script Specify the command to invoke on ``interface up'' events (or: addition of an address to an interface). -v Run in verbose debug mode and do not detach from the controlling terminal. Output verbose progress messages and flag errors ignored during normal operation. You do not want to use this option in /etc/rc.conf! ifname(s) The name of the interface to watch. Multiple interfaces may be specified. Events for other interfaces are ignored. EXAMPLES
# ifwatchd -u /etc/ppp/ip-up -d /etc/ppp/ip-down pppoe0 If your pppoe0 interface is your main connection to the internet, the typical use of the up/down scripts is to add and remove a default route. This is an example for an up script doing this: #! /bin/sh /sbin/route add default $5 /sbin/route add -inet6 default fe80::2 -iface ifp $1 As described below the fifth command line parameter will contain the peer address of the pppoe link. The corresponding ip-down script is: #! /bin/sh /sbin/route delete default $5 /sbin/route delete -inet6 default fe80::2 Note that this is not a good idea if you have pppoe0 configured to connect only on demand (via the link1 flag), but works well for all perma- nent connected cases. Use ! /sbin/route add default -iface 0.0.0.1 in your /etc/ifconfig.pppoe0 file in the on-demand case. The next example is for dhclient users. # ifwatchd -i -c /etc/dhcp/carrier-detect tlp0 With the above command, the carrier-detect script will be invoked when a carrier is detected on the interface tlp0. Note that the -i flag prevents any action based on the initial state. A script like the following should work for most users, although it will not work for machines with multiple interfaces running dhclient. #! /bin/sh # Arguments: ifname tty speed address destination # If there is a dhclient already running, kill it. # (This step could be put in a distinct no-carrier script, # if desired.) if [ -f /var/run/dhclient.pid ]; then /bin/kill `/bin/cat /var/run/dhclient.pid` fi # Start dhclient again on this interface /sbin/dhclient $1 PARAMETERS PASSED TO SCRIPTS
The invoked scripts get passed these parameters: ifname The name of the interface this change is for (this allows to share the same script for multiple interfaces watched and dispatch- ing on the interface name in the script). tty Dummy parameter for compatibility with pppd(8) which will always be /dev/null. speed Dummy parameter for compatibility with pppd(8) which will always be 9600. address The new address if this is an up event, or the no longer valid old address if this is a down event. The format of the address depends on the address family, for IPv4 it is the usual dotted quad notation, for IPv6 the colon sepa- rated standard notation. destination For point to point interfaces, this is the remote address of the interface. For other interfaces it is the broadcast address. ERRORS
The program logs to the syslog daemon as facility ``daemon''. For detailed debugging use the -v (verbose) option. SEE ALSO
pppoe(4), route(4), ifconfig.if(5), rc.d(8), route(8) HISTORY
The ifwatchd utility appeared in NetBSD 1.6. AUTHORS
The program was written by Martin Husemann <martin@NetBSD.org>. CAVEATS
Due to the nature of the program a lot of stupid errors can not easily be caught in advance without removing the provided facility for advanced uses. For example typing errors in the interface name can not be detected by checking against the list of installed interfaces, because it is possible for a pcmcia card with the name given to be inserted later. BSD
April 16, 2010 BSD
All times are GMT -4. The time now is 07:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy