mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
Cleanup and simplify boot process messages
- Remove indentation of module loading and device node creation - Clarify that we load kernel modules - Clarify that we load Finit plugins - Remove cls() - Remove verbose condition for echo() - Make banner a separate function with optional distribution banner - Add a few neat ANSI escape sequences for cls(), clreol(), delline(), etc. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -60,7 +60,6 @@ static char *build_cmd(char *cmd, char *line, int len)
|
||||
void parse_finit_conf(char *file)
|
||||
{
|
||||
FILE *fp;
|
||||
int modfirst = 1;
|
||||
char line[LINE_SIZE];
|
||||
char cmd[CMD_SIZE];
|
||||
|
||||
@@ -87,7 +86,7 @@ void parse_finit_conf(char *file)
|
||||
if (MATCH_CMD(line, "check ", x)) {
|
||||
strcpy(cmd, "/sbin/fsck -C -a ");
|
||||
build_cmd(cmd, x, CMD_SIZE);
|
||||
run_interactive(cmd, "Checking file system integrity on %s", x);
|
||||
run_interactive(cmd, "Checking file system %s", x);
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "user ", x)) {
|
||||
@@ -106,19 +105,15 @@ void parse_finit_conf(char *file)
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "module ", x)) {
|
||||
if (modfirst) {
|
||||
echo("Loading kernel modules ...");
|
||||
modfirst = 0;
|
||||
}
|
||||
strcpy(cmd, "/sbin/modprobe ");
|
||||
build_cmd(cmd, x, CMD_SIZE);
|
||||
run_interactive(cmd, " Loading module %s", x);
|
||||
run_interactive(cmd, "Loading kernel module %s", x);
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "mknod ", x)) {
|
||||
strcpy(cmd, "/bin/mknod ");
|
||||
build_cmd(cmd, x, CMD_SIZE);
|
||||
run_interactive(cmd, " Creating device node %s", x);
|
||||
run_interactive(cmd, "Creating device node %s", x);
|
||||
continue;
|
||||
}
|
||||
if (MATCH_CMD(line, "network ", x)) {
|
||||
|
||||
@@ -141,10 +141,11 @@ static int run_loop(void)
|
||||
|
||||
static void banner(void)
|
||||
{
|
||||
delline();
|
||||
#ifdef BANNER
|
||||
echo(BANNER);
|
||||
#else
|
||||
echo("finit " VERSION " (built " __DATE__ " " __TIME__ " by " WHOAMI ")");
|
||||
echo("Finit version " VERSION " (" WHOAMI ") " __DATE__ " " __TIME__);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -153,6 +154,11 @@ int main(int argc, char* argv[])
|
||||
if (getpid() != 1)
|
||||
return client(argc, argv);
|
||||
|
||||
/*
|
||||
* Hello world.
|
||||
*/
|
||||
banner();
|
||||
|
||||
/*
|
||||
* Initial setup of signals, ignore all until we're up.
|
||||
*/
|
||||
@@ -177,9 +183,6 @@ int main(int argc, char* argv[])
|
||||
*/
|
||||
parse_kernel_cmdline();
|
||||
|
||||
cls();
|
||||
banner();
|
||||
|
||||
/*
|
||||
* Populate /dev and prepare for runtime events from kernel.
|
||||
*/
|
||||
@@ -199,7 +202,7 @@ int main(int argc, char* argv[])
|
||||
* all services, or service plugins won't have anything to
|
||||
* hook on to.
|
||||
*/
|
||||
print_desc("", "Loading plugins");
|
||||
print_desc("", "Loading Finit plugins");
|
||||
print_result(plugin_load_all(PLUGIN_PATH));
|
||||
|
||||
/*
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
# define CONSOLE "/dev/tty1"
|
||||
# define GETTY "/sbin/getty -8 38400 %s"
|
||||
# define REMOUNT_ROOTFS_RW
|
||||
# define RUNLEVEL 2
|
||||
# define USE_UDEV
|
||||
# define USE_MESSAGE_BUS
|
||||
#endif
|
||||
|
||||
@@ -638,14 +638,6 @@ int getgroup(char *group)
|
||||
* Other convenience functions
|
||||
*/
|
||||
|
||||
void cls(void)
|
||||
{
|
||||
static const char cls[] = "\e[2J\e[1;1H";
|
||||
|
||||
if (verbose)
|
||||
fprintf (stderr, "%s", cls);
|
||||
}
|
||||
|
||||
void chomp(char *str)
|
||||
{
|
||||
char *x;
|
||||
|
||||
@@ -56,8 +56,20 @@
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
|
||||
#endif
|
||||
/* Esc[2JEsc[1;1H Clear screen and move cursor to 1,1 (upper left) pos. */
|
||||
#define clrscr() fputs("\e[2J\e[1;1H", stderr)
|
||||
/* Esc[K Erases from the current cursor position to the end of the current line. */
|
||||
#define clreol() fputs("\e[K", stderr)
|
||||
/* Esc[2K Erases the entire current line. */
|
||||
#define delline() fputs("\e[2K", stderr)
|
||||
/* Esc[Line;ColumnH Moves the cursor to the specified position (coordinates) */
|
||||
#define gotoxy(x,y) fprintf(stderr, "\e[%d;%dH", y, x)
|
||||
/* Esc[?25l (lower case L) Hide Cursor */
|
||||
#define hidecursor() fputs("\e[?25l", stderr)
|
||||
/* Esc[?25h (lower case H) Show Cursor */
|
||||
#define showcursor() fputs("\e[?25h", stderr)
|
||||
|
||||
#define echo(fmt, args...) do { if (verbose) { fprintf(stderr, fmt "\n", ##args); } } while (0)
|
||||
#define echo(fmt, args...) do { fprintf(stderr, fmt "\n", ##args); } while (0)
|
||||
#define _d(fmt, args...) do { if (debug) { fprintf(stderr, "finit:%s:%s() - " fmt "\n", __FILE__, __func__, ##args); } } while (0)
|
||||
#define _e(fmt, args...) do { fprintf(stderr, "finit:%s:%s() - " fmt "\n", __FILE__, __func__, ##args); } while (0)
|
||||
#define _pe(fmt, args...) do { fprintf(stderr, "finit:%s:%s() - " fmt ". Error %d: %s\n", __FILE__, __func__, ##args, errno, strerror(errno)); } while (0)
|
||||
@@ -65,7 +77,7 @@
|
||||
extern int debug;
|
||||
extern int verbose;
|
||||
|
||||
int makepath (char *path);
|
||||
int makepath (char *path);
|
||||
void ifconfig (char *ifname, char *addr, char *mask, int up);
|
||||
|
||||
pid_t pidfile_read (char *pidfile);
|
||||
@@ -80,16 +92,15 @@ int procname_kill (char *name, int signo);
|
||||
void print_desc (char *action, char *desc);
|
||||
int print_result (int fail);
|
||||
int start_process (char *cmd, char *args[], int console);
|
||||
void cls (void);
|
||||
void chomp (char *str);
|
||||
void chomp (char *str);
|
||||
int getuser (char *username);
|
||||
int getgroup (char *group);
|
||||
int getgroup (char *group);
|
||||
void set_hostname (char *hostname);
|
||||
|
||||
int run (char *cmd);
|
||||
int run_interactive (char *cmd, char *fmt, ...);
|
||||
pid_t run_getty (char *cmd, int console);
|
||||
int run_parts (char *dir, char *cmd);
|
||||
int run_parts (char *dir, char *cmd);
|
||||
|
||||
#endif /* FINIT_HELPERS_H_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user