2018-08-24 03:57:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
NAME="Mystic BBS"
|
2019-04-07 13:03:49 +00:00
|
|
|
VERSION="A43"
|
2018-08-24 03:57:25 +00:00
|
|
|
INIT=mis
|
|
|
|
|
|
|
|
function stop {
|
|
|
|
echo "Stopping ${NAME}"
|
|
|
|
kill $(ps -Af|grep ${INIT} |grep -v grep|awk '{ print $2}')
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'stop' SIGTERM
|
|
|
|
export PATH=$PATH:/mystic
|
|
|
|
|
|
|
|
if [ "$1" == "start" ]; then
|
|
|
|
# First time install - expand out our data directory
|
2019-02-03 00:24:41 +00:00
|
|
|
if [ $(find data|wc -l) -le 1 ]; then
|
|
|
|
echo "** First time install, deploying sample setup"
|
|
|
|
tar xzf data.tar.gz
|
|
|
|
echo ${VERSION} > .version
|
|
|
|
|
|
|
|
# We need to upgrade
|
|
|
|
else
|
|
|
|
OLD_VERSION=$(cat data/.version)
|
|
|
|
echo "** Upgrading [${OLD_VERSION}]"
|
|
|
|
case ${OLD_VERSION} in
|
|
|
|
A39)
|
|
|
|
echo "Processing data/default.txt"
|
|
|
|
set -x
|
|
|
|
[ ! -d data/upgrade/${VERSION}/${OLD_VERSION} ] && mkdir -p data/upgrade/${VERSION}/${OLD_VERSION}
|
|
|
|
cd data/upgrade/${VERSION}/${OLD_VERSION}
|
|
|
|
[ -d data ] && rm -rf data
|
|
|
|
tar xzf /mystic/data.tar.gz
|
|
|
|
cd /mystic/data
|
|
|
|
diff -u data/default.txt upgrade/${VERSION}/${OLD_VERSION}/data/data/default.txt > upgrade/${VERSION}/${OLD_VERSION}/default.txt.patch && echo $?
|
|
|
|
if [ -s upgrade/${VERSION}/${OLD_VERSION}/default.txt.patch ]; then
|
|
|
|
patch -p 0 < upgrade/${VERSION}/${OLD_VERSION}/default.txt.patch
|
|
|
|
echo "! Check upgrade/${VERSION}/${OLD_VERSION}/default.txt.patch for an strings that may have been overwritten..."
|
|
|
|
else
|
|
|
|
rm -f upgrade/${VERSION}/${OLD_VERSION}/default.txt.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in msg_index.ini msg_index.ans msg_index_help.ans; do
|
|
|
|
cp upgrade/${VERSION}/${OLD_VERSION}/data/text/$i text/
|
|
|
|
done
|
|
|
|
|
|
|
|
cp upgrade/${VERSION}/${OLD_VERSION}/data/data/cfgroot4.ans data/
|
|
|
|
../upgrade
|
|
|
|
cd ../scripts
|
|
|
|
./mplc -all
|
|
|
|
cd ../data
|
|
|
|
rm -rf upgrade/${VERSION}/${OLD_VERSION}/data
|
|
|
|
echo A42 > .version
|
|
|
|
;;
|
|
|
|
|
2019-04-07 13:03:49 +00:00
|
|
|
A42)
|
|
|
|
set -x
|
|
|
|
[ ! -d data/upgrade/${VERSION}/${OLD_VERSION} ] && mkdir -p data/upgrade/${VERSION}/${OLD_VERSION}
|
|
|
|
cd data/upgrade/${VERSION}/${OLD_VERSION}
|
|
|
|
[ -d data ] && rm -rf data
|
|
|
|
tar xzf /mystic/data.tar.gz
|
|
|
|
cd /mystic/data
|
|
|
|
|
|
|
|
for i in text/userchat.ans text/userchat.ini; do
|
|
|
|
cp upgrade/${VERSION}/${OLD_VERSION}/data/$i ./$i
|
|
|
|
done
|
|
|
|
|
|
|
|
diff -ur text/ upgrade/${VERSION}/${OLD_VERSION}/data/text/ > upgrade/${VERSION}/${OLD_VERSION}/text.patch || true
|
|
|
|
|
|
|
|
rm -rf upgrade/${VERSION}/${OLD_VERSION}/data
|
|
|
|
echo A43 > .version
|
|
|
|
;;
|
|
|
|
|
|
|
|
A43) echo "Already up to date!" ;;
|
2019-02-03 00:24:41 +00:00
|
|
|
|
|
|
|
*) echo "!! Dont know how to upgrade" && exit 1
|
|
|
|
esac
|
|
|
|
fi
|
2018-08-24 03:57:25 +00:00
|
|
|
|
2019-04-07 13:03:49 +00:00
|
|
|
if [ -x /usr/sbin/zerotier-one -a -n "${ENABLE_ZT}" ]; then
|
|
|
|
echo "** Starting ZeroTier"
|
|
|
|
mkdir /dev/net && mknod /dev/net/tun -m 666 c 10 200
|
|
|
|
/usr/sbin/zerotier-one -d
|
|
|
|
fi
|
|
|
|
|
2018-08-24 03:57:25 +00:00
|
|
|
# OK, start
|
|
|
|
exec ${INIT} server
|
|
|
|
|
|
|
|
else
|
|
|
|
exec $@
|
|
|
|
fi
|