The update script backs up the config file to `/root/config.bak`, but
then tries to restore it from `/root/config.yml.bak` (which obviously
won't be found).
This looks like a typo in the backup command, so update that command to
use the same filename as the restore command.
Signed-off-by: Ross Simpson <ross@rosssimpson.com>
Removed bmap-tools from depends as the check on line 96 looks for bmaptools and would use it if available if not continue to build, but have it as a depend check made the check null and if someone is on a kernel/file-system that does not support SEEK_HOLE and SEEK_DATA the script just fails.
Fixed bmap-tools check as the line which bmaptool >/dev/null 2>&1 does not return 0 so it kept ending at this line, if bmap-tools were not installed
The original code below looks for sparse to be 0 and if which bmaptool >/dev/null 2>&1 returns 0 to use bmap-tools, but I think its the reverse so swapped the last then and else sections as it would then look if sparse is 0 and which bmaptool >/dev/null 2>&1 is 0 to not use bmap-tools, but if it is 1 to use bmap-tools. If tool is available = 1 use bmap-tools, if tools is unavailable=0 do not use bmap-tools:
if [ "${OPT_SPARSE}" -eq 0 ];
then
which bmaptool >/dev/null 2>&1
if [ $? -eq 0 ];
then
echo "[+] Defaulting to sparse image generation as bmaptool is available"
OPT_SPARSE=1
Removed bmap-tools from depends as the check on line 96 looks for bmaptools and would use it if available if not continue to build, but have it as a depend check made the check null and if someone is on a kernel/file-system that does not support SEEK_HOLE and SEEK_DATA the script just fails.
Fixed bmap-tools check as the line which bmaptool >/dev/null 2>&1 does not return 0 so it kept ending at this line, if bmap-tools were not installed
The original code below looks for sparse to be 0 and if which bmaptool >/dev/null 2>&1 returns 0 to use bmap-tools, but I think its the reverse so swapped the last then and else sections as it would then look if sparse is 0 and which bmaptool >/dev/null 2>&1 is 0 to not use bmap-tools, but if it is 1 to use bmap-tools. If tool is available = 1 use bmap-tools, if tools is unavailable=0 do not use bmap-tools:
if [ "${OPT_SPARSE}" -eq 0 ];
then
which bmaptool >/dev/null 2>&1
if [ $? -eq 0 ];
then
echo "[+] Defaulting to sparse image generation as bmaptool is available"
OPT_SPARSE=1
Before:
```
bash: ./update_pwnagotchi.sh: /bin/bash^M: bad interpreter: No such file or directory
```
Thus:
```
scripts/update_pwnagotchi.sh: Bourne-Again shell script text executable, ASCII text, with CRLF line terminators
dos2unix: converting file scripts/update_pwnagotchi.sh to Unix format...
scripts/update_pwnagotchi.sh: Bourne-Again shell script text executable, ASCII text
```
Now it works :)
This uses https://github.com/intel/bmap-tools to generate a .bmap file
which can be copied around. The bmaptool allows storing sparse files
onto for instance an SD card, thus avoiding having to transfer the full
disk image every time one burns one.
Thus saving lots of time (and SD card cycles).
This also adds some instructions for then transfering and copying the
sparse file.
bmaptool: info: discovered bmap file '/Users/jeroen/berry.img.bmap'
bmaptool: info: block map format version 2.0
bmaptool: info: 7324219 blocks of size 4096 (27.9 GiB), mapped 1539940 blocks (5.9 GiB or 21.0%)
bmaptool: info: copying image 'berry.img' to file 'rdisk4' using bmap file 'berry.img.bmap'
bmaptool: info: 100% copied
bmaptool: info: synchronizing '/dev/rdisk4'
bmaptool: info: copying time: 6m 49.7s, copying speed 14.7 MiB/sec
versus copying the whole 30G which would take forever...