From c846ff4798c4c48d229587297e6df8b593c60c54 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Jul 2010 00:25:41 +0200 Subject: [PATCH] main: show welcome message on boot --- src/main.c | 3 ++- src/util.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 2 ++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 99bea7591..df0da0be4 100644 --- a/src/main.c +++ b/src/main.c @@ -764,7 +764,8 @@ int main(int argc, char *argv[]) { log_debug(PACKAGE_STRING " running in %s mode.", manager_running_as_to_string(arg_running_as)); - if (arg_running_as == MANAGER_SYSTEM) { + if (arg_running_as == MANAGER_SYSTEM && !serialization) { + status_welcome(); modprobe_setup(arg_nomodules); kmod_setup(); hostname_setup(); diff --git a/src/util.c b/src/util.c index 4795dbcc6..774f061ef 100644 --- a/src/util.c +++ b/src/util.c @@ -2651,6 +2651,53 @@ finish: close_nointr_nofail(fd); } +void status_printf(const char *format, ...) { + va_list ap; + + assert(format); + + va_start(ap, format); + status_vprintf(format, ap); + va_end(ap); +} + +void status_welcome(void) { + +#if defined(TARGET_FEDORA) + char *r; + + if (read_one_line_file("/etc/system-release", &r) < 0) + return; + + truncate_nl(r); + + /* This tries to mimic the color magic the old Red Hat sysinit + * script did. */ + + if (startswith(r, "Red Hat")) + status_printf("\tWelcome to \x1B[0;31m%s\x1B[0m!\n", r); /* Red for RHEL */ + else if (startswith(r, "Fedora")) + status_printf("\tWelcome to \x1B[0;34m%s\x1B[0m!\n", r); /* Blue for Fedora */ + else + status_printf("\tWelcome to %s!\n", r); + + free(r); + +#elif defined(TARGET_SUSE) + char *r; + + if (read_one_line_file("/etc/SuSE-release", &r) < 0) + return; + + truncate_nl(r); + + status_printf("\tWelcome to \x1B[0;32m%s\x1B[0m!\n", r); /* Green for SUSE */ + free(r); +#else +#warning "You probably should add a welcome text logic here." +#endif +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", diff --git a/src/util.h b/src/util.h index 0465915f4..65a5e66ad 100644 --- a/src/util.h +++ b/src/util.h @@ -292,6 +292,8 @@ int rm_rf(const char *path, bool only_dirs, bool delete_root); cpu_set_t* cpu_set_malloc(unsigned *ncpus); void status_vprintf(const char *format, va_list ap); +void status_printf(const char *format, ...); +void status_welcome(void); const char *ioprio_class_to_string(int i); int ioprio_class_from_string(const char *s); -- 2.30.2