Hi,
I occasionally want to run some commands (or a script) before the system boots. I've made a small patch to
tc-config which will execute the file
/opt/preboot.sh before "Booting Core".
Here's the patch file:
https://gist.github.com/aw/346c56912abd744803d054a9df04662fdiff --git a/etc/init.d/tc-config b/etc/init.d/tc-config
index f6002dd..c44876c 100755
--- a/etc/init.d/tc-config
+++ b/etc/init.d/tc-config
@@ -25,6 +25,8 @@ addUser(){
# Main
+[ -f "/opt/preboot.sh" ] && /opt/preboot.sh
+
clear
echo "${GREEN}Booting ${YELLOW}Core $VERSION ${NORMAL}"
echo "${GREEN}Running Linux Kernel ${YELLOW}$KERNEL${GREEN}.${NORMAL}"
Here's an example use-case:
On PiCore, if the system doesn't have an RTC, the year always resets/begins at 1970. To fix that, I've introduced a boot option called
builddate which sets the system date very early in the boot process, based on a UNIX timestamp
# example /opt/preboot.sh
#
# builddate from /proc/cmdline = 1463499605
. /etc/init.d/tc-functions
builddate=$(getbootparam "builddate")
if [ ${builddate-} ]; then
[ "$builddate" -lt `/bin/date +%s` ] || /bin/date +%s -s @${builddate}
fi
Would it be possible to patch the official
tc-config to allow us to add our own preboot scripts? I'm sure others have encountered situations requiring certain actions before TinyCore starts booting.
Thanks!