Skip to content

Instantly share code, notes, and snippets.

@Fran-Rg
Last active August 17, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fran-Rg/fbab508c336397323d6c1caef8cdc46c to your computer and use it in GitHub Desktop.
Save Fran-Rg/fbab508c336397323d6c1caef8cdc46c to your computer and use it in GitHub Desktop.
EMF Badge 2016 - Sync local to Badge and unmount
#!/bin/bash
# HOW TO USE: make this script next to a src directory that contains all files on the Badge (~190.5 kB)
# /Badge
# -sync.sh
# -src/
# ----<ALL Badge files: wifi.json, etc>
# Make your changes locally and the script will copy them to the badge and unplug safely the badge. Restart and test your changes
#!/bin/bash
cd "$(dirname "$0")"
partition_info=`df -h --output=source,target | grep PYBFLASH | tr -s ' ' ' '`
if [ -z "$partition_info" ]
then
possible_mount=`fdisk -l 2> /dev/null | grep -A 1 Device | tail -n 1 | grep FAT12 | cut -d ' ' -f 1`
if [ -z "$possible_mount" ]
then
echo "No TILDA connected, Nothing to mount"
exit
fi
udisksctl mount -b $possible_mount
partition_info=`df -h --output=source,target | grep PYBFLASH | tr -s ' ' ' '`
if [ -z "$partition_info" ]
then
echo "No TILDA connected"
exit
fi
fi
partition=`echo $partition_info | cut -d ' ' -f 1`
path=`echo $partition_info | cut -d ' ' -f 2`
rsync -avzh -delete --exclude 'src/log.txt' src/* $path
udisksctl unmount -b $partition
udisksctl power-off -b $partition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment