Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalwareutils.git;a=commitdiff;h=55afde70350760ae14a8d7575161b0526a0d21b0
commit 55afde70350760ae14a8d7575161b0526a0d21b0 Author: Miklos Vajna <vmik...@frugalware.org> Date: Sat Sep 24 22:07:17 2011 +0200 Add netconfigd, so network startup does not block the boot process diff --git a/Makefile b/Makefile index 41e5701..944aaf2 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ -include config.mak -include Makefile.inc -SUBDIRS = doc apidoc libfwutil libfwdialog setup \ +SUBDIRS = doc apidoc libfwutil libfwdialog setup netconfigd \ libfwnetconfig netconfig \ libfwtimeconfig timeconfig \ libfwraidconfig raidconfig \ diff --git a/doc/netconfigd.txt b/doc/netconfigd.txt new file mode 100644 index 0000000..d0418dc --- /dev/null +++ b/doc/netconfigd.txt @@ -0,0 +1,26 @@ += netconfigd(1) + +== NAME + +netconfigd - wrapper daemon around netconfig + +== SYNOPSIS + +netconfigd + +== DISCUSSON + +This daemon runs `netconfig start` on startup, `netconfig restart` when it +receives SIGHUP, finally `netconfig stop` when it receives SIGTERM. + +== AUTHOR + +Written by Miklos Vajna. + +== REPORTING BUGS + +If you find any bug, then please file a bugreport at <http://bugs.frugalware.org/>. + +== SEE ALSO + +*netconfig*(1) diff --git a/netconfig/netconfig.service b/netconfig/netconfig.service index d57e5d2..5c53bd2 100644 --- a/netconfig/netconfig.service +++ b/netconfig/netconfig.service @@ -1,12 +1,10 @@ [Unit] Description=Network configurator -After=syslog.target +Wants=network.target +Before=network.target [Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/sbin/netconfig start -ExecStop=/sbin/netconfig stop +ExecStart=/sbin/netconfigd [Install] -WantedBy=network.target multi-user.target +WantedBy=multi-user.target diff --git a/netconfigd/Makefile b/netconfigd/Makefile new file mode 100644 index 0000000..75f3e99 --- /dev/null +++ b/netconfigd/Makefile @@ -0,0 +1,29 @@ +# Makefile for frugalwareutils +# +# Copyright (C) 2011 Miklos Vajna <vmik...@frugalware.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +-include ../config.mak + +compile: netconfigd + +install: + $(INSTALL) netconfigd $(DESTDIR)$(sbindir)/setup + +clean: + rm -f netconfigd *.o + +prepare: diff --git a/netconfigd/netconfigd.c b/netconfigd/netconfigd.c new file mode 100644 index 0000000..24ab44a --- /dev/null +++ b/netconfigd/netconfigd.c @@ -0,0 +1,59 @@ +/* + * netconfigd.c for frugalwareutils + * + * Copyright (c) 2011 by Miklos Vajna <vmik...@frugalware.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include <stdio.h> +#include <signal.h> +#include <stdlib.h> + +static int term_interrupt = 0; + +static void handle_sigterm(int signum) +{ + term_interrupt = 1; +} + +static void handle_sighup(int signum) +{ + system("netconfig restart"); +} + +int main(int argc, char **argv) +{ + sigset_t mask, oldmask; + + signal(SIGTERM, handle_sigterm); + signal(SIGHUP, handle_sighup); + + /* Set up the mask of signals to temporarily block. */ + sigemptyset(&mask); + sigaddset(&mask, SIGTERM); + + system("netconfig start"); + + /* Wait for a signal to arrive. */ + sigprocmask(SIG_BLOCK, &mask, &oldmask); + while (!term_interrupt) + sigsuspend(&oldmask); + sigprocmask(SIG_UNBLOCK, &mask, NULL); + + system("netconfig stop"); + return 0; +} diff --git a/sampleconfig/README b/sampleconfig/README index 3a0ec61..0bcd31f 100644 --- a/sampleconfig/README +++ b/sampleconfig/README @@ -2,4 +2,4 @@ This directory contains a very simple config plugin, in fact a mix of the raidconfig and timeconfig, but the target here is to be simple. Feel free to use it as a base of other new plugins. -VMiklos +Miklos _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git