How to add custom service to v2.1?



  • I've made a custom perl script doing things in the background. I start it with "daemon -p /var/run/myapp.pid /root/my_app.pl"

    I even made a service script (myapp.sh):```
    #!/bin/sh

    Service handler for pitty plyayer

    rc_start() {
            daemon -p /var/run/myapp.pid /root/my_app.pl
    }

    rc_stop() {
            [ -f "/var/run/myapp.pid" ] && kill -9 cat /var/run/myapp.pid && rm -f /var/run/myapp.pid
    }

    case $1 in
            start)
                    rc_start
                    ;;
            stop)
                    rc_stop
                    ;;
            restart)
                    rc_stop
                    rc_start
                    ;;
    esac

    
    Question is: how to add it to the system so that it can be viewed through the web interface?
    
    I tried to add to /etc/inc/service-utils.inc this, but it doesn't appear in the list:```
            if(isset($config['myapp']['enable'])) {
                    $pconfig = array();
                    $pconfig['name'] = "myapp";
                    $pconfig['description'] = gettext("My App");
                    $services[] = $pconfig;
            }
    

  • Rebel Alliance Developer Netgate

    The simplest way is to just add it into your config.xml as a <service>…</service> tag as used by packages. Plenty of examples in the package repo xml files.



  • OK I'll try that, thanks.

    I already thougt of making a package for it, but the product is not ready yet.


Log in to reply