From 0a1a600d49d1292be82a47cfde6f0355996478f0 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Fri, 9 Feb 2018 23:26:58 +0000 Subject: [PATCH] exec cli strings as commands on init --- getting-started.md | 10 +++++++++- rootfs_overlay/etc/init.d/S98 | 5 +++-- rootfs_overlay/eval.sh | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 rootfs_overlay/eval.sh diff --git a/getting-started.md b/getting-started.md index 7dd6387..082b0b7 100644 --- a/getting-started.md +++ b/getting-started.md @@ -132,7 +132,15 @@ When debugging a module, it becomes tedious to wait for build and re-type: every time. -Instead, you can add your test commands to: +Instead, you can either run them from a minimal init: + + ./run -e 'init=/eval.sh - lkmc_eval="insmod /hello.ko;/poweroff.out"' -n + +or run them at the end of the BusyBox init, which does things like setting up networking: + + ./run -e '- lkmc_eval="insmod /hello.ko;wget -S google.com;poweroff.out;"' + +or add them to a new `init.d` entry: cp rootfs_overlay/etc/init.d/S98 rootfs_overlay/etc/init.d/S99 vim S99 diff --git a/rootfs_overlay/etc/init.d/S98 b/rootfs_overlay/etc/init.d/S98 index 685fc2e..0fb807b 100755 --- a/rootfs_overlay/etc/init.d/S98 +++ b/rootfs_overlay/etc/init.d/S98 @@ -1,6 +1,7 @@ #!/bin/sh -# For temparary test commands, first copy this file to to -# S99 which is already gitignored. echo 'S98' # insmod /hello.ko +if [ -n "$lkmc_eval" ]; then + eval "$lkmc_eval" +fi exit 0 diff --git a/rootfs_overlay/eval.sh b/rootfs_overlay/eval.sh new file mode 100755 index 0000000..997b51b --- /dev/null +++ b/rootfs_overlay/eval.sh @@ -0,0 +1,2 @@ +#!/bin/sh +eval "$lkmc_eval"