-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakebook.sh
executable file
·49 lines (39 loc) · 1.36 KB
/
makebook.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
kindlegen=$(which kindlegen)
zip=$(which zip)
if [ ! -x "$zip" ]; then
echo "zip utility not found."
exit 1
fi
echo "zip utility found as '$zip'"
cd epub_root
zip -qX0 ../../Martin_Manley-My_life_and_death.epub mimetype
zip -qXur9D ../../Martin_Manley-My_life_and_death.epub *
if [ ! -x "$kindlegen" ]; then
echo "Amazon 'kindlegen' utility not found."
else
cd ../../
$kindlegen Martin_Manley-My_life_and_death.epub
fi
if [ ! -e "Martin_Manley-My_life_and_death.mobi" ]; then
echo "No .mobi version found?"
exit 1
fi
if [ "$1" = "copy" ]; then
# FIXME now we just assume kindle is not in use / mounted :O
device=$(grep -il "amazon kindle" /sys/bus/usb/devices/*/product | sed -e 's#/product.*##')
if [ ! -z "$device" ]; then
echo 0 | sudo tee ${device}/authorized
sleep 1
echo 1 | sudo tee ${device}/authorized
sleep 10
device=$(readlink /dev/disk/by-id/usb-Kindle_Internal_Storage*-part1)
if [ -b "/dev/disk/by-id/$device" ]; then
sudo mkdir -p /mnt/pt1
sudo mount /dev/disk/by-id/$device /mnt/pt1
sudo mkdir -p /mnt/pt1/documents/Manley,\ Martin/
sudo cp Martin_Manley-My_life_and_death.mobi /mnt/pt1/documents/Manley,\ Martin/Martin_Manley-My_life_and_death.mobi
sudo eject /dev/disk/by-id/$device
fi
fi
fi