2006-02-27 Dan Williams <dcbw@redhat.com>
* dispatcher-daemon/NetworkManagerDispatcher.c - Accept --pid-file with a path to a pidfile, write it out on startup, and delete it on shutdown * src/NetworkManager.c - Accept --pid-file with a path to a pidfile, write it out on startup, and delete it on shutdown - Move nm_print_usage() lower * initscripts/RedHat/NetworkManager.in - Use new --pid-file option - Fix service stopping to wait a bit for NM to quit * initscripts/RedHat/NetworkManagerDispatcher.in - Use new --pid-file option git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1500 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
|||||||
|
2006-02-27 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* dispatcher-daemon/NetworkManagerDispatcher.c
|
||||||
|
- Accept --pid-file with a path to a pidfile, write it out on
|
||||||
|
startup, and delete it on shutdown
|
||||||
|
|
||||||
|
* src/NetworkManager.c
|
||||||
|
- Accept --pid-file with a path to a pidfile, write it out on
|
||||||
|
startup, and delete it on shutdown
|
||||||
|
- Move nm_print_usage() lower
|
||||||
|
|
||||||
|
* initscripts/RedHat/NetworkManager.in
|
||||||
|
- Use new --pid-file option
|
||||||
|
- Fix service stopping to wait a bit for NM to quit
|
||||||
|
|
||||||
|
* initscripts/RedHat/NetworkManagerDispatcher.in
|
||||||
|
- Use new --pid-file option
|
||||||
|
|
||||||
2006-02-26 Dan Williams <dcbw@redhat.com>
|
2006-02-26 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/Makefile.am
|
* src/Makefile.am
|
||||||
|
@@ -280,6 +280,22 @@ static void nmd_print_usage (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_pidfile (const char *pidfile)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int ignored;
|
||||||
|
char pid[16];
|
||||||
|
|
||||||
|
if ((fd = open (pidfile, O_CREAT | O_WRONLY, 00644)) < 0)
|
||||||
|
return FALSE;
|
||||||
|
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||||
|
ignored = write (fd, pid, strlen (pid));
|
||||||
|
close (fd);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*
|
*
|
||||||
@@ -287,8 +303,9 @@ static void nmd_print_usage (void)
|
|||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
gboolean become_daemon = TRUE;
|
gboolean become_daemon = TRUE;
|
||||||
GMainLoop *loop = NULL;
|
GMainLoop * loop = NULL;
|
||||||
DBusConnection *connection = NULL;
|
DBusConnection *connection = NULL;
|
||||||
|
char * pidfile = NULL;
|
||||||
|
|
||||||
/* Parse options */
|
/* Parse options */
|
||||||
while (1)
|
while (1)
|
||||||
@@ -299,6 +316,7 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
static struct option options[] = {
|
static struct option options[] = {
|
||||||
{"no-daemon", 0, NULL, 0},
|
{"no-daemon", 0, NULL, 0},
|
||||||
|
{"pid-file", 1, NULL, 0},
|
||||||
{"help", 0, NULL, 0},
|
{"help", 0, NULL, 0},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@@ -318,6 +336,8 @@ int main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (strcmp (opt, "no-daemon") == 0)
|
else if (strcmp (opt, "no-daemon") == 0)
|
||||||
become_daemon = FALSE;
|
become_daemon = FALSE;
|
||||||
|
else if (strcmp (opt, "pid-file") == 0)
|
||||||
|
pidfile = g_strdup (optarg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nmd_print_usage ();
|
nmd_print_usage ();
|
||||||
@@ -344,6 +364,13 @@ int main (int argc, char *argv[])
|
|||||||
if (!g_thread_supported ())
|
if (!g_thread_supported ())
|
||||||
g_thread_init (NULL);
|
g_thread_init (NULL);
|
||||||
|
|
||||||
|
if (pidfile)
|
||||||
|
{
|
||||||
|
if (!write_pidfile (pidfile))
|
||||||
|
nm_warning ("Couldn't write pid file %s! errno: %s", pidfile,
|
||||||
|
strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
/* Connect to the NetworkManager dbus service and run the main loop */
|
/* Connect to the NetworkManager dbus service and run the main loop */
|
||||||
if ((connection = nmd_dbus_init ()))
|
if ((connection = nmd_dbus_init ()))
|
||||||
{
|
{
|
||||||
@@ -351,5 +378,10 @@ int main (int argc, char *argv[])
|
|||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clean up pidfile */
|
||||||
|
if (pidfile)
|
||||||
|
unlink (pidfile);
|
||||||
|
g_free (pidfile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -37,17 +37,16 @@ start()
|
|||||||
echo $"Setting network parameters... "
|
echo $"Setting network parameters... "
|
||||||
sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
|
sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
|
||||||
echo -n $"Starting NetworkManager daemon: "
|
echo -n $"Starting NetworkManager daemon: "
|
||||||
daemon --check $servicename $processname
|
daemon --check $servicename $processname --pid-file=$pidfile
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > $pidfile
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
||||||
}
|
}
|
||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
echo -n $"Stopping NetworkManager daemon: "
|
echo -n $"Stopping NetworkManager daemon: "
|
||||||
|
killproc -p $pidfile $servicename
|
||||||
killproc $servicename -TERM
|
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
if [ $RETVAL -eq 0 ]; then
|
if [ $RETVAL -eq 0 ]; then
|
||||||
|
@@ -32,16 +32,15 @@ RETVAL=0
|
|||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
echo -n $"Starting NetworkManagerDispatcher daemon: "
|
echo -n $"Starting NetworkManagerDispatcher daemon: "
|
||||||
daemon --check $servicename $processname
|
daemon --check $servicename $processname --pid-file=$pidfile
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > $pidfile
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
||||||
}
|
}
|
||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
echo -n $"Stopping NetworkManagerDispatcher daemon: "
|
echo -n $"Stopping NetworkManagerDispatcher daemon: "
|
||||||
|
|
||||||
killproc $servicename -TERM
|
killproc $servicename -TERM
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
|
@@ -495,28 +495,6 @@ static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, g
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_print_usage
|
|
||||||
*
|
|
||||||
* Prints program usage.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nm_print_usage (void)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n" "usage : NetworkManager [--no-daemon] [--help]\n");
|
|
||||||
fprintf (stderr,
|
|
||||||
"\n"
|
|
||||||
" --no-daemon Don't become a daemon\n"
|
|
||||||
" --enable-test-devices Allow dummy devices to be created via DBUS methods [DEBUG]\n"
|
|
||||||
" --help Show this information and exit\n"
|
|
||||||
"\n"
|
|
||||||
"NetworkManager monitors all network connections and automatically\n"
|
|
||||||
"chooses the best connection to use. It also allows the user to\n"
|
|
||||||
"specify wireless access points which wireless cards in the computer\n"
|
|
||||||
"should associate with.\n"
|
|
||||||
"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nm_device_link_activated (NmNetlinkMonitor *monitor, const gchar *interface_name, NMData *data)
|
static void nm_device_link_activated (NmNetlinkMonitor *monitor, const gchar *interface_name, NMData *data)
|
||||||
{
|
{
|
||||||
NMDevice *dev = NULL;
|
NMDevice *dev = NULL;
|
||||||
@@ -685,6 +663,47 @@ void nm_hal_deinit (NMData *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_pidfile (const char *pidfile)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int ignored;
|
||||||
|
char pid[16];
|
||||||
|
|
||||||
|
if ((fd = open (pidfile, O_CREAT | O_WRONLY, 00644)) < 0)
|
||||||
|
return FALSE;
|
||||||
|
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||||
|
ignored = write (fd, pid, strlen (pid));
|
||||||
|
close (fd);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_print_usage
|
||||||
|
*
|
||||||
|
* Prints program usage.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void nm_print_usage (void)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n" "usage : NetworkManager [--no-daemon] [--pid-file=<file>] [--help]\n");
|
||||||
|
fprintf (stderr,
|
||||||
|
"\n"
|
||||||
|
" --no-daemon Don't become a daemon\n"
|
||||||
|
" --pid-file=<path> Specify the location of a PID file\n"
|
||||||
|
" --enable-test-devices Allow dummy devices to be created via DBUS methods [DEBUG]\n"
|
||||||
|
" --help Show this information and exit\n"
|
||||||
|
"\n"
|
||||||
|
"NetworkManager monitors all network connections and automatically\n"
|
||||||
|
"chooses the best connection to use. It also allows the user to\n"
|
||||||
|
"specify wireless access points which wireless cards in the computer\n"
|
||||||
|
"should associate with.\n"
|
||||||
|
"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*
|
*
|
||||||
@@ -694,6 +713,7 @@ int main( int argc, char *argv[] )
|
|||||||
gboolean become_daemon = TRUE;
|
gboolean become_daemon = TRUE;
|
||||||
gboolean enable_test_devices = FALSE;
|
gboolean enable_test_devices = FALSE;
|
||||||
char * owner;
|
char * owner;
|
||||||
|
char * pidfile = NULL;
|
||||||
|
|
||||||
if (getuid () != 0)
|
if (getuid () != 0)
|
||||||
{
|
{
|
||||||
@@ -711,6 +731,7 @@ int main( int argc, char *argv[] )
|
|||||||
static struct option options[] = {
|
static struct option options[] = {
|
||||||
{"no-daemon", 0, NULL, 0},
|
{"no-daemon", 0, NULL, 0},
|
||||||
{"enable-test-devices", 0, NULL, 0},
|
{"enable-test-devices", 0, NULL, 0},
|
||||||
|
{"pid-file", 1, NULL, 0},
|
||||||
{"help", 0, NULL, 0},
|
{"help", 0, NULL, 0},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@@ -732,6 +753,8 @@ int main( int argc, char *argv[] )
|
|||||||
become_daemon = FALSE;
|
become_daemon = FALSE;
|
||||||
else if (strcmp (opt, "enable-test-devices") == 0)
|
else if (strcmp (opt, "enable-test-devices") == 0)
|
||||||
enable_test_devices = TRUE;
|
enable_test_devices = TRUE;
|
||||||
|
else if (strcmp (opt, "pid-file") == 0)
|
||||||
|
pidfile = g_strdup (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -756,6 +779,13 @@ int main( int argc, char *argv[] )
|
|||||||
g_thread_init (NULL);
|
g_thread_init (NULL);
|
||||||
dbus_g_thread_init ();
|
dbus_g_thread_init ();
|
||||||
|
|
||||||
|
if (pidfile)
|
||||||
|
{
|
||||||
|
if (!write_pidfile (pidfile))
|
||||||
|
nm_warning ("Couldn't write pid file %s! errno: %s", pidfile,
|
||||||
|
strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
nm_logging_setup (become_daemon);
|
nm_logging_setup (become_daemon);
|
||||||
nm_info ("starting...");
|
nm_info ("starting...");
|
||||||
|
|
||||||
@@ -826,5 +856,10 @@ int main( int argc, char *argv[] )
|
|||||||
nm_data_free (nm_data);
|
nm_data_free (nm_data);
|
||||||
nm_logging_shutdown ();
|
nm_logging_shutdown ();
|
||||||
|
|
||||||
|
/* Clean up pidfile */
|
||||||
|
if (pidfile)
|
||||||
|
unlink (pidfile);
|
||||||
|
g_free (pidfile);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user