Stop and restart service. How?

Forum Forums New users New Users and General Questions Stop and restart service. How?

  • This topic has 9 replies, 5 voices, and was last updated Jan 27-11:50 pm by Anonymous.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #76235
    Member
    oparun

      Trying to install and configure stubby (encrypt dns). The how-to calls for stop – and – restart procedure. How should i do it? I’ve tried “the-void-way” (according to Google): sudo sv down stubby. It didn’t work.

      #76242
      Moderator
      caprea
        Helpful
        Up
        0
        ::

        Did you try
        sudo service stubby stop
        sudo service stubby start
        or
        sudo service stubby restart
        for restarting

        #76243
        Anonymous
          Helpful
          Up
          0
          ::

          terminal commandline to access the manpage:
          man service

          • This reply was modified 1 year, 2 months ago by Brian Masinick. Reason: From skidoo
          • This reply was modified 1 year, 2 months ago by Brian Masinick. Reason: From skidoo
          #76244
          Member
          oparun
            Helpful
            Up
            0
            ::

            sudo service stubby start
            stubby: unrecognized service

            didn’t work ((

            • This reply was modified 1 year, 3 months ago by oparun.
            #76249
            Anonymous
              Helpful
              Up
              1
              ::

              unrecognized service

              Are you certain the installation completed successfully?
              How to check…

              sudo service --status-all
              or
              sudo sysv-rc-conf

              edit:
              aha, the packaged-by-debian “stubby” packages.debian.org/bullseye/amd64/stubby/filelist
              does not provide a sysv initscript. You will need to manually craft one.

              • This reply was modified 1 year, 2 months ago by Brian Masinick. Reason: From skidoo
              #76251
              Member
              oparun
                Helpful
                Up
                0
                ::

                does not provide a sysv initscript. You will need to manually craft one.

                how do i do it?

                I’ve found a script that can be suitable for my situation. It’s on github. Can you kindly look at it and tell me what should i do with it?
                I’ve found some information about sysvinit on archwiki, but i cannot do the same with my antix install. For example i have rc.1 – 5 and on arch (according to wiki) there is only /etc/rc.d (one directory)

                The script lies here:
                shorturl.at/mEFL9

                • This reply was modified 1 year, 3 months ago by oparun.
                #76253
                Member
                PPC
                  Helpful
                  Up
                  0
                  ::

                  Search (on-line) and you shall find… It took me 2 seconds to find this on ddg: https://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

                  #76254
                  Anonymous
                    Helpful
                    Up
                    0
                    ::

                    I _almost_ posted (from a websearch query: “tutorial sysv initscript”) a link to that identical cyberciti page

                    Anyhow, I am not familiar with “stubby”, but the script from the shortlink url looks reasonable.

                    How do I…

                    This is a sysV init thing, not proprietary to antiX.
                    Through the years I have probably posted a ‘splainer or walkthrough describing the sysV init and the boot process,
                    but I can’t find that post (I recall having invited others to followup by describing rc.local)…
                    edit:
                    found the prior post ~~ pasting most of its content, into a quotebox here

                    http://www.antixforum.com/forums/topic/how-do-i-start-a-daemon/#post-48685
                    A SysV (aka SystemV) init walkthrough

                    During boot, immediately following Linux kernel initialization, the init script executes /sbin/init

                    === In the “live boot” scenario, an interim init (extracted from within the initrd)
                    === is executed, and it performs a plethora of operations prior to calling
                    === the switch_root command and handing off to /sbin/init

                    /sbin/init reads /etc/initscript and consults /etc/inittab
                    (which governs a series of scripts required to complete the initialization process)
                    ^—v
                    Next, /sbin/init (according to entries in /etc/inittab)
                    will exec /etc/xxxxxx passing to it the requested initial runlevel (as specified in /etc/inittab)

                    ===
                    === above, I’m omitting some details in this draft
                    ===

                    The numbering convention for runlevels, across linux distributions, typically includes
                    0 = halt
                    1 = single-user mode (only runs /etc/rc.d/rc.sysinit; does not run /etc/rc.d/rc)
                    6 = reboot
                    and runlevels 2-3-4-5 are configured to achieve various forms of multi-user mode

                    Theoretically, you could declare n configure additional runlevels 7 thru 9. If you configured
                    a “runlevel 7”, its operation would be no higher//better//later than the existing numbered runlevels,
                    (mentioned just for sake of completeness: Doing this would be accomplished by editing /etc/inittab )

                    SysVinit goes directly to the runlevel specified in /etc/inittab; It does not consult
                    the scripts in the other levels. However, at each boot, we can provide a bootline
                    argument to override the configured default target runlevel.

                    While a system is running, admin can command a switchover from one runlevel to another,
                    via the init (aka ‘telinit’) command. When switching runlevels, the init system assesses the difference
                    between the current and target runlevel. Any processes listed for the current level but not in the target
                    runlevel are killed using the kill scripts, then any listed for the target runlevel but not in the
                    current are executed. Items that exist in both run levels are left undisturbed.

                    ===
                    ===
                    ===

                    on antiX (and other OSes using SysV init) all startup scripts for any process which will be started
                    when entering one (or several) of the runlevels, are stored in // read from the directory /etc/init.d/
                    .
                    The initscripts are processed in numerical order, according to your assigned script filenames.
                    .
                    After placing a new script into /etc/init.d/, you can use the tool (command) ____ update-rc.d _____
                    to generate symlinks ~~ one symlink will be added into each of the numbered /etc/rc[0-6]/ directories.
                    If the new script is to be stopped for a given runlevel, update-rc.d will preface the name of its symlink
                    with a K (kill); it the new script is intended to be started for that runlevel, an S (start) prefix
                    will be applied.
                    .
                    Learn by example: inspect the content of the various existing /etc/init.d/ “init scripts” and note
                    the convention(s) used in their declaratory header lines.
                    .
                    Various tutorials are available online. For example: wiki.linuxquestions.org/wiki/Creating_startup_scripts

                    note: a process called via an initscript will not necessarily be a “daemon”.
                    (Many of ’em, run in order to perform prep, or housekeeping upon entering a runlevel then they immediately exit.)

                    Here are some helpful web resources:
                    linuxfromscratch.org/lfs/view/9.0/chapter07/usage.html
                    boot-init-shutdown-sysv.html

                    some relevant manpages:
                    man boot
                    man init
                    man rc
                    man runlevel
                    man inittab
                    man sysv-rc-conf
                    man initscript
                    man update-rc.d

                    When you place this initscript in /etc/init.d
                    running update-rc.d will parse the initscript and, based on finding the line
                    Default-Start: 2 3 4 5
                    will create symlinks:
                    /etc/rc2.d/stubby
                    /etc/rc3.d/stubby
                    /etc/rc4.d/stubby
                    /etc/rc5.d/stubby

                    note: Typically, a desktop user is booting straight to runlevel 5.

                    Each time the system initializes a given runlevel, the init system reads (follows) the symlinks present is the associated /etc/rc*.d/ directory, launching//exec()ing each item.

                    #!/bin/sh
                    
                    ### BEGIN INIT INFO
                    # Provides:          stubby
                    # Required-Start:    $local_fs $network
                    # Required-Stop:     $local_fs
                    # Default-Start:     2 3 4 5
                    # Default-Stop:      0 1 6
                    # Short-Description: stubby service
                    # Description:       stubby, the secure DNS proxy
                    ### END INIT INFO
                    
                    PATH=/bin:/usr/bin:/sbin:/usr/sbin
                    NAME=stubby
                    DAEMON=/usr/bin/stubby
                    PIDFILE=/run/stubby.pid
                    CONFIG=/etc/stubby/stubby.yml
                    USER=stubby
                    
                    test -f $DAEMON || exit 0
                    
                    . /lib/lsb/init-functions
                    
                    case "$1" in
                    	start)
                    		log_daemon_msg "Starting $NAME"
                    		touch $PIDFILE
                    		chown $USER $PIDFILE
                    		chmod 700 $PIDFILE
                    		start-stop-daemon --start --exec $DAEMON --pidfile $PIDFILE --chuid $USER --quiet --oknodo -- -C $CONFIG -g
                    		log_end_msg $?
                    		exit $?
                    		;;
                    
                    	stop)
                    		log_daemon_msg "Stopping $NAME"
                    		start-stop-daemon --stop --exec $DAEMON --pidfile $PIDFILE --remove-pidfile --user $USER --quiet --oknodo
                    		log_end_msg $?
                    		exit $?
                    		;;
                    
                    	restart)
                    		$0 stop && $0 start
                    		exit $?
                    		;;
                    
                    	status)
                    		status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME"
                    		exit $?
                    		;;
                    
                    	*)
                    		echo "Usage: $0 {start|stop|restart|status}"
                    		exit 1
                    		;;
                    esac
                    • This reply was modified 1 year, 2 months ago by Brian Masinick. Reason: From skidoo
                    #76256
                    Member
                    Robin
                      Helpful
                      Up
                      0
                      ::

                      Many thanks, Skidoo! This was new also to me.

                      aha, the packaged-by-debian <your-favourite-package-here> packages.debian.org/bullseye/…
                      does not provide a sysv initscript. You will need to manually craft one.

                      Ok, this is something I didn’t expect. Do I conclude correctly that the original debian packages do install programs incomplete on antiX sometimes? (just like gaupol, missing a dependency to a package you pointed me?)

                      And is this procedure meant to be applied always when original manual of an application or tutorials in internet refer to »systemctl« or any other ways of starting and stopping service programs user postinstalled in antiX?

                      How to determine what to write exactly into this script? (Will now read the tutorials you’ve linked to, maybe after this reading the last question is solved already.)

                      Windows is like a submarine. Open a window and serious problems will start.

                      #76258
                      Anonymous
                        Helpful
                        Up
                        0
                        ::

                        How to determine what to write exactly into this script?

                        The suggested script which you found online (and linked, and I pasted into the post above) seems “good to go” as is.

                        original debian packages do install programs incomplete(ly) on antiX sometimes?

                        Across the past several years, most debian packagers have catered for, and only for, systemd init.
                        Maybe, possibly, they will achieve a reasonable middle-ground… in the meantime, yes sometimes the debian packages are “incomplete” for our use (under sysV init, or runit init)
                        ref: Nov 2019 LWN.net article Debian reconsiders init-system diversity

                        is this procedure meant to be applied always when original manual of an application or tutorials in internet refer to »systemctl« or any other ways of starting and stopping service programs user postinstalled in antiX?

                        The question is a bit broad, but… “systemctl” is never applicable to antiX.
                        FWIW, I can’t recall the last time I installed a debian -provided package and was relegated to handcrafting an initscript.

                        • This reply was modified 1 year, 2 months ago by Brian Masinick. Reason: From skidoo
                      Viewing 10 posts - 1 through 10 (of 10 total)
                      • You must be logged in to reply to this topic.