[ previous ] [ next ] [ threads ]
 
 From:  Joey Morin <jmorin at icomm dot ca>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  RE: [m0n0wall] console on serial for generic pc
 Date:  Wed, 30 Jun 2004 13:20:10 -0400 (EDT)
This one time, at band camp, David Kitchens said:

> I hear you there! I have a Sharp Zaurus handheld which runs Linux and it
> even has a keyboard! To be able to use it with a standard pc would be
> wonderful! Manuel... !!!! Please???  :)
>
> Dave
>
> > I know that would be tremendously helpful for me, if the generic PC
> > image came built with support for the console on com1,9600,8,n,1 with
> > 3 wire serial console support. I would much rather attach a terminal,
> > or a serial terminal server, to my monowalls rather than a pc keyboard
> > and mouse.

it already has support for it.  you must configure it, though.  if you
have a linux box, use the attached script to create a custom m0n0wall
image.  what you need to do is add a line to loader.rc file (found in
/boot on the boot fs image)
	set console=comconsole

then install that image on your m0n0 box.

if you have some other *nix, you can easily modify the script.

i realise that it might be nice to be able to configure the console from,
say, the console!  or the webgui.  but there is usually a need to do this
only once.

truthfully, there is a way of configuring it from the webgui, but it's not
really any easier.  however, if you don't have a *nix box, it's probably
the only way.  it requires unmounting /cf, remounting it read/write, then
issuing a few commands in exec.php

	umount /cf
	mount /dev/ad0a /cf     # <-- or whatever your boot device is
	cp /cf/boot/loader.rc /cf/boot/loader.rc.temp
	echo "set console=comconsole" > /cf/boot/loader.rc
	cat /cf/boot/loader.rc.temp >> /cf/boot/loader.rc
	rm /cf/boot/loader.rc.temp
	sync                    # <-- i'm paranoid    (a reboot should
	umount /cf              # <-- really paranoid  do these anyway)

and then reboot.  the changes will be permananent.  if you need to go back
to vga/keyboard console, you can perform similar magic in exec.php, only
you'll have to re-create loader.rc one line at a time using echo commands.
there is no shell, no editor, no grep in m0n0.

jj
#!/bin/sh -

[ -e $1 ] || ! echo ERROR: \ file does not exist or no file specified || ! echo \ \ \ \ \ \ \ \ Must
specify an existing regular file || exit

shellcmd=/bin/bash

tmpdir=/tmp/m0n0_dev
mntdir1=$tmpdir/img
mntdir2=$tmpdir/mfs
zerofn=.zero.zero.bin

mkdir --verbose $tmpdir/
mkdir --verbose $mntdir1/
mkdir --verbose $mntdir2/

echo Uncompressing $1 ...
gunzip -v < $1 > $tmpdir/$1.bin
echo Mounting ad0a ...
mount -v -o loop -t ufs -o ufstype=44bsd $tmpdir/$1.bin $mntdir1

echo Uncompressing mfsroot.gz ...
gunzip -v < $mntdir1/mfsroot.gz > $tmpdir/mfsroot
echo Mounting mfsroot ...
mount -v -o loop -t ufs -o ufstype=44bsd $tmpdir/mfsroot $mntdir2
echo
echo Dropping into m0n0wall root filesystem, $mntdir2/
echo /dev/ad0a is $mntdir1/
echo Go crazy!  Type exit when done, and a new image will be built.
pushd $mntdir2

$shellcmd -

popd
echo Zeroing out unused space in root fs ...
dd bs=512 < /dev/zero > $mntdir2/$zerofn
rm -v $mntdir2/$zerofn
echo Unmounting mfsroot ...
umount -v $mntdir2
echo Compressing mfsroot ...
gzip -9v $tmpdir/mfsroot
echo Replacing mfsroot ...
mv -v $tmpdir/mfsroot.gz $mntdir1/
echo Zeroing out unused space in boot fs ...
dd bs=512 < /dev/zero > $mntdir1/$zerofn
rm -v $mntdir1/$zerofn
echo Unmounting ad0a ...
umount -v $mntdir1
echo Compressing  new image ...
gzip -9v < $tmpdir/$1.bin > $1.new
echo Cleaning up ...
rm -r -f -v $tmpdir/

echo
echo Built $1.new