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.
magicka/init
2018-11-09 15:21:29 +11:00

46 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
: ${MAGICKA_ROOT=/opt/magicka}
PATH=${MAGICKA_ROOT}/bin:$PATH
export PATH
# Adjust some paths
echo "* Adjusting some paths..."
sed -i 's/magicka\/var/magicka\/data\/var/g' ${MAGICKA_ROOT}/bin/magiedit.sh
if [ ! -d "${MAGICKA_ROOT}/data/etc" ]; then
echo "* Installing MAGICKA_ROOT data files into ${MAGICKA_ROOT}/data"
cp -pR ${MAGICKA_ROOT}/{etc,share,var} ${MAGICKA_ROOT}/data/
sed -ri 's#opt/magicka/(etc|share|var)#opt/magicka/data/\1#g' ${MAGICKA_ROOT}/data/etc/magicka/bbs.ini
sed -i 's/=\ USERNAME/= root/g' ${MAGICKA_ROOT}/data/etc/magicka/bbs.ini
sed -i 's#magicka#opt/magicka/data#g' ${MAGICKA_ROOT}/data/etc/magicka/filesgen.ini
sed -i 's#var/magicka/msgs#data/msgs#g' ${MAGICKA_ROOT}/data/etc/magicka/localmail.ini
mkdir ${MAGICKA_ROOT}/data/{msgs,ftn}
mkdir ${MAGICKA_ROOT}/data/ftn/{bad_tic,cm_temp,cm_packets,in_sec,in,in_temp,out}
rmdir ${MAGICKA_ROOT}/data/var/magicka/msgs
fi
# Fix for magiedit
[ -d ${MAGICKA_ROOT}/data/share/magicka/ansis/drafts ] || mkdir ${MAGICKA_ROOT}/data/share/magicka/ansis/drafts
ln -sf ${MAGICKA_ROOT}/data/share/magicka/ansis/drafts ${MAGICKA_ROOT}/share/magicka/ansis/drafts
ln -sf ${MAGICKA_ROOT}/data/share/magicka/ansis/magiedit.ans ${MAGICKA_ROOT}/share/magicka/ansis/magiedit.ans
ln -sf ${MAGICKA_ROOT}/data/share/magicka/ansis/magiquote.ans ${MAGICKA_ROOT}/share/magicka/ansis/magiquote.ans
for keytype in rsa dsa; do
if [ ! -f "${MAGICKA_ROOT}/data/etc/magicka/keys/ssh_host_${keytype}_key" ]; then
echo "* Generating ${keytype} ssh key"
[ -d "${MAGICKA_ROOT}/data/etc/magicka/keys" ] || mkdir ${MAGICKA_ROOT}/data/etc/magicka/keys
/usr/bin/ssh-keygen -f ${MAGICKA_ROOT}/data/etc/magicka/keys/ssh_host_${keytype}_key -N '' -t ${keytype}
fi
done
# clear out state and lockfiles from previous instance
echo "* Setting up FTN watch"
touch ${MAGICKA_ROOT}/data/var/magicka/mail.out
( while inotifywait -e close_write ${MAGICKA_ROOT}/data/var/magicka/mail.out; do ${MAGICKA_ROOT}/bin/magiscan.sh;done )&
echo "* Ready..."
exec "$@"