mirror of
https://github.com/troglobit/finit.git
synced 2026-10-22 11:36:07 +00:00
New cmdline options to control debug and progress/status
Modeled after systemd.show_status, currently without the 'auto' setting. - finit.debug[=bool] - finit.show_status[=bool] - finit.status_style[=old,classic,new,modern] Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
35e4e0d073
commit
70ca64a392
5 files changed
+74
-19
No files matched your search
+45
-3
@@ -75,11 +75,53 @@ static void hide_args(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_bool(char *ptr, int default_value)
|
||||||
|
{
|
||||||
|
if (string_compare(ptr, "true") || string_compare(ptr, "on") || string_compare(ptr, "1"))
|
||||||
|
return 1;
|
||||||
|
if (string_compare(ptr, "false") || string_compare(ptr, "off") || string_compare(ptr, "0"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return default_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* finit.debug = [on,off]
|
||||||
|
* finit.show_status = [on,off]
|
||||||
|
*/
|
||||||
|
static void parse_finit_opts(char *opt)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ptr = strchr(opt, '=');
|
||||||
|
if (ptr)
|
||||||
|
*ptr++ = 0;
|
||||||
|
|
||||||
|
if (string_compare(opt, "debug")) {
|
||||||
|
debug = get_bool(ptr, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string_compare(opt, "status_style")) {
|
||||||
|
if (string_compare(ptr, "old") || string_compare(ptr, "classic"))
|
||||||
|
show_progress(PROGRESS_CLASSIC);
|
||||||
|
else
|
||||||
|
show_progress(PROGRESS_MODERN);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string_compare(opt, "show_status")) {
|
||||||
|
show_progress(get_bool(ptr, 1) ? PROGRESS_DEFAULT : PROGRESS_SILENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void parse_arg(char *arg)
|
static void parse_arg(char *arg)
|
||||||
{
|
{
|
||||||
/* Catches finit_debug, --debug, and debug */
|
if (!strncmp(arg, "finit.", 6)) {
|
||||||
if (strstr(arg, "debug"))
|
parse_finit_opts(&arg[6]);
|
||||||
debug = 1;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
|
if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
|
||||||
rescue = 1;
|
rescue = 1;
|
||||||
|
|||||||
+5
-5
@@ -307,11 +307,8 @@ static void finalize(void)
|
|||||||
plugin_run_hooks(HOOK_SYSTEM_UP);
|
plugin_run_hooks(HOOK_SYSTEM_UP);
|
||||||
service_step_all(SVC_TYPE_ANY);
|
service_step_all(SVC_TYPE_ANY);
|
||||||
|
|
||||||
/* Enable silent mode before starting TTYs */
|
/* Disable progress output at normal runtime */
|
||||||
if (!debug) {
|
enable_progress(0);
|
||||||
_d("Going silent ...");
|
|
||||||
show_progress(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delayed start of TTYs at bootstrap */
|
/* Delayed start of TTYs at bootstrap */
|
||||||
_d("Launching all getty services ...");
|
_d("Launching all getty services ...");
|
||||||
@@ -410,6 +407,9 @@ int main(int argc, char *argv[])
|
|||||||
if (!rescue && !debug)
|
if (!rescue && !debug)
|
||||||
screen_init();
|
screen_init();
|
||||||
|
|
||||||
|
/* Allow progress, if enabled */
|
||||||
|
enable_progress(1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In case of emergency.
|
* In case of emergency.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+11
-9
@@ -39,13 +39,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utmp-api.h"
|
#include "utmp-api.h"
|
||||||
|
|
||||||
typedef enum {
|
static pstyle_t progress_onoff = PROGRESS_DEFAULT;
|
||||||
PROGRESS_SILENT,
|
|
||||||
PROGRESS_CLASSIC,
|
|
||||||
PROGRESS_MODERN,
|
|
||||||
} pstyle_t;
|
|
||||||
|
|
||||||
#define PROGRESS_DEFAULT PROGRESS_MODERN
|
|
||||||
static pstyle_t progress_style = PROGRESS_DEFAULT;
|
static pstyle_t progress_style = PROGRESS_DEFAULT;
|
||||||
|
|
||||||
#ifndef HOSTNAME_PATH
|
#ifndef HOSTNAME_PATH
|
||||||
@@ -189,14 +183,22 @@ char *strip_line(char *line)
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_progress(int onoff)
|
void enable_progress(int onoff)
|
||||||
{
|
{
|
||||||
|
if (debug)
|
||||||
|
return;
|
||||||
|
|
||||||
if (onoff)
|
if (onoff)
|
||||||
progress_style = PROGRESS_DEFAULT;
|
progress_style = progress_onoff;
|
||||||
else
|
else
|
||||||
progress_style = PROGRESS_SILENT;
|
progress_style = PROGRESS_SILENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show_progress(pstyle_t style)
|
||||||
|
{
|
||||||
|
progress_onoff = style;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return screen length of string, not counting escape chars, and
|
* Return screen length of string, not counting escape chars, and
|
||||||
* accounting for unicode characters as only one screen byte wide
|
* accounting for unicode characters as only one screen byte wide
|
||||||
|
|||||||
+11
-1
@@ -34,6 +34,14 @@
|
|||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
#define PROGRESS_DEFAULT PROGRESS_MODERN
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PROGRESS_SILENT,
|
||||||
|
PROGRESS_CLASSIC,
|
||||||
|
PROGRESS_MODERN,
|
||||||
|
} pstyle_t;
|
||||||
|
|
||||||
#ifndef HAVE_GETFSENT
|
#ifndef HAVE_GETFSENT
|
||||||
struct fstab {
|
struct fstab {
|
||||||
char *fs_spec; /* block device name */
|
char *fs_spec; /* block device name */
|
||||||
@@ -55,7 +63,9 @@ void console_init (void);
|
|||||||
ssize_t cprintf (const char *fmt, ...);
|
ssize_t cprintf (const char *fmt, ...);
|
||||||
|
|
||||||
char *strip_line (char *line);
|
char *strip_line (char *line);
|
||||||
void show_progress (int onoff);
|
|
||||||
|
void enable_progress (int onoff);
|
||||||
|
void show_progress (pstyle_t style);
|
||||||
|
|
||||||
int getty (char *tty, speed_t speed, char *term, char *user);
|
int getty (char *tty, speed_t speed, char *term, char *user);
|
||||||
int sh (char *tty);
|
int sh (char *tty);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void log_exit(void)
|
|||||||
else
|
else
|
||||||
screen_init();
|
screen_init();
|
||||||
|
|
||||||
show_progress(1);
|
enable_progress(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_open(void)
|
void log_open(void)
|
||||||
@@ -85,6 +85,7 @@ void log_debug(void)
|
|||||||
screen_init();
|
screen_init();
|
||||||
}
|
}
|
||||||
log_open();
|
log_open();
|
||||||
|
enable_progress(1);
|
||||||
|
|
||||||
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
|
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user