#!/bin/csh -f
# RoA MUDBase Installation Script v0.1
# 1/18/98 James Rhone
# All Rights Reserved (see license.txt in the roa directory)
set os = `uname`
set ver = `uname -r`
clear
echo "Welcome to the RoA MUDBase installation script."
echo "(version 1.1, (c)1998, RoA MUDBase, -jtrhone)"
echo ""
echo "${os} ${ver}"
if ("${os}" != "Linux") then
echo "WARNING: Binaries may not operate properly on this OS."
endif
echo ""
echo ""
echo "Press <return> to begin..."
set input = $<
#
# _DEF_PORT_ in autorun
#
rep1:
set port = 4000
echo "Which port do you wish the server to run on by default?"
echo -n "(default: ${port}) > "
set input = $<
if ("${input}" != "") then
set port = "${input}"
endif
if (${port} < 1024 || ${port} > 32767) then
echo "Invalid port..."
echo "Press <return>..."
set input = $<
goto rep1
endif
#
# _ADMIN_USERNAME_ in autorun...
#
rep2:
set me = `whoami`
echo "Email which username reboot/crash information?"
echo -n "(default: ${me}) > "
set input = $<
if ("${input}" != "") then
set me = "${input}"
endif
set isin = `grep "${me}" /etc/passwd`
if ("${isin}" == "") then
echo "Unable to locate username ${me}..."
echo "Press <return>..."
set input = $<
goto rep2
endif
#
# Get the mud short name...
#
rep3:
set short = "RoA"
echo "Enter the short MUD name:"
echo -n "(default: ${short}) > "
set input = $<
if ("${input}" != "") then
set short = "${input}"
endif
#
# Get the mud long name...
#
rep3:
set long = "Realms of Aurealis"
echo "Enter the long MUD name:"
echo -n "(default: ${long}) > "
set input = $<
if ("${input}" != "") then
set long = "${input}"
endif
#
# set the spico path...
#
echo "Locating hard spico path..."
pushd ./roa/lib/edits >& /dev/null
if (! -f ./spico) then
echo "WARNING: Unable to locate spico... exeditor will be unavailable."
set spico = _DEF_SPICO_PATH_
else
set thisdir = `pwd`
set spico = ${thisdir}/spico
endif
popd >& /dev/null
#
# Now, actually modify the files...
#
echo "Altering autorun script..."
sed s/"_DEF_PORT_"/"${port}"/g ./roa/autorun > ./roa/autorun.tmp
mv ./roa/autorun.tmp ./roa/autorun
sed s/"_ADMIN_USERNAME_"/"${me}"/g ./roa/autorun > ./roa/autorun.tmp
mv ./roa/autorun.tmp ./roa/autorun
# This crap doesn't work yet...
#set awk1 = \'\{ if \(\$0 \=\= \"spico_path\:_DEF_SPICO_PATH_\"\)
#set awk2 = print \"${spico}\";
#set awk3 = else print \$0 \}\'
#set awkcmd = $awk1$awk2$awk3
#awk $awkcmd ./roa/lib/config/roa.cfg > ./roa/lib/config/roa.cfg.tmp
#awk '{ if ($0 == "spico_path:_DEF_SPICO_PATH_") \
# print "${spico}"; \
# else print $0 }' ./roa/lib/config/roa.cfg > ./roa/lib/config/roa.cfg.tmp
#mv ./roa/lib/config/roa.cfg.tmp ./roa/lib/config/roa.cfg
sed s/"_DEF_MUD_SHORT_NAME_"/"${short}"/g ./roa/lib/config/roa.cfg > ./roa/lib/config/roa.cfg.tmp
mv ./roa/lib/config/roa.cfg.tmp ./roa/lib/config/roa.cfg
sed s/"_DEF_MUD_LONG_NAME_"/"${long}"/g ./roa/lib/config/roa.cfg > ./roa/lib/config/roa.cfg.tmp
mv ./roa/lib/config/roa.cfg.tmp ./roa/lib/config/roa.cfg
#
# make sure perms are ok
#
echo "Updating permissions..."
chmod 770 ./roa/auto*
chmod 770 ./roa/bin/*
#
# Finished!
#
touch ./roa/.setup_complete
echo ""
echo "Installation complete..."
echo ""
set thisdir = `pwd`
set base = ${thisdir}/roa
echo "Notes: Be sure to edit the ${base}/lib/config/roa.cfg file"
echo " and change the _DEF_SPICO_PATH_ text to the following:"
echo " ${spico}"
echo ""
echo " You may also edit this file for any other changes you wish"
echo " to apply to your MUD, such as currency name. Please note"
echo " that everything in the config files is case and spacing "
echo " sensitive! Failure to follow the file formats will lead"
echo " to incorrect MUD functioning."
echo ""
echo "To compile the MUD, "
echo "cd ${base}/src "
echo "make all"
echo "After it finishes make the appropriate changes to the config files,"
echo "cd ${base}/lib/config"
echo "vi roa.cfg"
echo "(make your changes...)"
echo "When you are ready to run the MUD,"
echo "cd ${base}"
echo "./autorun &"
echo "This will execute the autorun script (and MUD) in the background."
echo ""
echo "Good MUDDING!"
echo ""