#!/bin/sh
#
# Anthony DiSante's musicbox startup script
# http://nodivisions.com/tech/systems/musicbox/
# 20030910-1648pm

export PATH=$PATH:/sbin:/usr/sbin

# My CMOS clock is being dumb, or else I just can't figure it out, but
# in any case this makes it display the correct time through Linux.
clock --hctosys &

# drivers for my old setup (Creative Audigy in car system; fm801 in the
# test system)
#modprobe emu10k1
#modprobe snd-fm801
#modprobe snd-pcm-oss


# Optional: if you have a USB keyboard but didn't compile USB
# support into your kernel, then uncomment these lines:
#modprobe -a usb-ohci &
#modprobe -a keybdev &
#modprobe -a hid &


# Note: there are 3 sets of "new" drivers here, and all have crackley,
# distorted sound on the ac97 chip on my EPIA ME6000 motherboard, unless
# you turn the volume down to ~65%.  When you do that, they all seem to
# be of similar good quality.  I have the music.pl script currently 
# setting the volume to that level automatically.

# new ones for ac97
#modprobe snd-via82xx
#modprobe snd-pcm-oss
#modprobe snd-mixer-oss

# another new one for ac97
modprobe via82cxxx_audio

# new OSS one (not free):
#/tmp/oss/soundon


# Give us a nice font for when we're debugging the system.
setfont -v gr737b-8x11.psfu.gz &


mount /proc /proc -t proc

# Our playlist and other state files are going to be stored at /tmp.
# Mount it with write-caching turned off (sync turned on).
mount -o rw,sync /dev/hda3 /tmp

# The music collection: mount it read-only.
mount -o ro /dev/hda4 /mp3s

# Make a ramdisk from which to play the mp3s, so they never skip.
mke2fs -m 0 /dev/ram0 30000
mount -o sync /dev/ram0 /tmp/ramdisk0


# load the lmsensors modules so we can detect CPU temperature, etc.
modprobe i2c-viapro
modprobe i2c-isa
modprobe eeprom
modprobe vt1211
/usr/local/bin/sensors -s

# The initial call to the sensors program takes about 5 seconds
# (subsequent calls are ~instant), so we'll call it once here to 
# avoid getting that delay after the music script starts.
sensors -f >/dev/null &


# copy mpg321 to the ramdisk, so it executes faster.
cp `which mpg321` /tmp/ramdisk0/mpg321
chmod a+x /tmp/ramdisk0/mpg321

# copy the lcdwriter program to the ramdisk, so it executes faster.
cp /lcd /tmp/ramdisk0/
chmod a+x /tmp/ramdisk0/lcd


# Initialize the LCD screen.
/tmp/ramdisk0/lcd --init


# Run the music script.
/music.pl --noramdisk


