Print of www.smithonline.id.au on Friday 29Mar2024         Page : Console Jukebox

Console Jukebox


Some time ago we were having a few parties and found that my valuable CD collection was taking a real battering.  So I decided to convert an old Pentium 120 computer into a jukebox which stored and played mp3files on demand.  The console jukebox program was born!

The program, written in Perl, has the following features:





Now the bad news:



Program Code

This is the Perl code for the Console Jukebox.

Here's the file : jukebox_V1_5T.pl

#
# The following modules are required (get from www.cpan.org)
#

use Term::ReadKey;
use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
use Audio::Play::MPG123;

Now I don't pretend to be a professional "gun" programmer.  Experienced software types will find the style primitive, clumsy and very much like Basic programs of old.  I guess a reasonably experienced Perl programmer could acheive the same functions in half the lines.  Still, I hope the code is very readable and easy to modify for specific applications.

Of course, the source and program are made available free to anyone with absolutely no claims or warranties of performance or support.



Making your Jukebox hack proof

So by now I hope you realise that this program runs on my Jukebox PC that I put out for parties. It's a Pentium 120 with 32MB RAM, 6GB disk, and an old keyboard and monitor (no mouse is needed). It runs Redhat Linux 7.0.

To make the computer hack-proof and fool-proof, I modify the following files (I've written a simple script to do this automatically before aparty):

/etc/inittab

This file is modified to
Here's the relevant sections:
# Run gettys in standard runlevels
#1:2345:respawn:/sbin/mingetty tty1
1:2345:respawn:/usr/bin/perl /home/jukebox/jukebox
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6
# Trap CTRL-ALT-DELETEca::ctrlaltdel:/sbin/shutdown -t3 -h now

/etc/fstab

Entries for the floppy (/dev/fd0) and cd-rom (/dev/cdrom) are removed for jukebox mode.

/etc/sysconfig/init

Change PROMPT to no to disallow prompted start-up:
#PROMPT=yes
PROMPT=no

/etc/lilo.conf

Change the timeout to 0

I also stop a number of services from starting since the system won't be using samba, lp, etc.

To make it easy to change from normal mode to jukebox mode, I keep twoversions of the above files and have written two scripts:

jukebox_mode
echo ""
echo "Setting up jukebox mode (inittab, fstab, sysconfig/init, lilo.conf)"
cp /etc/inittab_jukebox /etc/inittab
cp /etc/fstab_jukebox /etc/fstab
cp /etc/sysconfig/init_jukebox /etc/sysconfig/init
cp /etc/lilo.conf_jukebox /etc/lilo.conf
lilo

mv /etc/rc.d/rc3.d/S90smb /etc/rc.d/rc3.d/_S90smb
mv /etc/rc.d/rc3.d/S90crond /etc/rc.d/rc3.d/_S90crond
mv /etc/rc.d/rc3.d/S90xfs /etc/rc.d/rc3.d/_S90xfs
mv /etc/rc.d/rc3.d/S95anacron /etc/rc.d/rc3.d/_S95anacron
mv /etc/rc.d/rc3.d/S99linuxconf /etc/rc.d/rc3.d/_S99linuxconf

echo ""
echo "Done"
echo "You now need to reboot to start dedicated jukebox mode"
echo ""

normal_mode

echo ""
echo "Setting normal devserver start-up mode (inittab, fstab, sysconfig/init, lilo)"
echo ""
cp /etc/inittab_normal /etc/inittab
cp /etc/fstab_normal /etc/fstab
cp /etc/sysconfig/init_normal /etc/sysconfig/init
cp /etc/lilo.conf_normal /etc/lilo.conf
lilo

mv /etc/rc.d/rc3.d/_S90smb /etc/rc.d/rc3.d/S90smb
mv /etc/rc.d/rc3.d/_S90crond /etc/rc.d/rc3.d/S90crond
mv /etc/rc.d/rc3.d/_S90xfs /etc/rc.d/rc3.d/S90xfs
mv /etc/rc.d/rc3.d/_S95anacron /etc/rc.d/rc3.d/S95anacron
mv /etc/rc.d/rc3.d/_S99linuxconf /etc/rc.d/rc3.d/S99linuxconf

echo "Done"
echo "You now need to reboot to start in normal mode"
echo ""

Once you're in jukebox mode, the only way to get back to normal_mode isto connect the box to a network and telnet into it as root, then run normal_mode.



Print of www.smithonline.id.au on Friday 29Mar2024