2017-06-09 23:25:56 +00:00
#!/bin/bash -x
2017-10-12 23:37:38 +00:00
2019-07-20 16:43:28 +00:00
# This /opt/iiab/iiab/roles/httpd/templates/refresh-wiki-docs.sh becomes
# /usr/bin/iiab-refresh-wiki-docs during IIAB's install.
# This pulls down iiab/iiab repo's entire Tech Docs Wiki (and scrapes/downloads
# other docs!) to create IIAB's offline docs collection: http://box/info
2017-10-12 23:37:38 +00:00
2019-07-21 00:57:44 +00:00
# TO DO: find more pages to download/scrape and offline links to fix,
# based on "fieldback" from truly remote implementer/operators.
2019-07-20 16:26:23 +00:00
set -e # Exit on error (avoids snowballing)
2019-07-20 15:15:40 +00:00
source { { iiab_env_file } } # /etc/iiab/iiab.env
2017-10-13 03:03:35 +00:00
INPUT = /tmp/iiab-wiki
OUTPUT = /tmp/iiab-wiki.out
2019-07-20 17:09:14 +00:00
DESTPATH = { { doc_root } } /info # /library/www/html/info
2019-07-20 15:15:40 +00:00
DOCSPATH = $DESTPATH /docs # /library/www/html/info/docs
2017-06-09 23:25:56 +00:00
rm -rf $INPUT
rm -rf $OUTPUT
mkdir -p $INPUT
mkdir -p $OUTPUT
2019-07-20 15:15:40 +00:00
mkdir -p $DOCSPATH
2017-06-09 23:25:56 +00:00
2017-10-12 23:37:38 +00:00
git clone https://github.com/iiab/iiab.wiki.git $INPUT
2017-06-09 23:25:56 +00:00
2017-10-13 03:03:35 +00:00
for f in ` ls $INPUT ` ; do
2017-06-09 23:25:56 +00:00
FTRIMMED = ${ f %.md }
2017-10-12 23:37:38 +00:00
if [ $FTRIMMED = "Home" ] ; then FTRIMMED = index; fi
2017-10-13 03:03:35 +00:00
pandoc -s $INPUT /$f -o $OUTPUT /$FTRIMMED .html
2017-06-09 23:25:56 +00:00
done
2017-10-12 23:37:38 +00:00
rsync -av $OUTPUT / $DESTPATH
2017-10-13 03:03:35 +00:00
# Download FAQ etc
2017-10-12 23:37:38 +00:00
lynx -reload -source http://wiki.laptop.org/go/IIAB/FAQ > $DESTPATH /FAQ.html
lynx -reload -source http://wiki.laptop.org/go/IIAB/Security > $DESTPATH /Security.html
lynx -reload -source http://wiki.laptop.org/go/IIAB/local_vars.yml > $DESTPATH /local_vars.yml
lynx -reload -source http://wiki.laptop.org/go/IIAB/local_vars_min.yml > $DESTPATH /local_vars_min.yml
lynx -reload -source http://wiki.laptop.org/go/IIAB/local_vars_big.yml > $DESTPATH /local_vars_big.yml
2017-10-13 03:03:35 +00:00
# Download older release notes
2017-10-12 23:37:38 +00:00
lynx -reload -source https://github.com/XSCE/xsce/wiki/IIAB-6.2-Release-Notes > $DESTPATH /IIAB-6.2-Release-Notes.html
lynx -reload -source https://github.com/XSCE/xsce/blob/release-6.2/ReleaseNotes6.0.md > $DESTPATH /ReleaseNotes6.0.html
lynx -reload -source https://github.com/XSCE/xsce/blob/release-6.2/ReleaseNotes6.1.md > $DESTPATH /ReleaseNotes6.1.html
2019-07-18 23:35:26 +00:00
# Download Raspberry Pi guides
2019-07-20 17:40:23 +00:00
wget -nc https://www.raspberrypi.org/magpi-issues/Beginners_Guide_v1.pdf -O $DOCSPATH /Raspberry_Pi_Beginners_Guide_v1.pdf || true # Overrides set -e
2020-04-26 22:21:47 +00:00
wget -nc https://archive.org/15/items/other_doc/other_doc.pdf -O $DOCSPATH /Raspberry_Pi_User_Guide_v4.pdf || true
2019-07-18 21:22:06 +00:00
2019-07-21 00:57:44 +00:00
# Copy PDF from Lokole playbook
cp -p "{{ iiab_dir }}/roles/lokole/Lokole-IIAB_Users_Manual.pdf" $DOCSPATH # From /opt/iiab/iiab
# MAKE LINKS REFER TO LOCAL ITEMS...
2019-07-20 16:26:23 +00:00
2019-07-21 00:57:44 +00:00
# ...on main page (http://box/info)
2019-07-20 15:15:40 +00:00
sed -i -r "s|https://www.raspberrypi.org/magpi-issues/Beginners_Guide_v1.pdf|docs/Raspberry_Pi_Beginners_Guide_v1.pdf|g" $DESTPATH /index.html
2020-04-26 22:34:56 +00:00
sed -i -r "s|https://.*archive.org/15/items/other_doc/other_doc.pdf|docs/Raspberry_Pi_User_Guide_v4.pdf|g" $DESTPATH /index.html
2019-07-20 17:58:20 +00:00
sed -i -r "s|https://github.com/iiab/iiab/blob/master/roles/lokole/Lokole-IIAB_Users_Manual.pdf|docs/Lokole-IIAB_Users_Manual.pdf|g" $DESTPATH /index.html
2019-07-18 21:22:06 +00:00
2019-07-21 00:57:44 +00:00
# ...and within subpages
2017-10-13 15:48:54 +00:00
for f in $DESTPATH /*.html; do
sed -i -r "s|https://github.com/iiab/iiab/wiki/([-.A-Za-z0-9]*)|\1.html|g" $f
sed -i -e "s|https://github.com/xsce/xsce/blob/release-6.2/\(.*\)\.md\">|\1.html\">|g" $f
sed -i -e "s|https://github.com/xsce/xsce/wiki/\(.*\)\">|\1.html\">|g" $f
sed -i -e "s|http://wiki.laptop.org/go/IIAB/FAQ|FAQ.html|g" $f
sed -i -e "s|/go/IIAB/FAQ|FAQ.html|g" $f
sed -i -e "s|http://wiki.iiab.io/FAQ|FAQ.html|g" $f
sed -i -e "s|http://FAQ.IIAB.IO|FAQ.html|g" $f
sed -i -e "s|http://faq.iiab.io|FAQ.html|g" $f
sed -i -e "s|http://schoolserver.org/FAQ|FAQ.html|g" $f
sed -i -e "s|http://schoolserver.org/faq|FAQ.html|g" $f
sed -i -e "s|http://wiki.laptop.org/go/XS_Community_Edition/FAQ|FAQ.html|g" $f
sed -i -e "s|http://wiki.laptop.org/go/IIAB/Security|Security.html|g" $f
sed -i -e "s|/go/IIAB/Security|Security.html|g" $f
sed -i -e "s|http://wiki.iiab.io/Security|Security.html|g" $f
sed -i -e "s|http://wiki.laptop.org/go/IIAB/local_vars.yml|local_vars.yml|g" $f
sed -i -e "s|/go/IIAB/local_vars.yml|local_vars.yml|g" $f
sed -i -e "s|http://wiki.iiab.io/local_vars.yml|local_vars.yml|g" $f
sed -i -e "s|http://wiki.laptop.org/go/IIAB/local_vars_min.yml|local_vars_min.yml|g" $f
sed -i -e "s|/go/IIAB/local_vars_min.yml|local_vars_min.yml|g" $f
sed -i -e "s|http://wiki.iiab.io/local_vars_min.yml|local_vars_min.yml|g" $f
sed -i -e "s|http://wiki.laptop.org/go/IIAB/local_vars_big.yml|local_vars_big.yml|g" $f
sed -i -e "s|/go/IIAB/local_vars_big.yml|local_vars_big.yml|g" $f
sed -i -e "s|http://wiki.iiab.io/local_vars_big.yml|local_vars_big.yml|g" $f
2017-06-09 23:25:56 +00:00
done
2017-10-12 23:37:38 +00:00
2017-06-20 01:12:18 +00:00
exit 0