#!/bin/sh # # ELWIX install script for device # # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # # $Id: install2dev.sh,v 1.3 2013/08/05 13:10:16 misho Exp $ # [ -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 - install 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 -b ${WORLD}/boot/boot -m ${TARGET} ${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 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 if [ -z "$2" -o ! -r "$2" ]; then echo echo "Error:: ELWIX OS tar file '$2' not found!" echo exit 2 fi initdev $DEV mountdev $DEV install2 ${2:-"${REL}/${OS}"} umountdev #enablejfs $DEV boot2dev $DEV echo "ELWIX OS install complete."