From patchwork Thu Mar 12 19:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Thiery X-Patchwork-Id: 1253875 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.133; helo=hemlock.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=OupZyr43; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48ddZG5dvHz9sPF for ; Fri, 13 Mar 2020 06:05:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E8F53883BC; Thu, 12 Mar 2020 19:05:21 +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 a9X5JGPGCDB1; Thu, 12 Mar 2020 19:05:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id E416488388; Thu, 12 Mar 2020 19:05:19 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 7730D1BF40A for ; Thu, 12 Mar 2020 19:05:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7456886C82 for ; Thu, 12 Mar 2020 19:05:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Sxl6cnIQWhkM for ; Thu, 12 Mar 2020 19:05:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 4B8BC86CB5 for ; Thu, 12 Mar 2020 19:05:15 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id 11so7313027wmo.2 for ; Thu, 12 Mar 2020 12:05:15 -0700 (PDT) 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=8w7IfHYbCDBVYmLfFZBs2A1+1nDgfwvXo0JTFYEh438=; b=OupZyr43fmyJSZLM+2RtUWjtLBFxL9LfaQnTA9NGqFgTsSbXVx5sCyFX61iFziHtVw ulwsf4jl1IYHhIL2FtEN4qsZNh+sjL/f+C+BEmKWzSyMslRvvmU8rjMA6NO+wGfuhfkQ jTtgihndEL+yuXb4Ry3iqXdkN4ZY5GnPK0PGEU+O701+hvKv610sb4T6R/w0SmxPaHD+ SOaYB2Nn6STIY+fw/c7DxpmUY+24pcyPgM19a79cFr4Silg/+nIZygkiwuw1NFRniUMT i2ItgQjZqBOsE6e2zTseBmQcin/M9lxRAtHYPu31QyrLHJAVqk1i8NddFamWSd+G0Gwq aFew== 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=8w7IfHYbCDBVYmLfFZBs2A1+1nDgfwvXo0JTFYEh438=; b=npF+HdsKMMr+HixMvqvejY2d6o0N7aa1gBEbghpZRm3DM6slUv7s2UMVdg86X5/k+Y 1i5Us/V4RNO5ixU5+A8UAQ7oO1R7bUlq773NQTSxUN74NC0aC31xx6RbOgp0VQQfrXgS U4McXYs1o9AU1Lq12f4kgiwBn0DLPq+jpsDRvypsVPqDbw0766XSz3yrVvQLvBL35ZlC 7uVFHc7OSzvBen5xtIOZj1QvRiVOgAbePOjV+/AexdvV8EUweMn4dcUaw0zWoqrJvQBH hGSVhQ+bGTksWr2dZtqI7379cBbkAOetb8H+FqhOF6fLPWyhr2Xh1TeaiB6y3V1RmoqB eUNQ== X-Gm-Message-State: ANhLgQ3cGq1Cn7t4HlWtg6wMKjDQ6zJyyWJiRqrEbljxtDgbVftJ/SWX xZ4l2PXPCabigaJOJI5CghnIwTc2SCU= X-Google-Smtp-Source: ADFU+vsBrwK9z7fYJIppGHscAYUnDy3T1GgNntulsY2GXa4GHd6ABGPGpe0EHRtW6J24YeleTQsZzw== X-Received: by 2002:a1c:5585:: with SMTP id j127mr6195521wmb.35.1584039913383; Thu, 12 Mar 2020 12:05:13 -0700 (PDT) Received: from hthiery01.sab.local ([213.135.10.150]) by smtp.gmail.com with ESMTPSA id b203sm14261755wmc.45.2020.03.12.12.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 12:05:12 -0700 (PDT) From: Heiko Thiery To: buildroot@buildroot.org Date: Thu, 12 Mar 2020 20:04:34 +0100 Message-Id: <20200312190434.973-2-heiko.thiery@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312190434.973-1-heiko.thiery@gmail.com> References: <20200312190434.973-1-heiko.thiery@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v4 1/2] 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 Tested-by: Carlos Santos --- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/linuxptp.mk | 6 ++-- 4 files changed, 122 insertions(+), 48 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..c680879aeb --- /dev/null +++ b/package/linuxptp/S66phc2sys @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# + +DAEMON="phc2sys" + +PIDFILE="/var/run/$DAEMON.pid" + +PHC2SYS_ARGS="-a -r -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 $? diff --git a/package/linuxptp/linuxptp.mk b/package/linuxptp/linuxptp.mk index 97e4af7be7..ba57396f86 100644 --- a/package/linuxptp/linuxptp.mk +++ b/package/linuxptp/linuxptp.mk @@ -33,8 +33,10 @@ define LINUXPTP_INSTALL_TARGET_CMDS endef define LINUXPTP_INSTALL_INIT_SYSV - $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65linuxptp \ - $(TARGET_DIR)/etc/init.d/S65linuxptp + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S66phc2sys \ + $(TARGET_DIR)/etc/init.d/S66phc2sys endef define LINUXPTP_INSTALL_INIT_SYSTEMD