aboutsummaryrefslogtreecommitdiff
path: root/rc.lib
diff options
context:
space:
mode:
Diffstat (limited to 'rc.lib')
-rw-r--r--rc.lib19
1 files changed, 16 insertions, 3 deletions
diff --git a/rc.lib b/rc.lib
index 7d5068d..57f66d4 100644
--- a/rc.lib
+++ b/rc.lib
@@ -1,10 +1,22 @@
# rc.lib -- common functions for rc.boot and rc.shutdown
-# shellcheck disable=1090
+# shellcheck disable=1090,2034
export PATH=$PATH:/usr/local/bin:/usr/bin
-out() { printf '\033[1;36m-> \033[39m%s\033[m\n' "$@" ;}
-err() { printf '\033[1;31m!> \033[39m%s\033[m\n' "$@" ;}
+log_file="${log_dir:=/var/log/init}/$(date +%Y%m%d-%H%M)-${0##*.}"
+
+log() {
+ [ "$log" = 1 ] || {
+ cat
+ return 0
+ }
+ mkdir -p "$log_dir"
+ tee -a "$log_file"
+}
+
+
+out() { printf '\033[1;36m-> \033[39m%s\033[m\n' "$@" | log ;}
+err() { printf '\033[1;31m!> \033[39m%s\033[m\n' "$@" | log ;}
shell() {
err "Dropping to shell, type 'exit' to continue the boot process."
@@ -58,6 +70,7 @@ parse_cmdline() {
ro) RO=1 ;;
forcefsck) FORCEFSCK="-f" ;;
fastboot) FASTBOOT=1 ;;
+ log) log=1 ;;
esac
done
}