Skip to content

Instantly share code, notes, and snippets.

@IVBakker IVBakker/sync.sh
Last active Aug 17, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.