Commit Graph

38 Commits (91c61aae200ecf98e332482d395beda819d6a4fa)

Author SHA1 Message Date
Florian Eckert 91c61aae20 base-files: add enabled commands to service rc.common
Add missing enbaled command help output.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
4 years ago
Peter Stadler 953c27df31 base-files: rc.common: fix missing EXTRA_HELP texts
Commit ed5b9129d7 ("base-files: implement generic service_running")
has added EXTRA_HELP variable, thus overriding already available
EXTRA_HELP text available in other init scripts, resulting in the
missing help text from services like dropbear for example.

So fix this regression by appending EXTRA_HELP text provided by the
other init scripts into the one provided by the script itself.

Fixes: ed5b9129d7 ("base-files: implement generic service_running")
Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
[commit title/description facelift, fixes tag, fixed From:, pkg bump]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Luiz Angelo Daros de Luca 7519a36774 base-files,procd: add generic service status
Adds a default status action for init.d scripts.

procd "service status" will return:

 0) for loaded services (even if disabled by conf or dead)
 3) for inactive services
 4) when filtering a non-existing instance

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
[rebased, cleaned up]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Petr Štetiar ed5b9129d7 base-files: implement generic service_running
DRY is good, otherwise we're going to suffer with a copy&paste disease
in the init scripts.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Arthur Skowronek fc23bcdaa2 base-files: add service_stopped as a post stop hook
Purpose of these changes is to introduce a hook for post service
shutdown in a similar fashion to the existing hook service_started. I
found it to be useful to specify a hook that is called once the service
has been stopped and not before the service is stopped like the
stop_service hook does.

The concrete use case I have for this is that I'm running a binary that
takes over the hardware watchdog timer. Said binary unfortunately can
not use ubus directly to tell procd to hand over the watchdog timer so
this has to be done in the service file for the binary in question. In
order to support a clean handover of the watchdog timer back to procd,
the service init script has to dispatch the ubus invocation once the
binary in question has been stopped.

Signed-off-by: Arthur Skowronek <ags@digineo.de>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
[added commit message, use the same form as other hooks]
5 years ago
Linus Kardell 2ac1a57677 base-files: fix unkillable processes after restart
When restart is run on an init script, the script traps SIGTERM. This is
done as a workaround for scripts named the same name as the program they
start. In that case, the init script process will have the same name as
the program process, and so when the init script runs killall, it will
kill itself. So SIGTERM is trapped to make the init script unkillable.

However, the trap is retained when the init script runs start, and thus
processes started by restart will not respond to SIGTERM, and will thus
be unkillable unless you use SIGKILL. This fixes that by removing the
trap before running start.

Signed-off-by: Linus Kardell <linus@telliq.com>
6 years ago
Roman Yeryomin 8b477d09d1 base-files: protect stop and reload actions with procd_lock
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Signed-off-by: Andrejs Hanins <ahanins@gmail.com>
7 years ago
Roman Yeryomin 0b1fa809d0 base-files: rc.common: fix enable() return code and logic
In current state, if there is START but no STOP, enbale()
will return 1 (failure), which is wrong.
Moreover there is no need to check for START/STOP twice.
Instead, add err variable to save success state and
and return it's value.
Also eliminate the need to disable() by using 'ln -sf',
which will first delete the old symlink if one exists.

Changes from v1:
- fixed description

Signed-off-by: Roman Yeryomin <roman@advem.lv>
7 years ago
Pierre Lebleu 832b6b8305 procd: service_data: Support data within the service itself
Use the same approach than the service_triggers for the service_data.

Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
7 years ago
Alexandru Ardelean c7ee30d53a base-files: fix default procd reload
Bug introduced with 6713694.

I did not count on procd handling reload as mentioned
in this doc:
https://wiki.openwrt.org/inbox/procd-init-scripts

```
procd_set_param file /var/etc/your_service.conf # /etc/init.d/your_service reload will restart the daemon if these files have changed
procd_set_param netdev dev # likewise, except if dev's ifindex changes.
procd_set_param data name=value ... # likewise, except if this data changes.
```

The service would be restarted regardless of any of those params.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
7 years ago
Alexandru Ardelean 6713694fe4 base-files: use restart if no reload hook for service
This was also working before, with a slightly
different semantic.

[ Original semantic ]
If no reload hooks was implemented, the default one would
kick in, it would return fail, and restart would happen.

This would happen also in the case where a reload hook
would be implemented, it would fail, and it would restart
the service.

[ New semantic ]
The default reload hook calls restart.
Services can implement their own reload.

If reload fails, then the '/etc/init.d/<service> reload'
would return a non-zero code, and the caller can choose
a way to handle this.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
7 years ago
Pierre Lebleu 6bb11d52f3 procd: Allow initscripts to start one daemon instance at a time
Signed-off-by: Pierre Lebleu <pierre.lebleu@technicolor.com>
8 years ago
John Crispin 4cf7929869 base-files: add a init.d option that will start the syscall tracer
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 45009
9 years ago
Felix Fietkau d288a7903d rc.common: when reloading a service using procd, fall back to calling start instead of restart
This avoids unnecessary service restarts

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 41490
10 years ago
John Crispin 3a9bfa5938 base-files: add a post start hook to the procd init.d api
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41344
10 years ago
John Crispin 44e2de03a4 base-files: calling stop_service before procd_kill.
Before this patch, doing `/e/c/network restart' will emit the folloing
error by `ubus network.wireless down "{}"' because netifd already quit
by that time.

	Command failed: not found

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>

SVN-Revision: 40906
10 years ago
Felix Fietkau c622a37101 base-files: remove duplicate stop_service() function.
It was introduced in commit 2f966e8, "base-files: add a post start hook
for procd managed services".

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>

SVN-Revision: 40576
10 years ago
John Crispin 950428fb1b base-files: add a post start hook for procd managed services
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38024
11 years ago
John Crispin 8eb56a88a4 procd: add a small script that handles config reloads until configd is ready
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 37248
11 years ago
John Crispin 06ae364c3d base-files: run readlink on initscript name before opening services
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 37241
11 years ago
Felix Fietkau bbc6694d98 base-files: add basic procd integration, let procd start (and restart) ubus instead of having an ubus init script
SVN-Revision: 34866
12 years ago
Jo-Philipp Wich bfe966574f base-files: enable shell tracing in initscripts when INIT_TRACE is set
SVN-Revision: 32340
12 years ago
Felix Fietkau 6f46704743 base-files: split service related functions off to /lib/functions/service.sh
SVN-Revision: 31042
12 years ago
Nicolas Thill d0659ce37e package/base-files: move service* functions from /etc/rc.common to /lib/functions.sh
SVN-Revision: 28864
13 years ago
Nicolas Thill 10a03275bf package/base-files: /etc/rc.common: add service wrapper around start-stop-daemon
SVN-Revision: 28834
13 years ago
Felix Fietkau 8ff7756e82 base-files: warn when calling /etc/init.d/<script> enable and neither START nor STOP is defined
SVN-Revision: 27797
13 years ago
Felix Fietkau 5a351509aa base-files: use shutdown instead of stop when the system goes down (patch by tripolar)
SVN-Revision: 24540
14 years ago
Nicolas Thill b34bba25d2 base-files: fix shell syntax (prevent error messages when activating initscripts in IB)
SVN-Revision: 20571
14 years ago
Florian Fainelli de3a491240 simplify action handling in rc.common (#5558)
SVN-Revision: 17012
15 years ago
Nicolas Thill 7218e6326f make links to statup scripts in /etc/rc.d relative
SVN-Revision: 12659
16 years ago
Felix Fietkau e84e3a5b03 missing optional parameters for restart and boot functions
Add missing optional parameters in remaining rc functions.
It fixes my previous implementation of parametrized rc functions [8106],
ticket #3063, thanks argovela-at-yahoo-com for reporting.

Signed-off-by: Lubos Stanek (lubek) <lubek@lubek.name>

SVN-Revision: 10245
17 years ago
Felix Fietkau 6330c58b58 add patch from #2111
SVN-Revision: 8106
17 years ago
Mike Baker 5eb30e636d fix typo
SVN-Revision: 7170
17 years ago
Mike Baker bef40307bb START/STOP values must be specified in the init script
SVN-Revision: 7164
17 years ago
Mike Baker 291420a8f3 add K* scripts to be run at shutdown
SVN-Revision: 7163
17 years ago
Felix Fietkau 4bef6e13c2 add a workaround for self-killing init scripts on restart (#1023)
SVN-Revision: 5876
18 years ago
Felix Fietkau 9a5798e5f5 add a check to see if an init script is enabled
SVN-Revision: 5727
18 years ago
Felix Fietkau 59a06c71cb rename default/ to files/
SVN-Revision: 5622
18 years ago