Commit Graph

51 Commits (d13e86d4c2d4c1c8970a20cc1f3214b266f57ed0)

Author SHA1 Message Date
Jeffery To d13e86d4c2 procd: Add wrapper for uci_validate_section()
This adds a wrapper (uci_load_validate) for uci_validate_section() that
allows callers (through a callback function) to access the values set by
uci_validate_section(), without having to manually declare a
(potentially long) list of local variables.

The callback function receives two arguments when called, the config
section name and the return value of uci_validate_section().

If no callback function is given, then the wrapper exits with the value
returned by uci_validate_section().

This also updates several init scripts to use the new wrapper function.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
5 years ago
Yousong Zhou 60ad837bea procd: fix procd_lock() when prepare_roofs
This fixes the following errors when doing "make package/install"

    /home/yousong/git-repo/lede-project/lede/build_dir/target-mips_24kc_musl/root-malta/lib/functions/procd.sh: line 47: /home/yousong/git-repo/l
    ede-project/lede/build_dir/target-mips_24kc_musl/root-malta/var/lock/procd_urandom_seed.lock: No such file or directory
    flock: 1000: Bad file descriptor

Fixes FS#1260

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
6 years ago
Kevin Darbyshire-Bryant 37bb463daa procd: procd_send_signal use signal names
Usage documentation for 'procd_send_signal' states "The signal is SIGHUP
by default, and must be specified by NAME."  Make actual behaviour match
the stated documented behaviour.

https://wiki.openwrt.org/inbox/procd-init-scripts

Suggested-by: Jo-Philip Wich <jow@mein.io>
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
7 years ago
Roman Yeryomin e410f785a4 procd: introduce procd_lock for init script protection
Use flock to protect init script from concurrent execution
(of the same script).
Important for services which generate native config files.

Signed-off-by: Roman Yeryomin <roman@advem.lv>
Signed-off-by: Andrejs Hanins <ahanins@gmail.com>
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
Karl Palsson 7a423c389a procd: mdns: Support txt values with spaces
Properly quote the arguments so that you can register a service with TXT
entries that contains spaces.

Example:
   procd_add_mdns myservice tcp 9999 "key=descriptive text field 1" \
         "another=something equally verbose"

Output before:
$ avahi-browse -r -v _myservice._tcp
_myservice._tcp      local
   hostname = [blah.local]
   address = [192.168.255.74]
   port = [9999]
   txt = ["verbose" "equally" "another=something" "1" "field" "text" "key=descriptive"]

Output now:
$ avahi-browse -r -v _myservice._tcp
_myservice._tcp      local
   hostname = [blah.local]
   address = [192.168.255.74]
   port = [9999]
   txt = ["another=something equally verbose" "key=descriptive text field 1"]

Signed-off-by: Karl Palsson <karlp@etactica.com>
7 years ago
Jo-Philipp Wich 2c5f16ecac procd: support term_timeout parameter
Expose "term_timeout" parameter in procd.sh to allow init scripts to
request a longer termination timeout.

This is required to fix FS#859 in a later commit.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
7 years ago
Claudiu Brasovean c70c6ac070 procd.sh: use parameterized respawn values
continue work started here: http://patchwork.ozlabs.org/patch/520859

Extend /etc/config/system with parameters to set the default respawn treshold and respawn timeout
	for procd launched services that have respawn enabled.
This results in cleaner init scripts, while making sure services have respawn parameters set.

Signed-off-by: Claudiu Brasovean <cbrasho@gmail.com>
7 years ago
Denis Osvald d9a358d562 procd: fix default timeout for reload trigger actions
Default trigger action timeout was added to procd.sh in commit f88e3a4c0
(procd: add default timeout for reload trigger actions)
However, the timeout value was not placed under the correct JSON-script
array nesting level and thus did not apply.

To fix this and make the timeout actually apply to the reload triggers,
we place it in the correct scope, that is the per-trigger array.

Fixes: f88e3a4c0a
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
7 years ago
Bastian Bittorf b54cbad6ef procd: update procd.sh to disallow signal-numbers, enforce signal-names
A given signal-name is now converted to the corresonding number. In general
it's good style to use names (readability) and it's more portable: signal
numbers can be architecture-dependent, so we are more safe giving names.

A real world example is signal 10, which is BUS on ramips and USR1 on PPC.

All users of 'procd_send_signal' must change their code to reflect this.

Signed-off-by: Bastian Bittorf <bb@npl.de>
7 years ago
Hans Dedecker bbe825c74d procd: update procd.sh to support sending kill signal to a service
Add procd_send_signal which allows to send an optional specified
kill signal to one specified  or all instances of a given service.
By default SIGHUP is sent if no signal is specified

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
8 years ago
Jo-Philipp Wich b22a20af45 procd: add support for service signals
Update procd to latest HEAD in order to introduce support for services signals:

- Adds a new service.signal ubus call to send a kill() signal to one or all
  running instances of a given service

- Adds a new "reload_signal" property which allows service init scripts to
  request procd to send a specific kill() signal on reload, instead of
  stopping and restarting running processes

Also fixes some potential memory leaks reported by cppcheck and an environment
variable corruption in the trace command.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 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
Felix Fietkau f88e3a4c0a procd: add default timeout for reload trigger actions
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 8891d941e0 procd: rework trigger handling
Open/close triggers array around service_triggers call to make using
multiple triggers easier to deal with.
The API was quite confusing, because some functions contained implicit
trigger open/close calls and some didn't.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
John Crispin b756788cc4 procd: fix respawn related warning
WARNING: Variable 'respawn' does not exist or is not an array/object

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 48996
8 years ago
John Crispin 48e6ccc4e1 procd: support pidfile writing.
procd from revision b12bb150ed38a4409bef5127c77b060ee616b860 supports
writing a pidfile.  This adds support for setting that parameter with
standard init script hooks:

   procd_set_param pidfile /var/run/someprocess.pid

Signed-off-by: Karl Palsson <karlp@etactica.com>

SVN-Revision: 48984
8 years ago
John Crispin d98870feda procd: Allow to configure default respawn retry count
Extend /etc/config/system with a parameter to set the
default respawn retry for procd launched services that
have respawn enabled.

	config service
        	option respawn_retry -1

All services that don't specify specific respawn parameters
will get their defaults added by procd.sh. If respawn_retry
is specified in /etc/config/system the default retry limit
will be set to this value by procd.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>

SVN-Revision: 48915
8 years ago
John Crispin 32b37600b9 procd: update procd.sh to support new ujail options
Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>

SVN-Revision: 47862
9 years ago
Felix Fietkau 16fa80a8f1 procd: correct the order of respawn params in the comments.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>

SVN-Revision: 45955
9 years ago
John Crispin 5fe5aeaa72 procd: work around a event race
there is a conceptual design flaw in our interface events. workaround this by
disabling duplicate message supression in procd. we need to fix this properly
for the next release

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 45883
9 years ago
John Crispin 2b9ac1e0af procd: add a 10 second delay to the interface triggers
this is an ugly hack that will be removed when the netifd maintainers
have time to look at the problem.

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 45876
9 years ago
John Crispin a43bcc980e Removed reference to imaginary procd_add_interface_reload in procd.sh
The last line of procd.sh has a reference to procd_add_interface_reload. procd_add_interface_reload
doesn't seem to exist. I've removed the reference of it to minimize confusion.

Signed-off-by: Eric Schultz <eschultz@prplfoundation.org>

SVN-Revision: 45487
9 years ago
John Crispin e85b93d9b8 procd: add jail support
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 45010
9 years ago
Jo-Philipp Wich fd670d2756 procd: add support for relaying daemon stdio to syslog
Procd enabled init scripts can now specify:

  procd_set_param stdout 1
  procd_set_param stderr 1

... to relay their respective standard IO streams to the system log.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>

SVN-Revision: 44547
9 years ago
John Crispin 20940138ac scripts: fix wrong usage of '==' operator
[base-files] shell-scripting: fix wrong usage of '==' operator

normally the '==' is used for invoking a regex parser and is a bashism.
all of the fixes just want to compare a string. the used busybox-ash
will silently "ignore" this mistake, but make it portable/clean at least.

this patch does not change the behavior/logic of the scripts.

Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>

SVN-Revision: 42911
10 years ago
John Crispin f81614594f procd: update to latest git
add support for starting services as !root

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 42471
10 years ago
Felix Fietkau 2dabf3a775 procd: allow adding empty strings to arrays
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42456
10 years ago
John Crispin c23e0ed691 procd: run the mdns register outside the sub shell container
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 42327
10 years ago
John Crispin b0d9dcf84d procd: update to latest git HEAD
this adds a interafce.update trigger and mdns service registration helpers

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 42324
10 years ago
Felix Fietkau 5aef137f9e procd: add a shell helper function to emit a config.change event
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 41482
10 years ago
Felix Fietkau 2baf4d4fb0 procd: add shell functions to add instance data
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 41481
10 years ago
John Crispin 9912d02fa1 procd: fix uci_validation
Regardles of the return code from validate_data _error variable will be 0 due
to 'local' command in the previous line. With this patch we are able to catch
the return code from validate_data tool.

Signed-off-by: Luka Perkov <luka@openwrt.org>

SVN-Revision: 41414
10 years ago
John Crispin 91d82d7b36 procd: rename procd_add_network_trigger
i got complaints about the bad naming of the api. lets rename it while there are no users yet.

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41220
10 years ago
Felix Fietkau 79bbc4fbfb procd: allow passing multiple config files to procd_add_reload_trigger
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 41146
10 years ago
John Crispin bd179b2610 procd: service instances can now report an error of why they failed to start.
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41031
10 years ago
John Crispin e1e5f21b2f procd: add wrapper calls for interface triggers
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41008
10 years ago
John Crispin 59c8b70839 procd: rename local variable in uci_validate_section
Allow to use "package", "type", "name", "error" and "result"
as config option names:

package some_service
config section 'foo'
    option name 'bar'
    option type 'unknown'

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>

SVN-Revision: 41006
10 years ago
Felix Fietkau 84c3487e5a procd: add a PROCD_DEBUG variable that will dump the ubus calls from init scripts to stderr
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 39983
10 years ago
John Crispin b71eb4b5df procd: the helper script did not export all functions properly
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 39612
10 years ago
John Crispin 31a2912cd9 netifd: enable coredumps again
got broken due procd startup. Requires procd resource limit patch.

Signed-off-by: Ulrich Weber <uw@xyne.com>

SVN-Revision: 39020
11 years ago
Jo-Philipp Wich 387761e2fc procd: fix processing of datatype specification with spaces
SVN-Revision: 38935
11 years ago
John Crispin 91de2648e9 procd: update procd.sh to make use of the new validate_data tool
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38908
11 years ago
John Crispin 50db95e2f0 procd: options with default values are not parsed properly in the ubus register code
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38788
11 years ago
John Crispin 130d7de07f procd: update to latest git head
this includes the first wip version of the uci validation backend

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38786
11 years ago
Felix Fietkau d1794a7536 procd: fix command handling in procd_add_instance()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 38350
11 years ago
John Crispin 4f62127dea procd: update to latest git head
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38022
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 67eb275f69 procd: the delete ubus call was passed the wrong field name for services
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 37247
11 years ago
John Crispin 6884a8b59d procd: extend shell binding with trigger support
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 37157
11 years ago