From: Robert Yang <liezhi.yang@windriver.com>
To: Darren Hart <dvhart@linux.intel.com>
Cc: poky@yoctoproject.org
Subject: Re: [PATCH 2/2] Add a skeleton for init scripts
Date: Thu, 12 May 2011 08:47:38 +0800 [thread overview]
Message-ID: <4DCB2E2A.2010008@windriver.com> (raw)
In-Reply-To: <4DCACDDE.1090205@linux.intel.com>
Hi Darren,
Thank you very much for you detailed review, I think that I'd better
not use the start-stop-daemon(or patch it) to get the output message
that we need. because the inconsistent output is from
And please see the comments below.
On 05/12/2011 01:56 AM, Darren Hart wrote:
> Hi Robert,
>
> Thank you for doing this. This is a great start. As a preface to my
> comments below, I am going to be incredibly particular about formatting
> and such as this skeleton will be used by literally thousands of recipes
> in the future and now is the time to ensure consistent formatting and to
> eliminate any issues we don't want to see propagated.
>
>
> On 05/11/2011 06:41 AM, Robert Yang wrote:
>> + #
>> + #start-stop-daemon -K --oknodo --exec $DAEMON
>
>
> What does this command do?
>
if the $DAEMON is not running, exit with 0.
>
>> +
>> + # Many daemons don't delete their pidfiles when they exit.
>> + rm -f $PIDFILE
>
>
> Should STDERR be redirected to /dev/null in case the file does not exist?
>
I think rm -f would output nothing when there is no $PIDFILE.
//Robert
>
>> +}
>> +
>> +#
>> +# Function that sends a SIGHUP to the daemon/service
>> +#
>> +#do_reload() {
>> + #
>> + # If the daemon can reload its configuration without
>> + # restarting (for example, when it is sent a SIGHUP),
>> + # then implement that here.
>> + #
>> + #start-stop-daemon -K --signal 1 --pidfile $PIDFILE --name $NAME
>> +#}
>> +
>> +#
>> +# Function that shows the daemon/service status
>> +#
>> +status_of_proc () {
>> + pidof $NAME>/dev/null 2>&1
>> + case $? in
>> + 0)
>> + echo "$NAME is running."
>> + return 0
>> + ;;
>> + 127)
>> + echo "Can't get the status of $NAME (no pidof found)"
>> + ;;
>> + *)
>> + echo "$NAME is not running.">&2
>> + return 1
>> + ;;
>> + esac
>> +}
>> +
>> +case "$1" in
>> + start)
>> + echo "Starting $DESC ..."
>> + # Don't need check the return value, start-stop-daemon would
>> + # print the failed reason automatically.
>> + do_start
>> + ;;
>> + stop)
>> + do_stop
>> + ;;
>> + status)
>> + status_of_proc&& exit 0 || exit $?
>> + ;;
>> + #reload|force-reload)
>
>
> We don't want to have force-reload in two locations, even commented out.
> Going to lead to confusion.
>
>
>> + #
>> + # If do_reload() is not implemented then leave this commented out
>> + # and leave 'force-reload' as an alias for 'restart'.
>> + #
>> + #echo "Reloading $DESC ..."
>> + #do_reload
>> + #;;
>> + restart|force-reload)
>> + #
>> + # If the "reload" option is implemented then remove the
>> + # 'force-reload' alias.
>> + #
>> + do_stop
>> + echo "Starting $DESC ..."
>> + do_start
>> + ;;
>> + #try-restart)
>> + # If do_try_restart() is not implemented then leave this commented out
>> + #echo "Trying to restart $DESC ..."
>
>
> This needs a description of how it should be implemented. i.e. how is
> this different from restart?
>
>
>> + #do_try_restart()
>> + #;;
>> + *)
>> + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}">&2
>> + exit 3
>> + ;;
>> +esac
>> +
>> diff --git a/meta-skeleton/recipes-skeleton/service/service_0.1.bb b/meta-skeleton/recipes-skeleton/service/service_0.1.bb
>> new file mode 100644
>> index 0000000..88a7a59
>> --- /dev/null
>> +++ b/meta-skeleton/recipes-skeleton/service/service_0.1.bb
>> @@ -0,0 +1,20 @@
>> +DESCRIPTION = "The canonical example of init scripts"
>> +SECTION = "base"
>> +LICENSE = "GPLv2"
>> +LIC_FILES_CHKSUM = "file://${WORKDIR}/COPYRIGHT;md5=3900421dc55b9e70428bc522557a66d4"
>> +RDEPENDS_${PN} = "initscripts"
>> +PR = "r0"
>> +
>> +SRC_URI = "file://skeleton \
>> + file://COPYRIGHT \
>> + "
>> +
>> +CONFFILES_${PN} += "${sysconfdir}/init.d/skeleton"
>> +
>> +PACKAGE_ARCH = "all"
>> +
>> +do_install () {
>> + install -d ${D}/${sysconfdir}/init.d
>> + install -m 0755 ${WORKDIR}/skeleton ${D}/${sysconfdir}/init.d/
>> +}
>> +
>
> This installs a file that uses directories like /usr which should be
> replaced with the appropriate setting. For example, in mediatomb (and
> others) we do this like this:
>
> cat ${WORKDIR}/config.xml | \
> sed -e 's,/etc,${sysconfdir},g' \
> -e 's,/usr/sbin,${sbindir},g' \
> -e 's,/var,${localstatedir},g' \
> -e 's,/usr/bin,${bindir},g' \
> -e 's,/usr,${prefix},g'> ${D}${sysconfdir}/mediatomb/config.xml
>
next prev parent reply other threads:[~2011-05-12 0:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 13:41 [PATCH 0/2] Add meta-skeleton and a skeleton for init scripts Robert Yang
2011-05-11 13:41 ` [PATCH 1/2] Add the layer meta-skeleton Robert Yang
2011-05-11 16:27 ` Darren Hart
2011-05-11 13:41 ` [PATCH 2/2] Add a skeleton for init scripts Robert Yang
2011-05-11 17:56 ` Darren Hart
2011-05-12 0:47 ` Robert Yang [this message]
2011-05-12 15:41 ` Robert Yang
2011-05-16 1:34 ` Robert Yang
2011-05-12 17:22 ` Saul Wold
2011-05-12 20:31 ` Darren Hart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DCB2E2A.2010008@windriver.com \
--to=liezhi.yang@windriver.com \
--cc=dvhart@linux.intel.com \
--cc=poky@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.