From patchwork Wed Sep 27 02:16:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 818897 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y21fk2klMz9sCZ for ; Wed, 27 Sep 2017 12:17:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 11A6989593; Wed, 27 Sep 2017 02:17:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T+RTWPLV8ch4; Wed, 27 Sep 2017 02:16:57 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A8D0189443; Wed, 27 Sep 2017 02:16:57 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id CF1071BFFFA for ; Wed, 27 Sep 2017 02:16:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C8C21893F2 for ; Wed, 27 Sep 2017 02:16:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K-+nOQgndTrU for ; Wed, 27 Sep 2017 02:16:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.ind.br (mx.datacom.ind.br [177.66.5.10]) by hemlock.osuosl.org (Postfix) with ESMTPS id 6D4CB893E5 for ; Wed, 27 Sep 2017 02:16:53 +0000 (UTC) Received: from mail.datacom.ind.br (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTPS id 092B415AE5CA; Tue, 26 Sep 2017 23:16:32 -0300 (BRT) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.ind.br (Postfix) with ESMTP id EE0AE15AE5C9; Tue, 26 Sep 2017 23:16:31 -0300 (BRT) Received: from mail.datacom.ind.br ([127.0.0.1]) by localhost (mail.datacom.ind.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nIGANfFSen2L; Tue, 26 Sep 2017 23:16:31 -0300 (BRT) Received: from PEDELD011457.datacom.net (unknown [172.31.206.21]) by mail.datacom.ind.br (Postfix) with ESMTPSA id 8D91415AE5C1; Tue, 26 Sep 2017 23:16:31 -0300 (BRT) From: Carlos Santos To: buildroot@buildroot.org Date: Tue, 26 Sep 2017 23:16:09 -0300 Message-Id: <1506478569-8657-1-git-send-email-casantos@datacom.ind.br> X-Mailer: git-send-email 2.7.5 In-Reply-To: <7d0f3151-bce7-8512-bae1-2c0d44717faf@mind.be> References: <7d0f3151-bce7-8512-bae1-2c0d44717faf@mind.be> Subject: [Buildroot] [PATCH v2]] radvd: improve startup script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Print an error message if /usr/sbin/radvd is missing. Print an error message if the kernel does not support IPv6 forwarding, which is required by radvd. Ignore any start/stop/restart option if /etc/radvd.conf does not exist. The previous script printed an error message in this case but is valid to install radvd without a configuration file. The daemon may be started later by another service with a configuration created at run-time. This is a copy/paste/edit/fix of package/dnsmasq/S80dnsmasq. Signed-off-by: Carlos Santos --- Changes v1->v2 - Print error message is /usr/sbin/radvd is missing - Print error message if /proc/sys/net/ipv6/conf/all/forwarding is missing (kernel does not support IPv6 forwarding) - Echo "1" to /proc/sys/net/ipv6/conf/all/forwarding upon start --- package/radvd/S50radvd | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/package/radvd/S50radvd b/package/radvd/S50radvd index 9f1407c..cc73f29 100755 --- a/package/radvd/S50radvd +++ b/package/radvd/S50radvd @@ -1,18 +1,38 @@ #!/bin/sh -RADVD=/usr/sbin/radvd - -echo "1" > /proc/sys/net/ipv6/conf/all/forwarding - -printf "Starting radvd: " -if [ ! -x "${RADVD}" ]; then - echo "missing" +[ -x /usr/sbin/radvd ] || { + echo "Error: /usr/sbin/radvd is missing." exit 1 -fi +} -if ${RADVD} ; then - echo "done" -else - echo "failed" +[ -f /proc/sys/net/ipv6/conf/all/forwarding ] || { + echo "Error: radvd requires IPv6 forwarding support." exit 1 -fi +} + +[ -f /etc/radvd.conf ] || { + exit 0 +} + +case "$1" in + start) + printf "Starting radvd: " + echo "1" > /proc/sys/net/ipv6/conf/all/forwarding + start-stop-daemon -S -x /usr/sbin/radvd + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + stop) + printf "Stopping radvd: " + start-stop-daemon -K -q -x /usr/sbin/radvd + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + restart|reload) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit 0