Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
staging/
sdcard/
NookManager.img
NookManager.img*
build.sh?*
32 changes: 13 additions & 19 deletions NookManager/menu/backup
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,36 @@ MENU=/tmp/sdcache/menu

title="Create Backup"
header=
button1=
button1="<- Erase empty storage (makes backup faster)"
button2="Format remaining space on SD card ->"
button3="<- Back"
button2=
button4=
button4="Create backup ->"
footer=
key=0



if [ ! -b /dev/block/mmcblk1p2 ]; then
header="Backups will be stored on this SD card.\nTo proceed, you must format the unused\nspace on this card."
button2="Format remaining space on SD card ->"
else
header="It will take 15-45 minutes to create a backup."
button4="Create backup ->"
fi

until [ "$key" -eq "3" ]; do
if [ ! -b /dev/block/mmcblk1p2 ]; then
header="Backups will be stored on this SD card.\nTo proceed, you must format the unused\nspace on this card."
else
header="It will take 15-45 minutes to create a backup."
fi

$SCRIPT/menu -t "$title" -h "$header" -f "$footer" -1 "$button1" -2 "$button2" -3 "$button3" -4 "$button4"
key=$?

if [[ "$key" -eq "2" ]]; then
$SCRIPT/menu -t "$title" -h "$header" -f "Formatting free space on SD card..."
footer=`$SCRIPT/format_unused_sdcard`
header="It will take 15-45 minutes to create a backup."
button2=""
button4="Create backup ->"

elif [[ "$key" -eq "1" ]]; then
$SCRIPT/menu -t "$title" -h "$header" -f "Erasing empty storage areas..."
footer=`$SCRIPT/shrink_data`

elif [[ "$key" -eq "4" ]]; then
$SCRIPT/menu -t "$title" -h "$header" -f "Creating backup image...\nBackup started `date +%H:%M:%S`"
footer=`$SCRIPT/create_backup`
# If the backup succeeded, hide the create backup button
if [ "$?" -eq "0" ]; then
header=""
button4=""
fi
fi

done
10 changes: 7 additions & 3 deletions NookManager/menu/mainmenu
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ key=0
while [ "$key" -ne "3" ]; do

POWER=`cat /sys/class/power_supply/bq27510-0/capacity`
CHARGING=`cat /sys/class/power_supply/bq27510-0/status`

if [ "$POWER" -lt "40" ]; then
header="System: $SYSTEM\nBattery Level: $POWER\nPlease charge your battery above 40\nand then restart NookManager."
POWERMSG="$POWER%%"
[ "" != "$CHARGING" ] && POWERMSG="$POWER%% ($CHARGING)"
header="System: $SYSTEM\nBattery Level: $POWERMSG"

if [ "$POWER" -lt "40" -a \( "$POWER" -lt 20 -o "$CHARGING" != "Charging" \) ]; then
header="$header\nPlease charge your battery above 40%%\n(or 20%% when plugged in to power)\nand then restart NookManager."
button1=
button3="<- Exit"
button2=
button4=
else
header="System: $SYSTEM\nBattery Level: $POWER"
button1="<- Rescue"
button3="<- Exit"
button2="Root ->"
Expand Down
19 changes: 0 additions & 19 deletions NookManager/scripts/create_backup
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,8 @@ umount /tmp/backups
mkdir -p /tmp/backups
mount -t vfat /dev/block/mmcblk1p2 /tmp/backups

$SCRIPT/mount_nook

echo Backup started `date +%H:%M:%S`

# Zero the free space on each of the Nook's partitions
dd if=/dev/zero of=/nook/factory/DELETEME bs=512k
rm /nook/factory/DELETEME

dd if=/dev/zero of=/nook/system/DELETEME bs=512k
rm /nook/system/DELETEME

dd if=/dev/zero of=/nook/userdata/DELETEME bs=512k
rm /nook/userdata/DELETEME

dd if=/dev/zero of=/nook/cache/DELETEME bs=512k
rm /nook/cache/DELETEME

dd if=/dev/zero of=/nook/data/DELETEME bs=512k
rm /nook/data/DELETEME

sync

dd if=/dev/block/mmcblk0 bs=1000k | gzip -1 > /tmp/backups/backup.full.gz
Expand All @@ -46,7 +28,6 @@ fi

sync
umount /tmp/backups
$SCRIPT/umount_nook

echo "/dev/block/mmcblk1p2" > /sys/devices/platform/usb_mass_storage/lun1/file

Expand Down
8 changes: 4 additions & 4 deletions NookManager/scripts/menu_draw
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ done
-pointsize 45 \
-draw "gravity North text 0,0 '$title'" \
-pointsize 26 \
-draw "gravity West text 0,-100 '$button1' " \
-draw "gravity East text 0,-100 '$button2' " \
-draw "gravity West text 0,120 '$button3' " \
-draw "gravity East text 0,120 '$button4' " \
-draw "gravity West text 0,-115 '$button1' " \
-draw "gravity East text 0,-85 '$button2' " \
-draw "gravity West text 0,105 '$button3' " \
-draw "gravity East text 0,135 '$button4' " \
-gravity north \
-annotate +0+80 "$header" \
-gravity south \
Expand Down
28 changes: 28 additions & 0 deletions NookManager/scripts/shrink_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SCRIPT=/tmp/sdcache/scripts

$SCRIPT/mount_nook

echo Backup started `date +%H:%M:%S`

# Zero the free space on each of the Nook's partitions
# (described as "Erasing empty storage areas" on-screen)

dd if=/dev/zero of=/nook/factory/DELETEME bs=512k
rm /nook/factory/DELETEME

dd if=/dev/zero of=/nook/system/DELETEME bs=512k
rm /nook/system/DELETEME

dd if=/dev/zero of=/nook/userdata/DELETEME bs=512k
rm /nook/userdata/DELETEME

dd if=/dev/zero of=/nook/cache/DELETEME bs=512k
rm /nook/cache/DELETEME

dd if=/dev/zero of=/nook/data/DELETEME bs=512k
rm /nook/data/DELETEME

sync
$SCRIPT/umount_nook

exit 0
27 changes: 15 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,28 @@ cp "$BDIR/patched-jars/android.policy.jar" "$OUTDIR/files/system/framework/"
cp "$BDIR/patched-jars/services.jar" "$OUTDIR/files/system/framework/"

# Create image
dd if=/dev/zero of=NookManager.img bs=1MiB count=64
losetup /dev/loop0 NookManager.img
parted /dev/loop0 mklabel msdos
parted /dev/loop0 --align=cyl mkpart primary fat32 0 100%
parted /dev/loop0 set 1 boot on
losetup -o 16384 /dev/loop1 /dev/loop0
mkdosfs -F 32 -n "NookManager" /dev/loop1
IMAGE_FILE=NookManager.img
dd if=/dev/zero of=$IMAGE_FILE bs=1MiB count=64
WHOLE_CARD=$(sudo losetup -f)
sudo losetup $WHOLE_CARD $IMAGE_FILE
BOOTFS_DEV=$(sudo losetup -f)
sudo parted $WHOLE_CARD mklabel msdos
sudo parted $WHOLE_CARD --align=minimal mkpart primary fat32 16384B 100%
sudo parted $WHOLE_CARD set 1 boot on
sudo losetup -o 16384 $BOOTFS_DEV $WHOLE_CARD
sudo mkdosfs -F 32 -n "NookManager" $BOOTFS_DEV

if [ ! -d "$BDIR/tmpmount" ]; then
mkdir "$BDIR/tmpmount"
fi
mount -t vfat /dev/loop1 "$BDIR/tmpmount"
sudo mount -t vfat -o uid=$(id -ur) -o gid=$(id -gr) $BOOTFS_DEV "$BDIR/tmpmount"

rsync -a "$OUTDIR/" "$BDIR/tmpmount/"
sync
umount "$BDIR/tmpmount"
sudo umount "$BDIR/tmpmount"

losetup -d /dev/loop1
sudo losetup -d $BOOTFS_DEV
sync
losetup -d /dev/loop0
sudo losetup -d $WHOLE_CARD

echo "Build Complete. You can now flash NookManager.img to a SD card."
echo "Build Complete. You can now flash $IMAGE_FILE to an SD card."
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
You must use a 32-bit Linux system to build this project.

(Bela Lubkin notes: it built fine for me on Ubuntu 12.04 x86_64; not
sure what the issue might be? I do have 32-bit libraries installed for
the benefit of various binary-only apps.)

git clone https://github.com/doozan/NookManager.git

cd NookManager
Expand Down