79 lines
3.0 KiB
Bash
Executable File
79 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
MYSTIC_SOURCE=${1:-mys112a39_l64.rar}
|
|
[ "$1" ] && shift
|
|
SPELL_SOURCE=${1:-mystic_spellcheck_v2.zip}
|
|
[ "$1" ] && shift
|
|
|
|
CLEAN_INSTALL_DIR=x
|
|
INSTALL_CONTAINER=debian:stretch-slim
|
|
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
|
|
echo "! Skipping installation [${TARGET_DIR}] already exists"
|
|
|
|
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
|
|
|
|
mkdir ${CLEAN_INSTALL_DIR}; cd ${CLEAN_INSTALL_DIR}; unrar x ../${MYSTIC_SOURCE}; cd ..
|
|
[ $? -gt 0 ] && echo "ERROR: Unrar 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
|
|
tar czf ../mystic.tar.gz mystic
|
|
echo "OK mystic.tar.gz can be moved to your docker build"
|