2004-08-16 Dan Williams <dcbw@redhat.com>
* initscript/NetworkManager - Check for /sbin/ip - Do sysctl magic that network service does - sleep 4s after start to allow network time to come up [hack] * src/Makefile.am src/NMLoadModules - Load all network device kernel modules (hal doesn't know devices are ethernet until the module is loaded, and therefore we don't know) * src/NetworkManager.c - (main): daemonize later, launch NMLoadModules to alert HAL of our network devices, and bring up the loopback device explicitly * src/NetworkManagerUtils.[ch] - (nm_enable_loopback): new function git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@55 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
19
ChangeLog
19
ChangeLog
@@ -1,3 +1,22 @@
|
||||
2004-08-16 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* initscript/NetworkManager
|
||||
- Check for /sbin/ip
|
||||
- Do sysctl magic that network service does
|
||||
- sleep 4s after start to allow network time to come up [hack]
|
||||
|
||||
* src/Makefile.am
|
||||
src/NMLoadModules
|
||||
- Load all network device kernel modules (hal doesn't know devices
|
||||
are ethernet until the module is loaded, and therefore we don't know)
|
||||
|
||||
* src/NetworkManager.c
|
||||
- (main): daemonize later, launch NMLoadModules to alert HAL of our
|
||||
network devices, and bring up the loopback device explicitly
|
||||
|
||||
* src/NetworkManagerUtils.[ch]
|
||||
- (nm_enable_loopback): new function
|
||||
|
||||
2004-08-13 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* configure.in
|
||||
|
@@ -1,5 +1,4 @@
|
||||
EXTRA_DIST = NetworkManager
|
||||
|
||||
initddir = $(sysconfdir)/rc.d/init.d
|
||||
|
||||
initd_SCRIPTS = NetworkManager
|
||||
|
@@ -9,9 +9,15 @@
|
||||
# processname: NetworkManager
|
||||
# pidfile: /var/run/NetworkManager.pid
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: $network
|
||||
### END INIT INFO
|
||||
|
||||
# Sanity checks.
|
||||
[ -x /usr/bin/NetworkManager ] || exit 0
|
||||
[ -x /usr/bin/NetworkManager ] || exit 1
|
||||
|
||||
# We need /sbin/ip
|
||||
[ -x /sbin/ip ] || exit 1
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
@@ -19,18 +25,23 @@
|
||||
# so we can rearrange this easily
|
||||
processname=NetworkManager
|
||||
servicename=NetworkManager
|
||||
pidfile=/var/run/NetworkManager.pid
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
action $"Setting network parameters: " sysctl -e -p /etc/sysctl.conf
|
||||
echo -n $"Starting NetworkManager daemon: "
|
||||
daemon --check $servicename $processname
|
||||
sleep 4
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > /var/run/NetworkManager.pid
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > $pidfile
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping NetworkManager daemon: "
|
||||
|
||||
killproc $servicename -TERM
|
||||
@@ -38,7 +49,7 @@ stop() {
|
||||
echo
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
rm -f /var/lock/subsys/$servicename
|
||||
rm -f /var/run/NetworkManager.pid
|
||||
rm -f $pidfile
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -33,4 +33,7 @@ NetworkManager_LDADD = $(NM_LIBS) $(IWLIB) $(OPENSSL_LIBS)
|
||||
dbusservicedir = $(DBUS_SYS_DIR)
|
||||
dbusservice_DATA = NetworkManager.conf
|
||||
|
||||
EXTRA_DIST = $(dbusservice_DATA)
|
||||
helperdir = $(bindir)
|
||||
helper_SCRIPTS = NMLoadModules
|
||||
|
||||
EXTRA_DIST = $(dbusservice_DATA) $(helper_SCRIPTS)
|
||||
|
@@ -543,37 +543,18 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
}
|
||||
|
||||
if (become_daemon)
|
||||
{
|
||||
int child_pid;
|
||||
|
||||
if (chdir ("/") < 0)
|
||||
{
|
||||
fprintf( stderr, "NetworkManager could not chdir to /. errno=%d", errno);
|
||||
return (1);
|
||||
}
|
||||
|
||||
child_pid = fork ();
|
||||
switch (child_pid)
|
||||
{
|
||||
case -1:
|
||||
fprintf( stderr, "NetworkManager could not daemonize. errno = %d\n", errno );
|
||||
break;
|
||||
|
||||
case 0:
|
||||
/* Child */
|
||||
break;
|
||||
|
||||
default:
|
||||
exit (EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_type_init ();
|
||||
if (!g_thread_supported ())
|
||||
g_thread_init (NULL);
|
||||
|
||||
/* Load all network device kernel modules.
|
||||
* NOTE: this hack is temporary until device modules get loaded
|
||||
* on startup by something else. The problem is that unless
|
||||
* the module is loaded, HAL doesn't know its a network device,
|
||||
* and therefore can't tell us about it.
|
||||
*/
|
||||
nm_spawn_process ("/usr/bin/NMLoadModules");
|
||||
|
||||
/* Initialize our instance data */
|
||||
nm_data = nm_data_new ();
|
||||
if (!nm_data)
|
||||
@@ -601,10 +582,19 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
nm_data->hal_ctx = ctx;
|
||||
hal_ctx_set_user_data (nm_data->hal_ctx, nm_data);
|
||||
hal_device_property_watch_all (nm_data->hal_ctx);
|
||||
|
||||
/* Grab network devices that are already present and add them to our list */
|
||||
nm_add_initial_devices (nm_data);
|
||||
|
||||
/* We run dhclient when we need to, and we don't want any stray ones
|
||||
* lying around upon launch.
|
||||
*/
|
||||
nm_spawn_process ("/usr/bin/killall dhclient");
|
||||
|
||||
/* Bring up the loopback interface. */
|
||||
nm_enable_loopback ();
|
||||
|
||||
/* Create a watch function that monitors cards for link status (hal doesn't do
|
||||
* this for wireless cards yet).
|
||||
*/
|
||||
@@ -618,13 +608,32 @@ int main( int argc, char *argv[] )
|
||||
/* Keep a current list of access points */
|
||||
wireless_scan_source = g_timeout_add (10000, nm_wireless_scan_monitor, nm_data);
|
||||
|
||||
/* Watch all devices that HAL knows about for state changes */
|
||||
hal_device_property_watch_all (nm_data->hal_ctx);
|
||||
if (become_daemon)
|
||||
{
|
||||
int child_pid;
|
||||
|
||||
/* We run dhclient when we need to, and we don't want any stray ones
|
||||
* lying around upon launch.
|
||||
*/
|
||||
nm_spawn_process ("/usr/bin/killall dhclient");
|
||||
if (chdir ("/") < 0)
|
||||
{
|
||||
fprintf( stderr, "NetworkManager could not chdir to /. errno=%d", errno);
|
||||
return (1);
|
||||
}
|
||||
|
||||
child_pid = fork ();
|
||||
switch (child_pid)
|
||||
{
|
||||
case -1:
|
||||
fprintf( stderr, "NetworkManager could not daemonize. errno = %d\n", errno );
|
||||
break;
|
||||
|
||||
case 0:
|
||||
/* Child */
|
||||
break;
|
||||
|
||||
default:
|
||||
exit (EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wheeee!!! */
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
|
@@ -199,3 +199,17 @@ int nm_spawn_process (char *args)
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_enable_loopback
|
||||
*
|
||||
* Bring up the loopback interface
|
||||
*
|
||||
*/
|
||||
void nm_enable_loopback (void)
|
||||
{
|
||||
nm_spawn_process ("/sbin/ip link set dev lo up");
|
||||
nm_spawn_process ("ip addr add 127.0.0.1/8 brd 127.255.255.255 dev lo label loopback");
|
||||
}
|
||||
|
||||
|
@@ -50,4 +50,6 @@ void nm_dispose_scan_results (wireless_scan *result_list);
|
||||
|
||||
int nm_spawn_process (char *args);
|
||||
|
||||
void nm_enable_loopback (void);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user