clic-rpi-image/stage4/03-bookshelf/00-run.sh

16 lines
613 B
Bash
Raw Normal View History

2020-05-13 12:09:03 +00:00
#!/bin/sh -e
BOOKSHELF_URL="https://magpi.raspberrypi.org/bookshelf.xml"
2021-06-17 15:52:07 +00:00
GUIDE_URL="$(curl -s "$BOOKSHELF_URL" | awk -F '[<>]' "/<TITLE>Raspberry Pi Beginner's Guide 4th Edition<\/TITLE>/ {f=1; next} f==1 && /PDF/ {print \$3; exit}")"
2020-05-13 12:09:03 +00:00
OUTPUT="$(basename "$GUIDE_URL" | cut -f1 -d'?')"
if [ ! -f "files/$OUTPUT" ]; then
rm files/*.pdf -f
curl -s "$GUIDE_URL" -o "files/$OUTPUT"
fi
file "files/$OUTPUT" | grep -q "PDF document"
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/Bookshelf"
install -v -o 1000 -g 1000 -m 644 "files/$OUTPUT" "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/Bookshelf/"