Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id BB7AEE00CFE; Wed, 16 Aug 2017 01:09:13 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.1.11 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 2BEF1E009A4 for ; Wed, 16 Aug 2017 01:09:12 -0700 (PDT) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id v7G89CRI010386 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Wed, 16 Aug 2017 01:09:12 -0700 (PDT) Received: from ala-dreyna-lx3.corp.ad.wrs.com (147.11.157.78) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 16 Aug 2017 01:09:11 -0700 From: David Reyna To: Date: Wed, 16 Aug 2017 01:00:50 -0700 Message-ID: <1502870450-29765-1-git-send-email-david.reyna@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [147.11.157.78] Subject: [PATCH] toaster: custom start and stop actions X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2017 08:09:13 -0000 Content-Type: text/plain From: David Reyna Toaster needs the ability to allow custom extensions to execute when Toaster is started and stopped. Toaster will look for a custom extension script in the fixtures directory and execute any applicable hooks. [YOCTO #11938] Signed-off-by: David Reyna --- bitbake/bin/toaster | 22 ++++++++++- .../orm/fixtures/custom_toaster_append.sh_sample | 46 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100755 bitbake/lib/toaster/orm/fixtures/custom_toaster_append.sh_sample diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index c2e33fe..762451d 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster @@ -24,6 +24,14 @@ Usage: source toaster start|stop [webport=] [noweb] [webport] Set the development server (default: localhost:8000) " +custom_extention() +{ + custom_extension=$BBBASEDIR/lib/toaster/orm/fixtures/custom_toaster_append.sh + if [ -f $custom_extension ] ; then + $custom_extension $* + fi +} + databaseCheck() { retval=0 @@ -50,6 +58,11 @@ databaseCheck() webserverKillAll() { local pidfile + if [ -f ${BUILDDIR}/.toastermain.pid ] ; then + custom_extention web_stop_postpend + else + custom_extention noweb_stop_postpend + fi for pidfile in ${BUILDDIR}/.toastermain.pid ${BUILDDIR}/.runbuilds.pid; do if [ -f ${pidfile} ]; then pid=`cat ${pidfile}` @@ -89,6 +102,7 @@ webserverStartAll() else echo "Toaster development webserver started at http://$ADDR_PORT" echo -e "\nYou can now run 'bitbake ' on the command line and monitor your build in Toaster.\nYou can also use a Toaster project to configure and run a build.\n" + custom_extention web_start_postpend $ADDR_PORT fi return $retval @@ -168,7 +182,6 @@ fi unset OE_ROOT - WEBSERVER=1 ADDR_PORT="localhost:8000" unset CMD @@ -241,6 +254,7 @@ fi echo "The system will $CMD." # Execute the commands +custom_extention toaster_prepend $CMD $ADDR_PORT case $CMD in start ) @@ -262,9 +276,10 @@ case $CMD in if [ ! -f "$TOASTER_DIR/toaster.sqlite" ] ; then if ! databaseCheck; then echo "Failed ${CMD}." - return 4 + return 4 fi fi + custom_extention noweb_start_postpend $ADDR_PORT fi if [ $WEBSERVER -gt 0 ] && ! webserverStartAll; then echo "Failed ${CMD}." @@ -278,6 +293,7 @@ case $CMD in # set fail safe stop system on terminal exit trap stop_system SIGHUP echo "Successful ${CMD}." + custom_extention toaster_postpend $CMD $ADDR_PORT return 0 ;; stop ) @@ -285,3 +301,5 @@ case $CMD in echo "Successful ${CMD}." ;; esac +custom_extention toaster_postpend $CMD $ADDR_PORT + diff --git a/bitbake/lib/toaster/orm/fixtures/custom_toaster_append.sh_sample b/bitbake/lib/toaster/orm/fixtures/custom_toaster_append.sh_sample new file mode 100755 index 0000000..a7e0487 --- /dev/null +++ b/bitbake/lib/toaster/orm/fixtures/custom_toaster_append.sh_sample @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright (C) 2017 Intel Corp. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +verbose=0 +if [ $verbose -ne 0 ] ; then + echo "custom_toaster_append.sh:$*" +fi + +if [ "toaster_prepend" = "$1" ] ; then + echo "Add custom actions here when Toaster script is started" +fi + +if [ "web_start_postpend" = "$1" ] ; then + echo "Add custom actions here after Toaster web service is started" +fi + +if [ "web_stop_postpend" = "$1" ] ; then + echo "Add custom actions here after Toaster web service is stopped" +fi + +if [ "noweb_start_postpend" = "$1" ] ; then + echo "Add custom actions here after Toaster (no web) service is started" +fi + +if [ "noweb_stop_postpend" = "$1" ] ; then + echo "Add custom actions here after Toaster (no web) service is stopped" +fi + +if [ "toaster_postpend" = "$1" ] ; then + echo "Add custom actions here after Toaster script is done" +fi + -- 1.9.1