From 47f525c969eff1e7b4ce01af31a4cbcaf05664d8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 5 Oct 2011 13:38:53 -0300 Subject: Adding more actions to bootless subcommand --- share/hydra/bootless | 252 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 151 insertions(+), 101 deletions(-) diff --git a/share/hydra/bootless b/share/hydra/bootless index bad5f50..c2621e5 100755 --- a/share/hydra/bootless +++ b/share/hydra/bootless @@ -14,26 +14,34 @@ # License along with this program. If not, see # . -# hydra project bootless init refspec -# hydra project bootless git update -# hydra project bootless git commit -# hydra project bootless make /dev/sdb1 - # Load. source $APP_BASE/lib/hydra/functions || exit 1 hydra_config_load -# parameter verification -if [ $# -gt 1 ]; then - echo "Usage: `basename $0` [target]" - exit 1 -elif [ -z "$HYDRA_FOLDER" ]; then - echo "Parameter HYDRA_FOLDER not configured." - exit 1 -fi - -# script description -cat < /dev/null ) -if [ $? -ne 0 ]; then - echo "Error: '${gitdir}' is not a git repository." - exit 1 -fi - -if [ -z "$1" ]; then - echo -n "Target device: " - read device -else - device=$1 -fi - -# target device consistency check -if [ ! -b ${device} ]; then - echo "Error: device \"${device}\" not found." - exit 1 -fi - -if [ "`mount | grep ${device}`" != "" ]; then - echo "Error: device \"${device}\" is mounted." -fi - -# verifies that user is sure about that -cat < /dev/null ) + if [ $? -ne 0 ]; then + echo "Error: '${BOOTLESS_DIR}' is not a git repository." + exit 1 + fi + + if [ -z "$1" ]; then + echo -n "Target device: " + read device + else + device=$1 + fi + + # Target device consistency check + if [ ! -b ${device} ]; then + echo "Error: device \"${device}\" not found." + exit 1 + fi + + if [ "`mount | grep ${device}`" != "" ]; then + echo "Error: device \"${device}\" is mounted." + fi + + # Issue a warning + cat < [arguments]" exit 1 -fi +} -# formatacao e montagem -sudo mke2fs ${device} -if [ $? != 0 ]; then - echo "Error: mke2fs failed in \"${device}\" (errno: $?)." - exit 1; -fi -sudo tune2fs -c 0 -i 0 ${device} -if [ $? != 0 ]; then - echo "Error: tune2fs failed in \"${device}\" (errno: $?)." - exit 1; -fi -tmpdir=`mktemp -d` -sudo mount ${device} ${tmpdir} -if [ $? != 0 ]; then - echo "Error: failed to mount \"${device}\" filesystem in \"${tmpdir}\" (errno: $?)." - exit 1; -fi - -# data copy -sudo git clone --depth=1 ${gitdir} ${tmpdir}/boot -if [ $? != 0 ]; then - echo "Error: failed to clone repository \"${gitdir}\" in \"${tmpdir}\" (errno: $?)." - exit 1; +# Parameter verification +if [ -z "$1" ]; then + hydra_bootless_usage +elif [ -z "$HYDRA_FOLDER" ]; then + echo "Parameter HYDRA_FOLDER not configured." + exit 1 +elif [ "$1" == "make" ]; then + shift + hydra_bootless_make $* +elif [ "$1" == "init" ]; then + shift + hydra_bootless_init $* +elif [ "$1" == "git" ]; then + shift + hydra_bootless_git $* +else + hydra_bootless_usage fi - -# grub legacy -#devicemap=`mktemp` -#grub-mkdevicemap --no-floppy --device-map=${devicemap} -#usbdevice=`echo ${device} | sed -e s/[0-9]\$//` -#grubroot=`grep "${usbdevice}" ${devicemap} | cut -f1` -#grubdevice=`echo ${grubroot} | sed -e s/\)/,0\)/` -#echo "root ${grubdevice} -#setup ${grubroot} -#quit" | grub --device-map=${devicemap} --batch - -# grub 2 -usbdevice=`echo ${device} | sed -e s/[0-9]\$//` -sudo grub-install --root-directory=${tmpdir} ${usbdevice} --force - -# finalize -#rm -f ${devicemap} -sudo umount ${tmpdir} -sudo rm -rf ${tmpdir} -- cgit v1.2.3