summaryrefslogtreecommitdiff
path: root/share/hydra/bootless
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydra/bootless')
-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 $*