From patchwork Fri Mar 6 12:42:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Thiery X-Patchwork-Id: 1250259 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=i/Fr5esG; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48YnNs70Ymz9sRR for ; Fri, 6 Mar 2020 23:43:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2CC638676A; Fri, 6 Mar 2020 12:43:55 +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 hqOyBjg+A1Wx; Fri, 6 Mar 2020 12:43:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 66EB486837; Fri, 6 Mar 2020 12:43:53 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 64BB01BF309 for ; Fri, 6 Mar 2020 12:43:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4479B21FA9 for ; Fri, 6 Mar 2020 12:43:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hsUSGIb2E8EV for ; Fri, 6 Mar 2020 12:43:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by silver.osuosl.org (Postfix) with ESMTPS id 2EA5920364 for ; Fri, 6 Mar 2020 12:43:41 +0000 (UTC) Received: by mail-wm1-f43.google.com with SMTP id u9so2226166wml.3 for ; Fri, 06 Mar 2020 04:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F7YgpYqzhQRHc9FxpSec5uYvuA0zQdkWlZlO3njVgEU=; b=i/Fr5esGaQb4EyTuIlr54sSgwZslg6zHx+hpoaesZBtRqseWikwShjfD4BBA4vzuCF C0S0mJEIJHktDknZrg5e7MOGzA1TzxNPJTRBO9vjJIpA8lBh79Dp7LVOnZgQnaYoBTMf sZiDwQYhl0RetloTFOgiQJ6K7GJ1INdWIWQSXqHeWPM5FkaVR+BCRRV0w6SWnIwbcKbB RLsjbwG8BIwOghb7Wyr2IBR/XXB6Qz1jF/i6dkhhI5WcYwvKW2XM5Vrr8qCdM7N/1Off XrSzJbg150Vu4VTHf5Av9wpf9SUxyBzexh7+cXYD9n1LRdqLqkbOcQANqzkiyDKmWad1 9T4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F7YgpYqzhQRHc9FxpSec5uYvuA0zQdkWlZlO3njVgEU=; b=gg3EiZhKfkg/ZWci5l72qT7b+wARhQ+L6mj401she3Ft8JeTUicXfQqz5p8IzxKckJ EvSyzGqr35s/QlMb9bLwGnj9PmhrbJ7blzxPv95eqsPAHagMKjQvft4KGC6AFBuKzrgk KpekBXOsIJZPkEsQM8etoHFLTJ4o+BQOqgt2yrg8C5G8lL5Z8C7liRH5yFdiwNwfYI31 Ba10bbFQUtETmAx6ZSWYd/KqUku9Cp3gkEa/2We48P1iT0zlhCdKjiKUg/NLXKxP6W0h 7+MQnuZytqyycLw94hRMI5N/0Z3AW0KXoweQnfJnk+7O0luk+2cxfpbPZfd8QUDFAjCL NMYA== X-Gm-Message-State: ANhLgQ3DWW5sVis+8J2brBzzPZFvQHIHsCSbmOiU9isCZkW/Dda/J2TL fAnH64mJeayHkqId0Qj53I1XFn4C X-Google-Smtp-Source: ADFU+vubWdLnRuAlyi7OuTxUY3V1UCuIasm1hFZ5//B9Wm4rH5f/QbvvDTW3ua4y9OqfniI9Pb5w4A== X-Received: by 2002:a05:600c:22cd:: with SMTP id 13mr4031025wmg.51.1583498619110; Fri, 06 Mar 2020 04:43:39 -0800 (PST) Received: from hthiery01.sab.local ([213.135.10.150]) by smtp.gmail.com with ESMTPSA id i21sm2769401wmb.23.2020.03.06.04.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 04:43:38 -0800 (PST) From: Heiko Thiery To: buildroot@buildroot.org Date: Fri, 6 Mar 2020 13:42:24 +0100 Message-Id: <20200306124222.28208-2-heiko.thiery@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306124222.28208-1-heiko.thiery@gmail.com> References: <20200306124222.28208-1-heiko.thiery@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 1/1] package/linuxptp: make initscript options configurable X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlos Santos , Michale Walle , Heiko Thiery , Petr Kulhavy Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The "package/busybox/S01sysklogd" is taken as template to change the init script of the linuxptp daemon. The init script is split two parts because there are 2 daemons (ptp4l and phc2sys). Let the user supply its own options in /etc/default/ptp4l and /etc/default/phc2sys. This patch also fixes an issue with the creation of the pid file that is needed to properly stop the daemon again. Signed-off-by: Michael Walle Signed-off-by: Heiko Thiery --- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 46 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2sys diff --git a/package/linuxptp/S65linuxptp b/package/linuxptp/S65linuxptp deleted file mode 100644 index 46b8921fdd..0000000000 --- a/package/linuxptp/S65linuxptp +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# -# Start linuxptp -# - -start() { - printf "Starting linuxptp daemon: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l -- -f /etc/linuxptp.cfg - [ $? = 0 ] && echo "OK" || echo "FAIL" - - printf "Starting linuxptp system clock synchronization: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys -- -s eth0 -c CLOCK_REALTIME -w -S 1.0 - [ $? = 0 ] && echo "OK" || echo "FAIL" -} - -stop() { - printf "Stopping linuxptp system clock synchronization: " - start-stop-daemon -K -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys - echo "OK" - - printf "Stopping linuxptp daemon: " - start-stop-daemon -K -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l - echo "OK" -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $? diff --git a/package/linuxptp/S65ptp4l b/package/linuxptp/S65ptp4l new file mode 100644 index 0000000000..630c5e803b --- /dev/null +++ b/package/linuxptp/S65ptp4l @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# + +DAEMON="ptp4l" + +PIDFILE="/var/run/$DAEMON.pid" + +PTP4L_ARGS="-f /etc/linuxptp.cfg" + +# shellcheck source=/dev/null +[ -r "/etc/default/ptp4l" ] && . "/etc/default/ptp4l" + +# ptp4l does not create a pidfile, so pass "-n" in the command line +# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf "Starting linuxptp daemon: " + start-stop-daemon -S -b -q -m -p $PIDFILE \ + -x /usr/sbin/$DAEMON -- $PTP4L_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return $status +} + +stop() { + printf "Stopping linuxptp daemon: " + start-stop-daemon -K -q -p $PIDFILE + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return $status +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/package/linuxptp/S66phc2sys b/package/linuxptp/S66phc2sys new file mode 100644 index 0000000000..5d9e962b07 --- /dev/null +++ b/package/linuxptp/S66phc2sys @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# + +DAEMON="phc2sys" + +PIDFILE="/var/run/$DAEMON.pid" + +PHC2SYS_ARGS="-s eth0 -c CLOCK_REALTIME -w -S 1.0" + +# shellcheck source=/dev/null +[ -r "/etc/default/phc2sys" ] && . "/etc/default/phc2sys" + +# phc2sys does not create a pidfile, so pass "-n" in the command line +# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf "Starting linuxptp system clock synchronization: " + start-stop-daemon -S -b -q -m -p $PIDFILE \ + -x /usr/sbin/$DAEMON -- $PHC2SYS_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return $status +} + +stop() { + printf "Stopping linuxptp system clock synchronization: " + start-stop-daemon -K -q -p $PIDFILE + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return $status +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?