From 38a2e3f0ce51f335c63bf77646a827e216fc3025 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Mon, 13 Jan 2020 11:37:16 +0300 Subject: allow user hooks and make it more portable --- rc.lib | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rc.lib (limited to 'rc.lib') diff --git a/rc.lib b/rc.lib new file mode 100644 index 0000000..c7c8f84 --- /dev/null +++ b/rc.lib @@ -0,0 +1,29 @@ +# +# rc.lib +# + +# vim:filetype=sh +# shellcheck disable=1090 + +# Functions for rc.boot and rc.shutdown + +out() { printf "\033[1;36m->\033[0;00m\033[1m$1\033[0;00m\n" ;} +error() { printf "\033[1;31m-> ERROR: \033[0;00m\033[1m$1\033[0;00m\n" ;} +welcome() { printf '\033[1;36m->\033[m\033[1m Welcome to\033[35m Carbs Linux\033[m\033[1m!\n' ;} + +mnt() { + mountpoint -q "$1" || { + dir=$1 + shift + mount "$@" "$dir" + } +} + +emergency_shell() { + error "Cannot continue init due to errors above, starting emergency shell" + error "When ready, type 'exit' to continue the boot." + + /bin/sh -l +} + +run_hooks() { for file in "$@" ; do [ -f "$file" ] && . "$file"; done ;} -- cgit v1.2.3