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.
-
AuthorPosts
-
January 27, 2022 at 5:25 pm #76235Member
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.
January 27, 2022 at 6:51 pm #76242Moderator
caprea
::Did you try
sudo service stubby stop
sudo service stubby start
or
sudo service stubby restart
for restartingJanuary 27, 2022 at 6:57 pm #76243Anonymous
::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
January 27, 2022 at 7:00 pm #76244Member
oparun
::sudo service stubby start
stubby: unrecognized servicedidn’t work ((
- This reply was modified 1 year, 3 months ago by oparun.
January 27, 2022 at 7:13 pm #76249Anonymous
::unrecognized service
Are you certain the installation completed successfully?
How to check…sudo service --status-all or sudo sysv-rc-confedit:
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
January 27, 2022 at 7:15 pm #76251Member
oparun
::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.
January 27, 2022 at 7:32 pm #76253MemberPPC
::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
January 27, 2022 at 7:44 pm #76254Anonymous
::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 herehttp://www.antixforum.com/forums/topic/how-do-i-start-a-daemon/#post-48685
A SysV (aka SystemV) init walkthroughDuring 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 modeTheoretically, 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_scriptsnote: 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.htmlsome relevant manpages:
man boot
man init
man rc
man runlevel
man inittab
man sysv-rc-conf
man initscript
man update-rc.dWhen 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/stubbynote: 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
January 27, 2022 at 11:13 pm #76256MemberRobin
::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.
January 27, 2022 at 11:50 pm #76258Anonymous
::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 diversityis 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
-
AuthorPosts
- You must be logged in to reply to this topic.