#!/bin/sh

# boot.local is run once only during the startup process after 
# nfcms.  If called under :boot: under inittab it will run in 
# parallel with the other boot processes.  If called under 
# :bootwait: it will be run and finished before calling other 
# boot processes.   A danger with :bootwait: is that if it fails
# the system will not continue to boot.

# The intent here is to run some housekeeping items at boot.  
# Our initial usage of this is to import a separate bash script
# to be executed for the initial boot after a firmware upgrade.
# It would operate silimarly to the initialize and migrate scripts,
# but we are unable to use those two since drives are not yet mounted.
# This a good place to put items that need drive access since they
# will be mounted by this time (typically /media/hd0).


# path to file to run once and then delete
POST_MIG_FILE=/etc/sysconfig/boot_migrate

# source it, run it and delete it.  It should be self logging.
if [ -e $POST_MIG_FILE ]; then
   . $POST_MIG_FILE
   rm -f $POST_MIG_FILE
   logger -t "[MIGRATE]" "Post Migrate Completed."
fi

# fix old env.global TZ variable, this was moved from /etc/init.d/rcservices
#source /etc/env.global
#unset TZ
#tzset.sh

# Here we can run some general utilities such as inserting microcode


# force the CF card to be NOOP I/O scheduler.
# See http://en.wikipedia.org/wiki/Noop_scheduler
if [ -e /sys/block/hde/queue/scheduler ]; then  # skip if net-booting
   echo "noop" > /sys/block/hde/queue/scheduler
fi


# lets write out serial to a defined file:
# this allows us to use #include in apache to display our serial.
if [ ! -e /etc/SERIAL ];then
  /sbin/ifconfig eth0 | /bin/grep -o "..:..:..:..:..:.." | /usr/bin/tr -d : | /usr/bin/cut -c 7-12 > /etc/SERIAL
fi