Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Startup Script

Startup Script

Scheduled Pinned Locked Moved Support
5 Posts 3 Posters 30.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    M
    MHammett
    wrote on last edited by
    #1

    I have discovered that my startup script on Debian 8.6 isn't working. It works fine when I run netxmsd directly, but not when I run it via /etc/init.d/netxmsd start. There are no log entries made that way.

    Can I get someone's verified working script so that I can get mine running again?

    1 Reply Last reply
    0
    • M
      M
      MHammett
      wrote on last edited by
      #2

      I've also tried via systemctl.

      root@netXMS:/etc/init.d# systemctl start netxmsd
      root@netXMS:/etc/init.d# systemctl status netxmsd
      â netxmsd.service - LSB: NetXMS server
         Loaded: loaded (/etc/init.d/netxmsd)
         Active: active (exited) since Fri 2016-11-11 08:07:06 CST; 4min 58s ago
      
      Nov 11 08:07:06 netXMS systemd[1]: Started LSB: NetXMS server initscript.
      Nov 11 08:08:47 netXMS systemd[1]: Started LSB: NetXMS server initscript.
      Nov 11 08:08:59 netXMS systemd[1]: Started LSB: NetXMS server.
      Nov 11 08:12:02 netXMS systemd[1]: Started LSB: NetXMS server.
      root@netXMS:/etc/init.d# ps aux | grep net
      root        28  0.0  0.0      0     0 ?        S<   Oct16   0:00 [netns]
      root     19584  0.0  0.0   5844   712 pts/0    S+   08:07   0:00 tail -f -n 50 /var/log/netxmsd.log
      root     19616  0.0  0.0  12732  2304 pts/2    S+   08:12   0:00 grep net
      
      1 Reply Last reply
      0
      • A
        A
        Alex Kirhenshtein
        wrote on last edited by
        #3

        I'm successfully use this one: https://github.com/netxms/packages-deb/blob/master/netxms-server.netxmsd.init

        Which one do you use?

        1 Reply Last reply
        0
        • A
          A
          adimitrov
          wrote on last edited by
          #4

          Hello ,

          Check if the header of the startup script is full. I notice that the ubuntu script is not with the full header (see attachment). you can copy the header from one of the other scripts and it runs fine or use the script for ubuntu (if you are using debian) and other way around if you are using ubuntu.

          Hope this help.

          Best regards,
          Adrian


          Screenshot_5.png

          1 Reply Last reply
          0
          • M
            M
            MHammett
            wrote on last edited by
            #5

            Looks like I use this one:

            #!/bin/sh
            # vim: syntax=sh
            ### BEGIN INIT INFO
            # Provides:          netxms-server
            # Required-Start:    $network $local_fs nxagentd
            # Required-Stop:
            # Default-Start:     2 3 4 5
            # Default-Stop:      0 1 6
            # Short-Description: NetXMS server
            # Description:       Network monitoring daemon, which collect and process metrics
            #                    from native and SNMP agents.
            ### END INIT INFO
            
            # Author: Alex Kirhenshtein <[email protected]>
            
            PATH=/sbin:/usr/sbin:/bin:/usr/bin
            DESC="NetXMS server"
            NAME=netxmsd
            DAEMON=/usr/bin/netxmsd
            DAEMON_ARGS="-d"
            PIDFILE=/var/run/$NAME.pid
            SCRIPTNAME=/etc/init.d/$NAME
            
            # Exit if the package is not installed
            [ -x $DAEMON ] || exit 0
            
            # Read configuration variable file if it is present
            [ -r /etc/default/$NAME ] && . /etc/default/$NAME
            
            # Load the VERBOSE setting and other rcS variables
            . /lib/init/vars.sh
            
            # Define LSB log_* functions.
            # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
            . /lib/lsb/init-functions
            
            #
            # Function that starts the daemon/service
            #
            do_start()
            {
                    # Return
                    #   0 if daemon has been started
                    #   1 if daemon was already running
                    #   2 if daemon could not be started
                    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                            || return 1
                    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                            $DAEMON_ARGS \
                            || return 2
                    # Add code here, if necessary, that waits for the process to be ready
                    # to handle requests from services started subsequently which depend
                    # on this one.  As a last resort, sleep for some time.
            }
            
            #
            # Function that stops the daemon/service
            #
            do_stop()
            {
                    # Return
                    #   0 if daemon has been stopped
                    #   1 if daemon was already stopped
                    #   2 if daemon could not be stopped
                    #   other if a failure occurred
                    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
                    RETVAL="$?"
                    [ "$RETVAL" = 2 ] && return 2
                    # Wait for children to finish too if this is a daemon that forks
                    # and if the daemon is only ever run from this initscript.
                    # If the above conditions are not satisfied then add some other code
                    # that waits for the process to drop all resources that could be
                    # needed by services started subsequently.  A last resort is to
                    # sleep for some time.
                    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
                    [ "$?" = 2 ] && return 2
                    # Many daemons don't delete their pidfiles when they exit.
                    rm -f $PIDFILE
                    return "$RETVAL"
            }
            
            #
            # 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 --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
                    return 0
            }
            
            case "$1" in
              start)
                [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
                do_start
                case "$?" in
                            0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
                    esac
              ;;
              stop)
                    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
                    do_stop
                    case "$?" in
                            0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
                    esac
                    ;;
              status)
                   status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
                   ;;
              #reload|force-reload)
                    #
                    # If do_reload() is not implemented then leave this commented out
                    # and leave 'force-reload' as an alias for 'restart'.
                    #
                    #log_daemon_msg "Reloading $DESC" "$NAME"
                    #do_reload
                    #log_end_msg $?
                    #;;
              restart|force-reload)
                    #
                    # If the "reload" option is implemented then remove the
                    # 'force-reload' alias
                    #
                    log_daemon_msg "Restarting $DESC" "$NAME"
                    do_stop
                    case "$?" in
                      0|1)
                            do_start
                            case "$?" in
                                    0) log_end_msg 0 ;;
                                    1) log_end_msg 1 ;; # Old process is still running
                                    *) log_end_msg 1 ;; # Failed to start
                            esac
                            ;;
                      *)
                            # Failed to stop
                            log_end_msg 1
                            ;;
                    esac
                    ;;
              *)
                    echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
                    exit 3
                    ;;
            esac
            
            :
            

            There was also this one:

            #! /bin/sh
            ### BEGIN INIT INFO
            # Provides:          netxmsd
            # Required-Start:    $remote_fs nxagentd
            # Required-Stop:     $remote_fs
            # Default-Start:     2 3 4 5
            # Default-Stop:      0 1 6
            # Short-Description: NetXMS server initscript
            # Description:       NetXMS server startup script
            ### END INIT INFO
            
            # Author: Raden Solutions <[email protected]>
            
            # Do NOT "set -e"
            
            # PATH should only include /usr/* if it runs after the mountnfs.sh script
            PATH=/sbin:/usr/sbin:/bin:/usr/bin
            DESC="NetXMS Server"
            NAME=netxmsd
            DAEMON=~BINDIR~/$NAME
            DAEMON_ARGS="-d"
            PIDFILE=/var/run/$NAME.pid
            SCRIPTNAME=/etc/init.d/$NAME
            
            # Exit if the package is not installed
            [ -x "$DAEMON" ] || exit 0
            
            # Read configuration variable file if it is present
            [ -r /etc/default/$NAME ] && . /etc/default/$NAME
            
            # Load the VERBOSE setting and other rcS variables
            . /lib/init/vars.sh
            
            # Define LSB log_* functions.
            # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
            . /lib/lsb/init-functions
            
            #
            # Function that starts the daemon/service
            #
            do_start()
            {
                    # Return
                    #   0 if daemon has been started
                    #   1 if daemon was already running
                    #   2 if daemon could not be started
                    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                            || return 1
                    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                            $DAEMON_ARGS \
                            || return 2
                    # Add code here, if necessary, that waits for the process to be ready
                    # to handle requests from services started subsequently which depend
                    # on this one.  As a last resort, sleep for some time.
            }
            
            #
            # Function that stops the daemon/service
            #
            do_stop()
            {
                    # Return
                    #   0 if daemon has been stopped
                    #   1 if daemon was already stopped
                    #   2 if daemon could not be stopped
                    #   other if a failure occurred
                    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
                    RETVAL="$?"
                    [ "$RETVAL" = 2 ] && return 2
                    # Wait for children to finish too if this is a daemon that forks
                    # and if the daemon is only ever run from this initscript.
                    # If the above conditions are not satisfied then add some other code
                    # that waits for the process to drop all resources that could be
                    # needed by services started subsequently.  A last resort is to
                    # sleep for some time.
                    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
                    [ "$?" = 2 ] && return 2
                    # Many daemons don't delete their pidfiles when they exit.
                    rm -f $PIDFILE
                    return "$RETVAL"
            }
            
            #
            # 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 --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
                    return 0
            }
            
            case "$1" in
              start)
                    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
                    do_start
                    case "$?" in
                            0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
                    esac
                    ;;
              stop)
                    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
                    do_stop
                    case "$?" in
                            0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                            2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
                    esac
                    ;;
              #reload|force-reload)
                    #
                    # If do_reload() is not implemented then leave this commented out
                    # and leave 'force-reload' as an alias for 'restart'.
                    #
                    #log_daemon_msg "Reloading $DESC" "$NAME"
                    #do_reload
                    #log_end_msg $?
                    #;;
              restart|force-reload)
                    #
                    # If the "reload" option is implemented then remove the
                    # 'force-reload' alias
                    #
                    log_daemon_msg "Restarting $DESC" "$NAME"
                    do_stop
                    case "$?" in
                      0|1)
                            do_start
                            case "$?" in
                                    0) log_end_msg 0 ;;
                                    1) log_end_msg 1 ;; # Old process is still running
                                    *) log_end_msg 1 ;; # Failed to start
                            esac
                            ;;
                      *)
                            # Failed to stop
                            log_end_msg 1
                            ;;
                    esac
                    ;;
              status)
                    status_of_proc $DAEMON $NAME && exit 0 || exit $?
                    ;;
              *)
                    #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
                    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
                    exit 3
                    ;;
            esac
            
            :
            

            The second one was modified around the time I was trying to fix it.

            However now it's starting fine on reboot.  *sigh*

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            Powered by NodeBB Contributors
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups