step 4: edit qpkg configuration start-stop script

  1. edit package_routines
    ref:https://edhongcy.gitbooks.io/qdk-qpkg-development-kit/content/package-specific-installation-functions.html

     ######################################################################
     # Define any package specific operations that shall be performed when
     # the package is removed.
     ######################################################################
     #PKG_PRE_REMOVE="{
     #}"
     #
     #PKG_MAIN_REMOVE="{
     #}"
     #
     PKG_POST_REMOVE="{
         CONF=/etc/config/qpkg.conf
         DOCKER_NAME="container-station"
         DOCKER_ROOT=`/sbin/getcfg $DOCKER_NAME Install_Path -f ${CONF}`
         $DOCKER_ROOT/bin/system-docker rm -f myapp
         $DOCKER_ROOT/bin/system-docker rmi nginx:latest
     }"
     #
     #...
     ######################################################################
     # Define any package specific operations that shall be performed when
     # the package is installed.
     ######################################################################
     #pkg_pre_install(){
     #}
     #
     #pkg_install(){
     #}
     #
     pkg_post_install(){
         CONF=/etc/config/qpkg.conf
         QPKG_NAME="nginx"
         DOCKER_NAME="container-station"
         QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
         DOCKER_ROOT=`/sbin/getcfg $DOCKER_NAME Install_Path -f ${CONF}`
    
         $DOCKER_ROOT/bin/system-docker load < $QPKG_ROOT/nginx.tar
    
         $DOCKER_ROOT/bin/system-docker run --name myapp -p 9090:80 -v $QPKG_ROOT:/usr/share/nginx/html -d nginx:latest
     }
    
  2. edit myapp.sh(start-stop script)

     #!/bin/sh
     CONF=/etc/config/qpkg.conf
     QPKG_NAME="myapp"
     DOCKER_NAME="container-station"
     QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}`
     DOCKER_ROOT=`/sbin/getcfg $DOCKER_NAME Install_Path -f ${CONF}`
     APACHE_ROOT=`/sbin/getcfg SHARE_DEF defWeb -d Qweb -f /etc/config/def_share.info`
     export QNAP_QPKG=$QPKG_NAME
    
     case "$1" in
       start)
         ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
         if [ "$ENABLED" != "TRUE" ]; then
             echo "$QPKG_NAME is disabled."
             exit 1
         fi
         : ADD START ACTIONS HERE
         $DOCKER_ROOT/bin/system-docker start myapp
         ;;
    
       stop)
         : ADD STOP ACTIONS HERE
         $DOCKER_ROOT/bin/system-docker stop myapp
         ;;
    
       restart)
         $0 stop
         $0 start
         ;;
    
       *)
         echo "Usage: $0 {start|stop|restart}"
         exit 1
     esac
    
     exit 0
    
  3. edit qpkg.cfg
    ref:https://edhongcy.gitbooks.io/qdk-qpkg-development-kit/content/qpkg-configuration-file.html

     # Name of the packaged application.
     QPKG_NAME="myapp"
     # Name of the display application.
     #QPKG_DISPLAY_NAME=""
     # Version of the packaged application.
     QPKG_VER="0.1"
     # Author or maintainer of the package
     QPKG_AUTHOR="admin"
     # License for the packaged application
     #QPKG_LICENSE=""
     # One-line description of the packaged application
     #QPKG_SUMMARY=""
    
     # Preferred number in start/stop sequence.
     QPKG_RC_NUM="101"
     # Init-script used to control the start and stop of the installed   application.
     QPKG_SERVICE_PROGRAM="myapp.sh"
    
     # Optional 1 is enable. Path of starting/ stopping shall script. (no start/stop on App Center)
     #QPKG_DISABLE_APPCENTER_UI_SERVICE=1
    
     # Specifies any packages required for the current package to operate.
     QPKG_REQUIRE="container-station >= 1.9.3576"
     # Specifies what packages cannot be installed if the current package
     # is to operate properly.
     #QPKG_CONFLICT="Python"
     # Name of configuration file (multiple definitions are allowed).
     #QPKG_CONFIG="myApp.conf"
     #QPKG_CONFIG="/etc/config/myApp.conf"
     # Port number used by service program.
     #QPKG_SERVICE_PORT=""
     # Location of file with running service's PID
     #QPKG_SERVICE_PIDFILE=""
     # Relative path to web interface
     QPKG_WEBUI="/"
     # Port number for the web interface.
     QPKG_WEB_PORT="9090"
     # Port number for the SSL web interface.
     #QPKG_WEB_SSL_PORT=""
    

results matching ""

    No results matching ""