aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/InstallItAll.sh
diff options
context:
space:
mode:
authoronefang2019-05-22 19:14:35 +1000
committeronefang2019-05-22 19:14:35 +1000
commitca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5 (patch)
tree9b4dfc525c31a88014a8d7d6c223e7cd452749c6 /InstallItAll.sh
parentRenamed branch to SledjChisl. (diff)
downloadopensim-SC_OLD-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.zip
opensim-SC_OLD-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.gz
opensim-SC_OLD-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.bz2
opensim-SC_OLD-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.xz
Major tweaking of the scripts to suit the new setup.
Diffstat (limited to 'InstallItAll.sh')
-rwxr-xr-xInstallItAll.sh137
1 files changed, 67 insertions, 70 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh
index 0568709..6467ff8 100755
--- a/InstallItAll.sh
+++ b/InstallItAll.sh
@@ -1,42 +1,26 @@
1#!/bin/bash 1#!/bin/bash
2 2
3OSPATH="/opt/opensim"
4MYSQL_HOST="localhost" 3MYSQL_HOST="localhost"
5MYSQL_DB="InfiniteGrid" 4MYSQL_DB="opensim_SC"
6MYSQL_USER="opensim" 5MYSQL_USER="opensim_SC"
7OS_USER="opensim" 6
8 7OS_VER="0.9.0.1"
9OSVER="0.9.0.1" 8
10 9source scripts/common.sh
11 10getPrgDir
12# Figure out where we are, most of this mess is to troll through soft links.
13PRG="$0"
14while [ -h "${PRG}" ] ; do
15 ls=$(ls -ld "${PRG}")
16 link=`expr "${ls}" : '.*-> \(.*\)$'`
17 if expr "${link}" : '.*/.*' > /dev/null; then
18 PRG="${link}"
19 else
20 PRG=$(dirname "${PRG}")/"${link}"
21 fi
22done
23PRGDIR=$(dirname "${PRG}")
24pushd ${PRGDIR} >/dev/null
25PRGDIR=$(pwd)
26popd >/dev/null
27 11
28# This should all be safe for pre existing installs that are being updated. 12# This should all be safe for pre existing installs that are being updated.
29 13
30MYSQL_PASSWORD=$1 14MYSQL_PASSWORD=$1
31# Try to get old database credentials if they exist. 15# Try to get old database credentials if they exist.
32if [ -f ${OSPATH}/config/config.ini ]; then 16if [ -f ${OS_PATH}/config/config.ini ]; then
33 # Get the database credentials. 17 # Get the database credentials.
34 declare -A creds 18 declare -A creds
35 while read -d ';' p; do 19 while read -d ';' p; do
36 k=$(echo ${p} | cut -d '=' -f 1) 20 k=$(echo ${p} | cut -d '=' -f 1)
37 v=$(echo ${p} | cut -d '=' -f 2) 21 v=$(echo ${p} | cut -d '=' -f 2)
38 creds[${k}]="${v}" 22 creds[${k}]="${v}"
39 done < <(sudo grep ConnectionString ${OSPATH}/config/config.ini | cut -d '"' -f 2) 23 done < <(sudo grep ConnectionString ${OS_PATH}/config/config.ini | cut -d '"' -f 2)
40 # The above seems the best way to get bash to let the creds assignments survive outside the loop. 24 # The above seems the best way to get bash to let the creds assignments survive outside the loop.
41 25
42 MYSQL_HOST="${creds[Data Source]}" 26 MYSQL_HOST="${creds[Data Source]}"
@@ -50,76 +34,89 @@ fi
50 34
51USER=$(whoami) 35USER=$(whoami)
52 36
53echo "Installing software." 37echo "Installing into ${OS_PATH}, as user ${OS_USER} ."
54sudo apt-get install mysql-server tmux mono-complete mono-gmcs nunit uuid-runtime monit mc 38echo "Using MySQL host:${MYSQL_HOST} database:${MYSQL_DB} user:${MYSQL_USER} password:${MYSQL_PASSWORD} ."
39
40
41echo "Installing and compiling software."
42sudo apt-get install mariadb-server tmux mono-complete mono-devel nunit uuid-runtime monit
55# nant is done separately, coz it was removed from Debian for some mysterious reason. 43# nant is done separately, coz it was removed from Debian for some mysterious reason.
56sudo apt-get install nant 44sudo apt-get install nant
57sudo /etc/init.d/mysql restart 45sudo /etc/init.d/mysql restart
58 46
59echo "Setting up OpenSim users." 47
48echo "Setting up OpenSim users. This next prompt asks for your MySQL root users password."
60# "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. 49# "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.
61mysql -u root -p -h localhost << zzzzEOFzzz 50mysql -u root -p -h localhost << zzzzEOFzzz
62create database if not exists $MYSQL_DB; 51create database if not exists $MYSQL_DB;
63create user $OS_USER identified by '$MYSQL_PASSWORD'; 52create user '$OS_USER' identified by '$MYSQL_PASSWORD';
64create user $OS_USER@localhost identified by '$MYSQL_PASSWORD'; 53create user '$OS_USER'@localhost identified by '$MYSQL_PASSWORD';
65grant all on $MYSQL_DB.* to $OS_USER; 54grant all on $MYSQL_DB.* to '$OS_USER';
66grant all on $MYSQL_DB.* to $OS_USER@localhost; 55grant all on $MYSQL_DB.* to '$OS_USER'@localhost;
67FLUSH PRIVILEGES; 56FLUSH PRIVILEGES;
68zzzzEOFzzz 57zzzzEOFzzz
69 58
70echo "Setting up OpenSim." 59sudo adduser --system --shell /bin/false --group ${OS_USER}
71sudo adduser --system --shell /bin/false --group $OS_USER 60sudo addgroup ${USER} ${OS_USER}
72sudo addgroup $USER $OS_USER
73 61
74echo "Building OpenSim."
75./BuildIt.sh
76 62
77echo "Setting up OpenSim." 63echo "Setting up OpenSim."
78sudo rm -fr $OSPATH/opensim-IG_* 64sudo rm -fr ${OS_PATH}/opensim-SC_*
79sudo mkdir -p $OSPATH/opensim-IG_$OSVER 65sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER}
80sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER 66sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER}
81 67cd ${OS_PATH}
82cd $OSPATH 68if [ ! -h current ]; then
83sudo ln -fs opensim-IG_$OSVER current 69 sudo ln -fs opensim-SC_${OS_VER} current
70fi
84 71
85cd current 72cd current
86
87for dir in AssetFiles backups caches config db logs 73for dir in AssetFiles backups caches config db logs
88do 74do
89 if [ ! -f ../$dir ]; then 75 if [ ! -d ../$dir ]; then
90 sudo cp -fr example/$dir .. 76 sudo cp -fr example/$dir ..
91 fi 77 fi
92done 78done
93 79
94pushd config/ROBUST >/dev/null 80pushd ../config/ROBUST >/dev/null
95sudo ln -fs ../../current/scripts/common.sh common.sh 81sudo ln -fs ../../current/scripts/common.sh common.sh
96sudo ln -fs ../../current/scripts/start-sim start-sim 82sudo ln -fs ../../current/scripts/start-sim start-sim
97sudo ln -fs ../../current/scripts/start-sim stop-sim 83sudo ln -fs ../../current/scripts/start-sim stop-sim
84sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf
98popd >/dev/null 85popd >/dev/null
99 86
100echo "Securing OpenSim." 87sudo cp bin/config-include/config_* ../config/
101sudo chown -R $OS_USER:$OS_USER $OSPATH 88sudo ln -fs config_localhost.ini ../config/config.ini
102sudo chmod -R 775 $OSPATH 89sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini
103sudo chmod -R a-x $OSPATH 90sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini
104sudo chmod -R a+X $OSPATH 91sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini
105sudo chmod -R g+w $OSPATH 92
106sudo chmod -R a+x $OSPATH/current/scripts/*.sh 93sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini
107sudo chmod a+x $OSPATH/current/scripts/show-console 94sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini
108sudo chmod a+x $OSPATH/current/scripts/start-sim 95sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini
109 96
110sudo chmod ug+rwx $OSPATH/config 97sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini
111sudo chmod g+s $OSPATH/config 98sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini
112sudo chmod 600 $OSPATH/config/config.ini 99sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini
113 100
114sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini 101sudo chmod 600 ../config/*.ini
115sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini 102sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini
116sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini 103sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini
117sudo chmod 600 config/config.ini 104sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini
118sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini 105sudo chmod 600 ../config/*.ini
119sudo chmod 600 config/config.ini 106
120 107if [ ! -f /home/${OS_USER}/.tmux.conf ]; then
121sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf 108 sudo cp scripts/install/opensim.tmux.conf /home/${OS_USER}/.tmux.conf
122sudo chown $USER /home/$OS_USER/.tmux.conf 109 sudo chown ${OS_USER}:${OS_USR} /home/${OS_USER}/.tmux.conf
123sudo chmod 644 /home/$OS_USER/.tmux.conf 110 sudo chmod 644 /home/${OS_USER}/.tmux.conf
111fi
112
113
114echo "Building OpenSim."
115sudo chown -R ${USER}:${USER} ${OS_PATH} *
116./BuildIt.sh
117
118
119cd scripts/install
120sudo ./secure.sh
124 121
125echo "Done installing OpenSim." 122echo "Done installing OpenSim."