make service look in /etc/system.conf.d/<progname> first for config file.
This makes it easier to - have non-base system drivers (get clobbered by global system.conf) - have drivers as packages (can't touch global system.conf) - make configs part of the drivers/servers instead of in global file (makes system parts more self-contained)
This commit is contained in:
parent
1f2054c89c
commit
b1847ae244
3 changed files with 32 additions and 5 deletions
|
@ -116,6 +116,7 @@ PRIVATE long req_period = 0;
|
||||||
PRIVATE char *req_script = NULL;
|
PRIVATE char *req_script = NULL;
|
||||||
PRIVATE char *req_ipc = NULL;
|
PRIVATE char *req_ipc = NULL;
|
||||||
PRIVATE char *req_config = PATH_CONFIG;
|
PRIVATE char *req_config = PATH_CONFIG;
|
||||||
|
PRIVATE int custom_config_file = 0;
|
||||||
PRIVATE int class_recurs; /* Nesting level of class statements */
|
PRIVATE int class_recurs; /* Nesting level of class statements */
|
||||||
PRIVATE int req_lu_state = DEFAULT_LU_STATE;
|
PRIVATE int req_lu_state = DEFAULT_LU_STATE;
|
||||||
PRIVATE int req_lu_maxtime = DEFAULT_LU_MAXTIME;
|
PRIVATE int req_lu_maxtime = DEFAULT_LU_MAXTIME;
|
||||||
|
@ -339,6 +340,7 @@ PRIVATE int parse_arguments(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], ARG_CONFIG)==0) {
|
else if (strcmp(argv[i], ARG_CONFIG)==0) {
|
||||||
req_config = argv[i+1];
|
req_config = argv[i+1];
|
||||||
|
custom_config_file = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], ARG_LU_STATE)==0) {
|
else if (strcmp(argv[i], ARG_LU_STATE)==0) {
|
||||||
errno=0;
|
errno=0;
|
||||||
|
@ -1343,16 +1345,15 @@ PRIVATE void do_service(config_t *cpe, config_t *config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE void do_config(char *label, char *filename)
|
PRIVATE int do_config(char *label, char *filename)
|
||||||
{
|
{
|
||||||
config_t *config, *cp, *cpe;
|
config_t *config, *cp, *cpe;
|
||||||
|
|
||||||
config= config_read(filename, 0, NULL);
|
config= config_read(filename, 0, NULL);
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "config_read failed for '%s': %s\n",
|
/* config file read failed. */
|
||||||
filename, strerror(errno));
|
return 1;
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find an entry for our service */
|
/* Find an entry for our service */
|
||||||
|
@ -1396,6 +1397,9 @@ PRIVATE void do_config(char *label, char *filename)
|
||||||
cpe= cpe->next;
|
cpe= cpe->next;
|
||||||
|
|
||||||
do_service(cpe, config);
|
do_service(cpe, config);
|
||||||
|
|
||||||
|
/* config file read ok. */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main program.
|
/* Main program.
|
||||||
|
@ -1464,8 +1468,29 @@ PUBLIC int main(int argc, char **argv)
|
||||||
rs_start.rss_cpu = DSRV_CPU;
|
rs_start.rss_cpu = DSRV_CPU;
|
||||||
|
|
||||||
if (req_config) {
|
if (req_config) {
|
||||||
|
int config_fail = 0;
|
||||||
assert(progname);
|
assert(progname);
|
||||||
do_config(progname, req_config);
|
if(custom_config_file) {
|
||||||
|
config_fail = do_config(progname, req_config);
|
||||||
|
} else {
|
||||||
|
char *specificconfig;
|
||||||
|
if(asprintf(&specificconfig, "%s/%s", _PATH_SYSTEM_CONF_DIR,
|
||||||
|
progname) < 0) {
|
||||||
|
errx(1, "no memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try specific config filename first,
|
||||||
|
* and only if it fails, the global system one.
|
||||||
|
*/
|
||||||
|
config_fail =
|
||||||
|
do_config(progname, specificconfig) &&
|
||||||
|
do_config(progname, req_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config_fail) {
|
||||||
|
fprintf(stderr, "config_read failed for %s\n", progname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(rs_start.rss_priority < NR_SCHED_QUEUES);
|
assert(rs_start.rss_priority < NR_SCHED_QUEUES);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
755 root operator /dev
|
755 root operator /dev
|
||||||
/dev/mouse -> /dev/kbdaux
|
/dev/mouse -> /dev/kbdaux
|
||||||
755 root operator /etc
|
755 root operator /etc
|
||||||
|
755 root operator /etc/system.conf.d
|
||||||
755 root operator /boot
|
755 root operator /boot
|
||||||
755 root operator /boot/image
|
755 root operator /boot/image
|
||||||
555 root operator /mnt
|
555 root operator /mnt
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
#define _PATH_BSHELL "/bin/sh"
|
#define _PATH_BSHELL "/bin/sh"
|
||||||
#define _PATH_SERVICE "/bin/service"
|
#define _PATH_SERVICE "/bin/service"
|
||||||
#define _PATH_SYSTEM_CONF "/etc/system.conf"
|
#define _PATH_SYSTEM_CONF "/etc/system.conf"
|
||||||
|
#define _PATH_SYSTEM_CONF_DIR "/etc/system.conf.d"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue