From ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 22 May 2019 19:14:35 +1000 Subject: Major tweaking of the scripts to suit the new setup. --- InstallItAll.sh | 137 +++++++++++++++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 70 deletions(-) (limited to 'InstallItAll.sh') diff --git a/InstallItAll.sh b/InstallItAll.sh index 0568709..6467ff8 100755 --- a/InstallItAll.sh +++ b/InstallItAll.sh @@ -1,42 +1,26 @@ #!/bin/bash -OSPATH="/opt/opensim" MYSQL_HOST="localhost" -MYSQL_DB="InfiniteGrid" -MYSQL_USER="opensim" -OS_USER="opensim" - -OSVER="0.9.0.1" - - -# Figure out where we are, most of this mess is to troll through soft links. -PRG="$0" -while [ -h "${PRG}" ] ; do - ls=$(ls -ld "${PRG}") - link=`expr "${ls}" : '.*-> \(.*\)$'` - if expr "${link}" : '.*/.*' > /dev/null; then - PRG="${link}" - else - PRG=$(dirname "${PRG}")/"${link}" - fi -done -PRGDIR=$(dirname "${PRG}") -pushd ${PRGDIR} >/dev/null -PRGDIR=$(pwd) -popd >/dev/null +MYSQL_DB="opensim_SC" +MYSQL_USER="opensim_SC" + +OS_VER="0.9.0.1" + +source scripts/common.sh +getPrgDir # This should all be safe for pre existing installs that are being updated. MYSQL_PASSWORD=$1 # Try to get old database credentials if they exist. -if [ -f ${OSPATH}/config/config.ini ]; then +if [ -f ${OS_PATH}/config/config.ini ]; then # Get the database credentials. declare -A creds while read -d ';' p; do k=$(echo ${p} | cut -d '=' -f 1) v=$(echo ${p} | cut -d '=' -f 2) creds[${k}]="${v}" - done < <(sudo grep ConnectionString ${OSPATH}/config/config.ini | cut -d '"' -f 2) + done < <(sudo grep ConnectionString ${OS_PATH}/config/config.ini | cut -d '"' -f 2) # The above seems the best way to get bash to let the creds assignments survive outside the loop. MYSQL_HOST="${creds[Data Source]}" @@ -50,76 +34,89 @@ fi USER=$(whoami) -echo "Installing software." -sudo apt-get install mysql-server tmux mono-complete mono-gmcs nunit uuid-runtime monit mc +echo "Installing into ${OS_PATH}, as user ${OS_USER} ." +echo "Using MySQL host:${MYSQL_HOST} database:${MYSQL_DB} user:${MYSQL_USER} password:${MYSQL_PASSWORD} ." + + +echo "Installing and compiling software." +sudo apt-get install mariadb-server tmux mono-complete mono-devel nunit uuid-runtime monit # nant is done separately, coz it was removed from Debian for some mysterious reason. sudo apt-get install nant sudo /etc/init.d/mysql restart -echo "Setting up OpenSim users." + +echo "Setting up OpenSim users. This next prompt asks for your MySQL root users password." # "create user if not exists" doesn't exist until MySQL 5.7, so we have to put up with a warning, which we can ignore. mysql -u root -p -h localhost << zzzzEOFzzz create database if not exists $MYSQL_DB; -create user $OS_USER identified by '$MYSQL_PASSWORD'; -create user $OS_USER@localhost identified by '$MYSQL_PASSWORD'; -grant all on $MYSQL_DB.* to $OS_USER; -grant all on $MYSQL_DB.* to $OS_USER@localhost; +create user '$OS_USER' identified by '$MYSQL_PASSWORD'; +create user '$OS_USER'@localhost identified by '$MYSQL_PASSWORD'; +grant all on $MYSQL_DB.* to '$OS_USER'; +grant all on $MYSQL_DB.* to '$OS_USER'@localhost; FLUSH PRIVILEGES; zzzzEOFzzz -echo "Setting up OpenSim." -sudo adduser --system --shell /bin/false --group $OS_USER -sudo addgroup $USER $OS_USER +sudo adduser --system --shell /bin/false --group ${OS_USER} +sudo addgroup ${USER} ${OS_USER} -echo "Building OpenSim." -./BuildIt.sh echo "Setting up OpenSim." -sudo rm -fr $OSPATH/opensim-IG_* -sudo mkdir -p $OSPATH/opensim-IG_$OSVER -sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER - -cd $OSPATH -sudo ln -fs opensim-IG_$OSVER current +sudo rm -fr ${OS_PATH}/opensim-SC_* +sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER} +sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER} +cd ${OS_PATH} +if [ ! -h current ]; then + sudo ln -fs opensim-SC_${OS_VER} current +fi cd current - for dir in AssetFiles backups caches config db logs do - if [ ! -f ../$dir ]; then + if [ ! -d ../$dir ]; then sudo cp -fr example/$dir .. fi done -pushd config/ROBUST >/dev/null +pushd ../config/ROBUST >/dev/null sudo ln -fs ../../current/scripts/common.sh common.sh sudo ln -fs ../../current/scripts/start-sim start-sim sudo ln -fs ../../current/scripts/start-sim stop-sim +sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf popd >/dev/null -echo "Securing OpenSim." -sudo chown -R $OS_USER:$OS_USER $OSPATH -sudo chmod -R 775 $OSPATH -sudo chmod -R a-x $OSPATH -sudo chmod -R a+X $OSPATH -sudo chmod -R g+w $OSPATH -sudo chmod -R a+x $OSPATH/current/scripts/*.sh -sudo chmod a+x $OSPATH/current/scripts/show-console -sudo chmod a+x $OSPATH/current/scripts/start-sim - -sudo chmod ug+rwx $OSPATH/config -sudo chmod g+s $OSPATH/config -sudo chmod 600 $OSPATH/config/config.ini - -sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini -sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini -sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini -sudo chmod 600 config/config.ini -sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini -sudo chmod 600 config/config.ini - -sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf -sudo chown $USER /home/$OS_USER/.tmux.conf -sudo chmod 644 /home/$OS_USER/.tmux.conf +sudo cp bin/config-include/config_* ../config/ +sudo ln -fs config_localhost.ini ../config/config.ini +sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini +sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini +sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini + +sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini +sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini +sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini + +sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini +sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini +sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini + +sudo chmod 600 ../config/*.ini +sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini +sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini +sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini +sudo chmod 600 ../config/*.ini + +if [ ! -f /home/${OS_USER}/.tmux.conf ]; then + sudo cp scripts/install/opensim.tmux.conf /home/${OS_USER}/.tmux.conf + sudo chown ${OS_USER}:${OS_USR} /home/${OS_USER}/.tmux.conf + sudo chmod 644 /home/${OS_USER}/.tmux.conf +fi + + +echo "Building OpenSim." +sudo chown -R ${USER}:${USER} ${OS_PATH} * +./BuildIt.sh + + +cd scripts/install +sudo ./secure.sh echo "Done installing OpenSim." -- cgit v1.1