Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source "$SCRIPTFOLDER/modules/version.sh"
source "$SCRIPTFOLDER/modules/vnc.sh"
source "$SCRIPTFOLDER/modules/wifi.sh"
source "$SCRIPTFOLDER/modules/wificountry.sh"
source "$SCRIPTFOLDER/modules/clone.sh"



Expand Down Expand Up @@ -150,6 +151,10 @@ case $1 in
shift
feedback "$*"
;;
clone)
checkroot
clone
;;
help)
help "$2"
;;
Expand Down
38 changes: 38 additions & 0 deletions modules/clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

function clone {
a=$(fdisk -l |grep /dev/mmcblk0: | grep -P '\d+ (?=bytes)' -o)
#echo "$a - /dev/mmcblk0"

b=$(fdisk -l |grep /dev/sdb: | grep -P '\d+ (?=bytes)' -o)
#echo "$b - /dev/sdb"

if [ -z "$a" ] || [ -z "$b" ]; then
echo "no SDCard detected"
return 1
fi



if [ $b -lt $a ]; then
echo "SDCard detected but not big enough"
return 1
fi

if [ $a -eq $b ] || [ $a -lt $b ]; then

echo "copying...."
echo u > /proc/sysrq-trigger
dd if=/dev/mmcblk0 bs=1M of=/dev/sdb

fi

}

function clone_help {
echo ""
echo "Usage: $(basename "$0")"
echo ""
echo "clones your treehouses image to an SDCard"
echo ""
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.2.1",
"version": "1.2.2",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
"bin": {
Expand Down