mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 14:16:31 +00:00
writeimage.sh: cosmetic changes
This commit is contained in:
parent
cf35f56719
commit
3a6e99b664
@ -1,5 +1,6 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 [options...]" 1>&2
|
||||
echo ""
|
||||
@ -16,40 +17,33 @@ function msg() {
|
||||
echo "$(date) $1"
|
||||
}
|
||||
|
||||
# use this function to unmount regardless of MAC OS or not
|
||||
function smartUnmount() {
|
||||
function smart_unmount() {
|
||||
msg "Unmounting $1"
|
||||
|
||||
# if MAC OS
|
||||
if [ `uname` == "Darwin" ]; then
|
||||
if [ `uname` == "Darwin" ]; then # if macOS
|
||||
diskutil unmountDisk $1
|
||||
else # assuming Linux
|
||||
# unmount sdcard
|
||||
umount $1* >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# use this function to mount regardless of MAC OS or not
|
||||
function smartMount() {
|
||||
function smart_mount() {
|
||||
msg "Mounting $1"
|
||||
|
||||
# if MAC OS
|
||||
if [ `uname` == "Darwin" ]; then
|
||||
if [ `uname` == "Darwin" ]; then # if macOS
|
||||
diskutil mountDisk $1
|
||||
else # assuming Linux
|
||||
# unmount sdcard
|
||||
umount $1* >/dev/null 2>&1
|
||||
mount $1* >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will be ran upon script EXIT (using trap)
|
||||
# this function will be run upon script exit (using trap)
|
||||
function cleanup {
|
||||
msg "Performing cleanup"
|
||||
|
||||
set +e
|
||||
|
||||
# unmount sdcard
|
||||
smartUnmount ${SDCARD_DEV}
|
||||
smart_unmount ${SDCARD_DEV}
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
@ -112,7 +106,7 @@ if [[ $DISK_IMG == *.gz ]]; then
|
||||
DISK_IMG=${DISK_IMG::-3}
|
||||
fi
|
||||
|
||||
smartUnmount ${SDCARD_DEV}
|
||||
smart_unmount ${SDCARD_DEV}
|
||||
msg "writing disk image to sdcard"
|
||||
dd if=$DISK_IMG of=$SDCARD_DEV bs=1048576
|
||||
sync
|
||||
@ -124,15 +118,11 @@ fi
|
||||
|
||||
mkdir -p $BOOT
|
||||
|
||||
if [ `uname` == "Darwin" ]; then
|
||||
if [ `uname` == "Darwin" ]; then # if macOS
|
||||
BOOT_DEV=${SDCARD_DEV}s1 # e.g. /dev/disk4s1
|
||||
|
||||
# mount the disk
|
||||
hdiutil attach ${BOOT_DEV}
|
||||
|
||||
BOOT=$(pwd)/.boot
|
||||
|
||||
echo "set BOOT for MAC to $BOOT"
|
||||
else # assuming Linux
|
||||
BOOT_DEV=${SDCARD_DEV}p1 # e.g. /dev/mmcblk0p1
|
||||
if ! [ -e ${SDCARD_DEV}p1 ]; then
|
||||
@ -184,21 +174,21 @@ if [ -n "$IP" ] && [ -n "$GW" ] && [ -n "$DNS" ]; then
|
||||
echo "static_dns=\"$DNS\"" >> $conf
|
||||
fi
|
||||
|
||||
if [ `uname` == "Darwin" ]; then
|
||||
if [ `uname` == "Darwin" ]; then # if macOS
|
||||
# copy created files over to the disk
|
||||
DISK_PARTITION=`diskutil info $BOOT_DEV | grep "Mount Point:" | sed 's/^[^/]*//' | sed 's/ /\\ /g'`
|
||||
|
||||
echo "moving $BOOT/* to $DISK_PARTITION"
|
||||
|
||||
mv -v "$BOOT"/* "$DISK_PARTITION"
|
||||
|
||||
sync
|
||||
smartUnmount ${SDCARD_DEV}
|
||||
smart_unmount ${SDCARD_DEV}
|
||||
rmdir $BOOT
|
||||
diskutil eject ${SDCARD_DEV}
|
||||
else
|
||||
|
||||
else # assuming Linux
|
||||
sync
|
||||
smartUnmount $BOOT
|
||||
smart_unmount $BOOT
|
||||
rmdir $BOOT
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user