aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-12-31 18:20:51 -0200
committerSilvio Rhatto <rhatto@riseup.net>2012-12-31 18:20:51 -0200
commitcc76ba613040bb74b275bd755b4e7fc0d2e4bc5c (patch)
tree36f6c99e131220076fc0b35560e7298af3b02a8b /share
parent60c06d3736752ff5e17f173751ed791d73658ac4 (diff)
downloadhydra-cc76ba613040bb74b275bd755b4e7fc0d2e4bc5c.tar.gz
hydra-cc76ba613040bb74b275bd755b4e7fc0d2e4bc5c.tar.bz2
Adding update subcommand and --rsync option at bootless
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/bootless54
1 files changed, 50 insertions, 4 deletions
diff --git a/share/hydra/bootless b/share/hydra/bootless
index 19400d3..86fd928 100755
--- a/share/hydra/bootless
+++ b/share/hydra/bootless
@@ -135,10 +135,14 @@ EOF
fi
# Copy data
- $sudo git clone --depth=1 ${BOOTLESS_DIR} ${tmpdir}/boot
- if [ $? != 0 ]; then
- echo "Error: failed to clone repository \"${BOOTLESS_DIR}\" in \"${tmpdir}\" (errno: $?)."
- exit 1
+ if [ "$2" == "--rsync" ]; then
+ $sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
+ else
+ $sudo git clone --depth=1 ${BOOTLESS_DIR} ${tmpdir}/boot
+ if [ $? != 0 ]; then
+ echo "Error: failed to clone repository \"${BOOTLESS_DIR}\" in \"${tmpdir}\" (errno: $?)."
+ exit 1
+ fi
fi
# Grub legacy
@@ -160,6 +164,45 @@ EOF
$sudo rm -rf ${tmpdir}
}
+# Update a boot device
+function hydra_bootless_update {
+ # Set folder
+ hydra_bootless_folder
+
+ # Set sudo config
+ local sudo
+ if [ "`whoami`" != 'root' ]; then
+ sudo="sudo"
+ fi
+
+ # Target device consistency check
+ if [ ! -b ${device} ]; then
+ echo "Error: device \"${device}\" not found."
+ exit 1
+ elif [ ! -d "${tmpdir}/boot" ]; then
+ echo "Error: bootless repository not found at ${device}."
+ 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
+
+ # Copy data
+ if [ -d "${tmpdir}/boot/.git" ]; then
+ ( cd ${tmpdir}/boot && $sudo git pull origin master )
+ else
+ $sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
+ fi
+
+ # Finalize
+ $sudo umount ${tmpdir}
+ $sudo rm -rf ${tmpdir}
+}
+
# Repository initiator
function hydra_bootless_init {
mkdir -p $HYDRA_FOLDER
@@ -262,6 +305,9 @@ elif [ "$1" == "make" ]; then
elif [ "$1" == "init" ]; then
shift
hydra_bootless_init $*
+elif [ "$1" == "update" ]; then
+ shift
+ hydra_bootless_update $*
elif [ "$1" == "git" ]; then
shift
hydra_bootless_git $*