Commit Graph

63 Commits (1634461bd208f4bd108ea5c3d3f1cf9eb56d4a7e)

Author SHA1 Message Date
Daniel Bailey 5792f6a104 procd: allow optional watchdog instance parameter
Optional instance watchdog timeout and watchdog mode can be set by
adding: procd_set_param $mode $timeout

$mode is an integer [0-1] representing instance watchdog mode of
operation:
0 = disabled
1 = passive mode, client must periodically poke watchdog via ubus

$timeout is an integer representing how often, in seconds, the watchdog must be poked.

Signed-off-by: Daniel Bailey <danielb@meshplusplus.com>
4 years ago
Daniel Golle 8097fd4d5f procd: jail: fix segfault and add console feature
2e73848 jail: SIGSEGV must not be forwarded to the child process
 7e150f6 jail: unnamed jails can not have netns (fix segfault)
 1ab539b jail: add option to provide /dev/console to containers

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Adrian Schmutzler f079db3844 procd: replace backticks by $(...)
This replaces deprecated backticks by more versatile $(...) syntax.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
4 years ago
Daniel Golle 02a1914585 procd: bump to latest HEAD
2188d81 jail: add support for launching extroot containers
 6f3dbd2 jail: add support for userns and cgroupsns
 28a06e5 jail: add support for (ram-)overlayfs

Add handling for extroot, overlaydir and tmpoverlaysize as well as
jail flags for userns and cgroupsns to OpenWrt's shell script to
allow their use in init scripts.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Daniel Golle 40e578992b procd: actually wire-up netns support
When support for network namespaces was added to procd, adding the
corresponding jail flag in procd.sh was ommitted. Add it now.

Fixes: 97a03a4760 ("procd: update to latest git HEAD")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
4 years ago
Kevin Darbyshire-Bryant c0c988e179 procd: support 'requirejail' attribute
Bump procd package to reduce log spam related to missing jail binaries
in a non-jail capable system.

bcb8655 instance: add 'requirejail' attribute

An additional jail attribute 'requirejail' can now be used to indicate
mandatory use of a jailed environment and hence prevent process startup
in the event that the jail subsystem is unavailable.

Procd will now only log errors if jail is unavailable and 1) is a mandatory
requirement or 2) a procd debug level of at least 2 is in use.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
4 years ago
Alin Nastac ddf6ec29b4 procd: allow usage of * as procd_running() instance parameter
service_running() implementation in /etc/rc.common use it.
It is preferable to use wildcard than assuming the instance
name is the default one.

jsonfilter returns all matches when wildcards are used, hence
the -l 1 argument used to limit output to only one value.

Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
5 years ago
Jo-Philipp Wich c933b6d224 procd: fix invalid JSON filter expression in procd_running()
Since service and instance names may contain characters which are not allowed
in JSON path labels, such as dashes or spaces, change the filter expression
to array square bracket notation to properly match these cases as well.

Fixes: 2c3dd70741 ("procd: add procd_running() helper for checking running state")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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
Rafał Miłecki 2c3dd70741 procd: add procd_running() helper for checking running state
This should be helpful for implementing service_running() in procd init
scripts.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
5 years ago
Michael Heimpold 218b1bbecd procd: allow passing optional group instance parameter
Sometimes is desirable to run a process with a specific group id
instead of the default one which is derived from passwd entry.
This can be achived now by using procd_set_param group $mygroup.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_SOURCE_VERSION update]
5 years ago
Michael Heimpold a12ab07e21 procd: allow passing optional syslog facility as instance parameter
Optional syslog facility can be set by adding procd_set_param facility
$myfacility.
While at, also add stdout/stderr documentation.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_SOURCE_VERSION update]
5 years ago
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>
6 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>
6 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