This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
mystic/cleaninstall/cleaninstall.sh

83 lines
3.1 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
2019-02-03 00:24:41 +00:00
MYSTIC_SOURCE=${1:-mys112a42_pi.zip}
[ "$1" ] && shift
SPELL_SOURCE=${1:-mystic_spellcheck_v2.zip}
[ "$1" ] && shift
CLEAN_INSTALL_DIR=x
2018-09-02 23:28:02 +00:00
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
2018-08-26 14:30:33 +00:00
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
unzip ${MYSTIC_SOURCE} -d ${CLEAN_INSTALL_DIR}
2019-02-03 00:24:41 +00:00
chmod +x ${CLEAN_INSTALL_DIR}/install
[ $? -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 {} \;
2019-04-07 13:03:49 +00:00
# Create our temp dirs
mkdir data/tempftn data/tempmis data/temputil
# 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
echo "OK mystic.tar.gz can be moved to your docker build"