[poky] [PATCH 2/2] Add a skeleton for init scripts
Robert Yang
liezhi.yang at windriver.com
Wed May 11 17:47:38 PDT 2011
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
>
More information about the poky
mailing list