Normally, TinyCoreLinux has a script called /opt/bootlocal.sh which is used for custom setup. I like the convenience of having a group of setup scripts, one per "thing" (eg. one to setup wifi, another to setup the ssh daemon), and have them executed in alphabetical order (as with the standard linux command run-parts). This makes it easy to disable individual scripts, or change their order. Not really much easier than just editing a single script, but still I like it and it suits me.

The script logs to a datestamped logfile at /var/log/usr/boot.YYYY-MM-DD.log. The datestamp of the logfile will be wrong if your computer has no RTC (eg. with the Allwinner A10 processor). It also logs to syslog (which needs to have been enabled somewhere else - default TinyCoreLinux does not run syslog).

bootlocal.sh

Replace the normal /opt/bootlocal.sh with this:

#! /bb/ash
# Execute a bunch of setup scripts in alphabetical order.

# History:
# 2015-06-27: move to dCore
# 2013-05-19: add some start/end logging to syslog
# 2013-05-11: tidy up now that I have opt persistency working
# 2013-05-10: split out old bootlocal.sh into bootlocal.d

logger "$0: START"
echo "BEGIN $0"
#==========================================================================
# setup log dir for my custom logging

LOGDIR="/var/log/usr"
mkdir -p "$LOGDIR"
chown root:staff "$LOGDIR"
chmod g+rwx      "$LOGDIR"

# NOTE: since a10 has no RTC, we probably don't know the date yet, so date in log file name would be wrong
LOG="$LOGDIR/boot.$(date +%F).log"
echo "logfile: $LOG"

#==========================================================================
# Iterate over the validly-named scripts found in bootlocal.d
# Valid names are defined by regex in the "find" command.
echo "$(date +"%H:%M:%S"): BOOTLOCAL ITERATING..." | tee -a "$LOG"

find /opt/bootlocal.d/ -maxdepth 1 -type f -perm -0500 -regex '/opt/bootlocal\.d/[a-zA-Z0-9_-]\+' \
 | sort \
 | while read FN; do
   echo "----------------------------------------------------------"
   echo "$(date +"%H:%M:%S"): BEGIN $FN"
   "$FN" 2>&1
   echo "$(date +"%H:%M:%S"): END   $FN"
done | tee -a "$LOG"

echo "----------------------------------------------------------"

echo "$(date +"%H:%M:%S"): END $0" | tee -a "$LOG"
logger "$0: END"
#==========================================================================
#=== EOF ==================================================================
#==========================================================================

bootlocal.d

Create a directory /opt/bootlocal.d and put scripts there (they need to be executable, as well). The validly-named scripts will be executed in alphabetical order. eg.

tc@box:~$ ls /opt/bootlocal.d
20_wifi
30_internet_gateway
30_ssh
50_gpsd.DISABLED
50_tweak
90_cron
99_cpu_governor

NOTE: the script 50_gpsd.DISABLED is an example of a disabled script which will not be run. It has been disabled by giving it an invalid name (a "." is not valid, as per the regex in the "find" command) - this makes it easy to disable scripts.

Example scripts

eg. /opt/bootlocal.d/50_tweak:

#! /bin/sh
# Last modified: 2013-05-17

#==========================================================================
SELF="${0##*/}"

echo "$SELF: creating /tce symlink, for convenience"
TCE=/etc/sysconfig/tcedir/
ln -s "$TCE" /tce

#==========================================================================

eg. /opt/bootlocal.d/99_cpu_governor:

#! /bin/sh

# 2013-05-20: first version

SELF=${0##*/}

#==========================================================================
# Note: the defaults below are for Mini-X and TinyCoreLinux 4.7.7
#
# Default option set by bootsync.sh is "performance", which pins the clock
# at 1008000
# echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo "10080000"    > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# echo    "60000"    > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

# OnDemand changes clock according to load, but latency can be high.
# There is more that can be tweaked - see:
# - https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt
# - http://linux-sunxi.org/Cpufreq

echo "$SELF: setting up CPU governor"
echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo   "240000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

echo "governor = $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"
echo "cpu max  = $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)"
echo "cpu now  = $(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq)"
echo "cpu min  = $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)"
#==========================================================================