2018-08-24 03:57:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
MYSTIC_SOURCE=${1:-mys112a39_pi.zip}
|
|
|
|
[ "$1" ] && shift
|
|
|
|
SPELL_SOURCE=${1:-mystic_spellcheck_v2.zip}
|
|
|
|
[ "$1" ] && shift
|
|
|
|
|
|
|
|
CLEAN_INSTALL_DIR=x
|
2018-08-27 10:07:49 +00:00
|
|
|
INSTALL_CONTAINER=arm32v7/debian:stretch-slim
|
2018-08-24 03:57:25 +00:00
|
|
|
TARGET_DIR=mystic
|
|
|
|
PATCH_FILE=mystic.112a39.patch
|
|
|
|
|
|
|
|
[ $(id -u) -ne 0 ] && echo "ERROR: You need to run me as root." && exit 1
|
|
|
|
|
|
|
|
if [ -d ${TARGET_DIR} ]; then
|
2018-08-26 14:30:33 +00:00
|
|
|
echo "! Skipping installation [${TARGET_DIR}] already exists"
|
2018-08-24 03:57:25 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
# 1) Download Mystic App
|
|
|
|
[ ! -f ${MYSTIC_SOURCE} -o ! -f ${SPELL_SOURCE} ] && echo "ERROR: Source file missing [${MYSTIC_SOURCE}/${SPELL_SOURCE}], did you download it?" && exit 1
|
|
|
|
|
|
|
|
# 2) Create a new directory for it and unzip the App into it
|
|
|
|
[ -d ${CLEAN_INSTALL_DIR} ] && echo "ERROR: Directory [${CLEAN_INSTALL_DIR}] already exists!" && exit 1
|
|
|
|
|
|
|
|
unzip ${MYSTIC_SOURCE} -d ${CLEAN_INSTALL_DIR}
|
|
|
|
[ $? -gt 0 ] && echo "ERROR: Unzip failed?" && exit 1
|
|
|
|
|
|
|
|
# 3) Run docker with -v mapping the unzip files to an arbitrary directory -v unzipfiles:/install
|
|
|
|
# ** @TODO Request upstream to default QWK and Echo DIRs to named dir as well during installation
|
|
|
|
echo "Running docker, please perform the installation, and set:"
|
|
|
|
echo "* Installation directory to /mystic"
|
|
|
|
echo "* Data directories prefixed with /mystic/data"
|
|
|
|
echo "+ * Leave System Path and Scripts to /mystic"
|
|
|
|
echo "+ * Especially, QWK Settings and Echomail Settings"
|
|
|
|
|
|
|
|
docker run --rm -it -v ${PWD}/${CLEAN_INSTALL_DIR}:/install ${INSTALL_CONTAINER} /bin/bash -c "cd /install; ./install; [ -d /mystic ] && echo \"Now change QWK Settings and Echomail settings...\" && cd /mystic/ && sleep 5 && ./mystic -cfg && cd /; mv /mystic /install/"
|
|
|
|
|
|
|
|
[ ! -d ${CLEAN_INSTALL_DIR}/mystic/data/data ] && echo "ERROR: Expected a [${CLEAN_INSTALL_DIR}/mystic/data/data] dir, but it wasnt there?" && exit 1
|
|
|
|
[ ! -d ${CLEAN_INSTALL_DIR}/mystic/scripts ] && echo "ERROR: Expected a [${CLEAN_INSTALL_DIR}/mystic/scripts] dir, but it wasnt there?" && exit 1
|
|
|
|
[ ! -d ${CLEAN_INSTALL_DIR}/mystic/semaphore ] && echo "ERROR: Expected a [${CLEAN_INSTALL_DIR}/mystic/semaphore] dir, but it wasnt there?" && exit 1
|
|
|
|
|
|
|
|
# Add the spell directionary files to the data directory
|
|
|
|
unzip ${SPELL_SOURCE} dictionary.* -d ${CLEAN_INSTALL_DIR}/mystic/data/data
|
|
|
|
|
|
|
|
# 4) Run this script which will clean up the install and ZIP it up to be used with a docker.
|
|
|
|
cd ${CLEAN_INSTALL_DIR}/mystic
|
|
|
|
|
|
|
|
mv files mystic.dat data/
|
|
|
|
rm -rf localqwk echomail
|
|
|
|
|
|
|
|
# We need a symbolic link so that MIS can find MYSTIC
|
|
|
|
# @TODO Request fix from upstream
|
|
|
|
ln -s ../mystic data/mystic
|
|
|
|
|
|
|
|
chmod 755 * scripts/mide scripts/mplc scripts/*.mpx
|
|
|
|
chmod 644 *.ini *.txt docs/*.txt scripts/*.mps scripts/*.ini
|
|
|
|
|
|
|
|
patch -p0 < ../../${PATCH_FILE}
|
|
|
|
|
|
|
|
# Clean up data dir
|
|
|
|
find data -type f -exec chmod 644 {} \;
|
|
|
|
|
|
|
|
# Finished
|
|
|
|
mv data ../..
|
|
|
|
cd ../..
|
|
|
|
mv ${CLEAN_INSTALL_DIR}/mystic .
|
|
|
|
rm -rf ${CLEAN_INSTALL_DIR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Tar up the data dir and add it back to the main install
|
|
|
|
echo "Zipping up data dir..."
|
|
|
|
tar czf mystic/data.tar.gz data/
|
|
|
|
|
|
|
|
# That dir is now ready for the image
|
2018-08-26 14:30:33 +00:00
|
|
|
tar czf ../mystic.tar.gz mystic
|
2018-08-24 03:57:25 +00:00
|
|
|
echo "OK mystic.tar.gz can be moved to your docker build"
|