aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-10-04 17:38:44 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-10-04 17:38:44 -0300
commitfd2596e637f24492385c52692c99624340a33dca (patch)
tree3ea183c2b96118226cf17ec396d8d3b41dc85058 /share
parent4793cf4fab4bb57a0cf0ec8c9718e19a728cf893 (diff)
downloadhydra-fd2596e637f24492385c52692c99624340a33dca.tar.gz
hydra-fd2596e637f24492385c52692c99624340a33dca.tar.bz2
Using target argument
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/bootless43
1 files changed, 21 insertions, 22 deletions
diff --git a/share/hydra/bootless b/share/hydra/bootless
index 751ae5c..a9ae47b 100755
--- a/share/hydra/bootless
+++ b/share/hydra/bootless
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -20,11 +20,9 @@ hydra_config_load
# parameter verification
if [ $# -gt 1 ]; then
- echo "Usage: $0"
+ echo "Usage: `basename $0` [target]"
exit 1
-fi
-
-if [ -z "$HYDRA_FOLDER" ]; then
+elif [ -z "$HYDRA_FOLDER" ]; then
echo "Parameter HYDRA_FOLDER not configured."
exit 1
fi
@@ -35,33 +33,34 @@ Bootless Install Script
=======================
This script installs a bootable copy of the bootless repository in a device
-partition. It will ask for a git repo URL and a device partition, clone the
-repository in the partition and make the device bootable.
+partition. It will ask for a device partition, clone the repository in the
+partition and make the device bootable.
Press any key to continue, or ^C to abort.
EOF
read tmp
-# asks for git repo URL
-echo -n "Git repo url (`pwd`/.git): "
-read gitdir
-if [ -z "${gitdir}" ]; then
+if [ -e "$HYDRA_FOLDER/bootless" ]; then
gitdir="$HYDRA_FOLDER/bootless"
+elif [ -e "$HYDRA_FOLDER/conf/bootless" ]; then
+ gitdir="$HYDRA_FOLDER/conf/bootless"
+else
+ echo "Please make a symlink $HYDRA_FOLDER/bootless pointing to your devel puppet modules."
+ exit 1
fi
# git repo consistency check
-git --git-dir=${gitdir} status > /dev/null
+( cd ${gitdir} && git status > /dev/null )
if [ $? -ne 0 ]; then
echo "Error: '${gitdir}' is not a git repository."
exit 1
fi
-# asks for target device
-if [ $# -lt 1 ]; then
+if [ -z "$1" ]; then
echo -n "Target device: "
read device
else
- device=$2
+ device=$1
fi
# target device consistency check
@@ -93,25 +92,25 @@ if [ "${go}" != "YES" ]; then
fi
# formatacao e montagem
-mke2fs ${device}
+sudo mke2fs ${device}
if [ $? != 0 ]; then
echo "Error: mke2fs failed in \"${device}\" (errno: $?)."
exit 1;
fi
-tune2fs -c 0 -i 0 ${device}
+sudo tune2fs -c 0 -i 0 ${device}
if [ $? != 0 ]; then
echo "Error: tune2fs failed in \"${device}\" (errno: $?)."
exit 1;
fi
tmpdir=`mktemp -d`
-mount ${device} ${tmpdir}
+sudo mount ${device} ${tmpdir}
if [ $? != 0 ]; then
echo "Error: failed to mount \"${device}\" filesystem in \"${tmpdir}\" (errno: $?)."
exit 1;
fi
# data copy
-git clone --depth=1 ${gitdir} ${tmpdir}/boot
+sudo git clone --depth=1 ${gitdir} ${tmpdir}/boot
if [ $? != 0 ]; then
echo "Error: failed to clone repository \"${gitdir}\" in \"${tmpdir}\" (errno: $?)."
exit 1;
@@ -129,9 +128,9 @@ fi
# grub 2
usbdevice=`echo ${device} | sed -e s/[0-9]\$//`
-grub-install --root-directory=${tmpdir} ${usbdevice} --force
+sudo grub-install --root-directory=${tmpdir} ${usbdevice} --force
# finalize
#rm -f ${devicemap}
-umount ${tmpdir}
-rm -rf ${tmpdir}
+sudo umount ${tmpdir}
+sudo rm -rf ${tmpdir}