From patchwork Tue Nov 5 12:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rowe X-Patchwork-Id: 1189655 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.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=citrix.com header.i=@citrix.com header.b="alZYowDi"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 476pkd2Q16z9sNT for ; Tue, 5 Nov 2019 23:24:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DA71789283; Tue, 5 Nov 2019 12:24:20 +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 p0qXQ6fPOkzw; Tue, 5 Nov 2019 12:24:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B04E989237; Tue, 5 Nov 2019 12:24:19 +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 A92DA1BF484 for ; Tue, 5 Nov 2019 12:24:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A5E3B8A508 for ; Tue, 5 Nov 2019 12:24:18 +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 QUcP1lj88Z8v for ; Tue, 5 Nov 2019 12:24:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by hemlock.osuosl.org (Postfix) with ESMTPS id 15E138A360 for ; Tue, 5 Nov 2019 12:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1572956657; h=from:to:cc:subject:date:message-id:mime-version; bh=WGls8GZrlyyEv4/fOXBdfXK+g8GtcDOZ0Ns+9Uwv/f4=; b=alZYowDiQa+4vdsbLipoTYhdWAsQSEq5mmnUSw2i3EqJtXlZHwxy46Ki qyvbfgJx2SERCO8bulhH9p0FXWfBb2LX1IGQJESFy/qV9eydDE2vC71M+ TQINP49TTNLVpyH3hVP9C0c/4cgWaelqneFwBvVoviLg2GK0tsDYOEMys 4=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=simon.rowe@citrix.com; spf=Pass smtp.mailfrom=Simon.Rowe@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of simon.rowe@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Simon.Rowe@citrix.com"; x-sender="simon.rowe@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Simon.Rowe@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Simon.Rowe@citrix.com"; x-sender="Simon.Rowe@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Simon.Rowe@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: GJ2OW/7XLTP1KlQJhRHSmATafVu05dzGITSUlQAmCaDerHq4+jqEHIBhg2JQHho+i/mh1j0fqM lT+BvSqaNyf5MXo7Ws34QNhYlDubwLOA7IzR11LxaU6HUyShws/v0ZH8XOjx1Bm0NM0SBA+aUQ +vDwYyW74LqkOIZt+4Hi3T2l+usrEAzoFMx3Bm+utH9VK2nzItneqUo7ws+7UmWP8+nVNF3kEv NHVr9oU13CW72h/ZSoG1ll1wRex5HVTdckEtyUQRbW+okpwJLza/nlpHLdc+ZWU3tD13sBUAgh mk0= X-SBRS: 2.7 X-MesageID: 8250466 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,271,1569297600"; d="scan'208";a="8250466" From: Simon Rowe To: Date: Tue, 5 Nov 2019 12:24:11 +0000 Message-ID: <1572956651-8140-1-git-send-email-simon.rowe@citrix.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 1/1] package/ntp: base sysv script on current template 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: Simon Rowe Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Signed-off-by: Simon Rowe Tested-by: Carlos Santos --- package/ntp/S49ntp | 80 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/package/ntp/S49ntp b/package/ntp/S49ntp index 35e5874..66c5f70 100644 --- a/package/ntp/S49ntp +++ b/package/ntp/S49ntp @@ -1,34 +1,56 @@ -#! /bin/sh +#!/bin/sh +# +# Starts Network Time Protocol daemon +# -NAME=ntpd +DAEMON="ntpd" +PIDFILE="/var/run/$DAEMON.pid" -# Read config file if it is present. -if [ -r /etc/default/$NAME ] -then - . /etc/default/$NAME -fi +NTPD_ARGS="-g" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ + -- $NTPD_ARGS -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$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" +} + +restart() { + stop + sleep 1 + start +} case "$1" in - start) - printf "Starting $NAME: " - start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - stop) - printf "Stopping $NAME: " - start-stop-daemon -K -q -n $NAME - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - restart|reload) - echo "Restarting $NAME: " - $0 stop - sleep 1 - $0 start - ;; - *) - echo "Usage: $0 {start|stop|restart|reload}" >&2 - exit 1 - ;; + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 esac - -exit 0