48 lines
1.4 KiB
Bash
Executable file
48 lines
1.4 KiB
Bash
Executable file
#!/bin/sh
|
|
set -u
|
|
|
|
# TODO:
|
|
# import of images
|
|
|
|
# root directory of the cryptobox development environment
|
|
ROOT_DIR="$(dirname $(dirname $0))"
|
|
|
|
# retrieve these pages from the wiki
|
|
PAGES="CryptoBox CryptoBoxDev"
|
|
# the trailing slash is important
|
|
WIKI_HOST="https://systemausfall.org"
|
|
WIKI_URL="/wikis/howto/"
|
|
# the trailing slash is important
|
|
DEST_PATH="cbox-tree.d/usr/share/doc/cryptobox/html/"
|
|
TMP_FILE="/tmp/$(basename $0)-$$.out"
|
|
# the URL of the CGI of the cryptobox
|
|
CBOX_CGI='/cryptobox?action=show_doc&page='
|
|
|
|
[ ! -e "$DEST_PATH" ] && echo "$DEST_PATH does not exist" && exit 1
|
|
|
|
for PAGE in $PAGES; do
|
|
PAGE_SRC="$WIKI_HOST$WIKI_URL$PAGE"
|
|
echo "Importing $PAGE ..."
|
|
|
|
[ -e "$TMP_FILE" ] && rm "$TMP_FILE"
|
|
|
|
# download the page
|
|
echo " downloading the page ..."
|
|
wget -q -O "$TMP_FILE" "$PAGE_SRC" || { echo "Downloading ($PAGE_SRC) failed!"; exit 1; }
|
|
|
|
echo " removing header and footer ..."
|
|
# break lines before start of content
|
|
sed -i 's#<div [^>]* id="content" [^>]*>#_END_OF_HEADER_\n#' "$TMP_FILE"
|
|
sed -i 's#<div id="footer">#\n_START_OF_FOOTER_#' "$TMP_FILE"
|
|
# remove all lines before and after "body"
|
|
sed -i '1,/_END_OF_HEADER_/d; /_START_OF_FOOTER_/,$d' "$TMP_FILE"
|
|
|
|
# TODO: replace wiki-links by references to the cbox-cgi
|
|
# check if wiki-links are absolute!
|
|
echo " replacing wiki links ..."
|
|
sed -i "s#"$WIKI_URL#"$CBOX_CGI#g" "$TMP_FILE"
|
|
|
|
mv "$TMP_FILE" "${DEST_PATH}${PAGE}.html"
|
|
echo " finished!"
|
|
done
|