version 1.1, 2011/07/21 14:06:05
|
version 1.1.2.1, 2011/07/21 14:06:05
|
Line 0
|
Line 1
|
|
#!/bin/sh |
|
# |
|
# ELWIX install script for device |
|
# |
|
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org> |
|
# by Michael Pounov <misho@elwix.org> |
|
# |
|
# $Id$ |
|
# |
|
|
|
[ -r ./config/rc.elwix ] && . ./config/rc.elwix |
|
if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then |
|
echo |
|
echo "ELWIX project is not configured !?!" |
|
echo |
|
exit 1 |
|
fi |
|
|
|
if [ "${USER}" != "root" ]; then |
|
echo |
|
echo "ELWIX project is not configured - FS must build under root !?!" |
|
echo |
|
exit 1 |
|
fi |
|
|
|
MNT="/mnt" |
|
|
|
initdev() |
|
{ |
|
echo -n "+++ Init device $1 label ... " |
|
if disklabel -w $1; then |
|
echo "OK" |
|
else |
|
echo "Failed!" |
|
exit 3 |
|
fi |
|
|
|
if newfs -b8192 -f1024 -m0 -Lelwix ${1}a; then |
|
echo "+++ Formatting ... OK" |
|
else |
|
echo "+++ Formatting ... Failed!" |
|
exit 3 |
|
fi |
|
} |
|
|
|
mountdev() |
|
{ |
|
echo -n "+++ Mount device $1 to $MNT ... " |
|
if mount ${1}a $MNT; then |
|
echo "OK" |
|
else |
|
echo "Failed!" |
|
exit 4 |
|
fi |
|
} |
|
|
|
umountdev() |
|
{ |
|
echo -n "+++ Unmount $MNT ... " |
|
if umount $MNT; then |
|
echo "OK" |
|
else |
|
echo "Failed!" |
|
exit 4 |
|
fi |
|
} |
|
|
|
enablejfs() |
|
{ |
|
if tunefs -n enable -j enable ${1}a; then |
|
echo "Start FS Journaling ... OK" |
|
else |
|
echo "Start FS Journaling ... Failed!" |
|
exit 6 |
|
fi |
|
} |
|
|
|
boot2dev() |
|
{ |
|
echo -n "+++ Installboot to device $1 ... " |
|
if disklabel -B $1; then |
|
echo "OK" |
|
else |
|
echo "Failed!" |
|
exit 7 |
|
fi |
|
} |
|
|
|
install2() |
|
{ |
|
echo -n "+++ Install ELWIX OS from $1 into $MNT ... " |
|
if tar -xzvpf $1 -C $MNT; then |
|
echo "OK" |
|
else |
|
echo "Failed!" |
|
exit 5 |
|
fi |
|
} |
|
|
|
### main() |
|
|
|
if [ -z $1 ]; then |
|
echo |
|
echo "Error:: not specified raw disk drive for install ELWIX OS ..." |
|
echo " Syntax: (raw disk like: /dev/da1 or da1)" |
|
echo |
|
echo " If you wish, may apply secondary optional file name argument for other firmware" |
|
echo |
|
exit 2 |
|
fi |
|
|
|
if [ ! -r $2 ]; then |
|
echo |
|
echo "Error:: '$2' ELWIX OS file not found!" |
|
echo |
|
exit 2 |
|
else |
|
DEV=$(echo $1 | awk '{ |
|
if (!($1 ~ /^\//)) |
|
printf("/dev/%s", $1); |
|
else |
|
printf("%s", $1); |
|
}') |
|
if ! [ -c $DEV ]; then |
|
echo "Wrong device $DEV !!!" |
|
exit 1 |
|
fi |
|
fi |
|
|
|
initdev $DEV |
|
|
|
mountdev $DEV |
|
install2 ${2:-"${REL}/${OS}"} |
|
umountdev |
|
|
|
#enablejfs $DEV |
|
boot2dev $DEV |
|
|
|
echo "ELWIX OS install complete." |