if (config_get()->lang)
setlocale(LC_ALL, config_get()->lang);
+ if (config_get()->debug)
+ pb_log_set_debug(true);
+
system_info_init(server);
handler = device_handler_init(server, waitset, opts.dry_run == opt_yes);
"petitboot,network",
"petitboot,timeout",
"petitboot,bootdev",
+ "petitboot,debug?",
NULL,
};
populate_network_config(platform, config);
populate_bootdev_config(platform, config);
+
+ if (!config->debug) {
+ val = get_param(platform, "petitboot,debug?");
+ config->debug = val && !strcmp(val, "true");
+ }
}
static char *iface_config_str(void *ctx, struct interface_config *config)
+#define _GNU_SOURCE
+
+#include <fcntl.h>
#include <string.h>
#include <log/log.h>
+#include <file/file.h>
#include <types/types.h>
#include <talloc/talloc.h>
static struct platform *platform;
static struct config *config;
+static const char *kernel_cmdline_debug = "petitboot.debug";
+
static const char *device_type_name(enum device_type type)
{
switch (type) {
pb_log(" language: %s\n", config->lang ?: "");
}
+static bool config_debug_on_cmdline(void)
+{
+ char buf[600];
+ int rc, fd;
+
+ fd = open("/proc/cmdline", O_RDONLY);
+ if (fd < 0)
+ return false;
+
+ rc = read(fd, buf, sizeof(buf));
+ close(fd);
+
+ if (rc <= 0)
+ return false;
+
+ return memmem(buf, rc, kernel_cmdline_debug,
+ strlen(kernel_cmdline_debug)) != NULL;
+}
+
void config_set_defaults(struct config *config)
{
config->autoboot_enabled = true;
config->boot_priorities[0].priority = 2;
config->boot_priorities[1].type = DEVICE_TYPE_DISK;
config->boot_priorities[1].priority = 1;
+
+ config->debug = config_debug_on_cmdline();
}
int platform_init(void *ctx)
struct config {
bool autoboot_enabled;
unsigned int autoboot_timeout_sec;
- bool safe_mode;
struct network_config network;
struct boot_priority *boot_priorities;
unsigned int n_boot_priorities;
char *boot_device;
char *lang;
+
+ /* not user-settable */
+ bool safe_mode;
+ bool debug;
};
#endif /* _TYPES_H */
#
dist_sbin_SCRIPTS += utils/pb-udhcpc
-dist_pkglibexec_SCRIPTS = utils/pb-console utils/pb-sysinfo
+dist_pkglibexec_SCRIPTS = utils/pb-console
sbin_PROGRAMS += utils/pb-event utils/pb-config
utils_pb_config_LDADD = $(top_builddir)/lib/libpbcore.la \
config->autoboot_timeout_sec);
print_one_config(ctx, var, "safe-mode", "%s",
config->safe_mode ? "enabled" : "disabled");
+ print_one_config(ctx, var, "debug", "%s",
+ config->debug ? "enabled" : "disabled");
}
int main(int argc, char **argv)
getty=/sbin/getty
use_getty=0
detach=0
+pb_config=pb-config
usage() {
cat >&2 <<EOF
esac
verbose_opt=
-sysinfo_bin=$(dirname $0)/pb-sysinfo
-if [ -x $sysinfo_bin ] && $sysinfo_bin --debug-enabled
+if $pb_config debug | grep -q enabled
then
verbose_opt=--verbose
fi
+++ /dev/null
-#!/bin/sh
-
-case "$1" in
-'--debug-enabled')
- exec >/dev/null 2>&1
- nvram --print-config=petitboot,debug? | grep -q true && exit 0
- grep -Fq petitboot.debug /proc/cmdline && exit 0
- exit 1
- ;;
-esac