aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/InstallItAll.sh
diff options
context:
space:
mode:
Diffstat (limited to 'InstallItAll.sh')
-rwxr-xr-xInstallItAll.sh132
1 files changed, 132 insertions, 0 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh
new file mode 100755
index 0000000..a0f1e0f
--- /dev/null
+++ b/InstallItAll.sh
@@ -0,0 +1,132 @@
1#!/bin/bash
2
3MYSQL_HOST="localhost"
4MYSQL_DB="opensim_SC"
5MYSQL_USER="opensim_SC"
6
7OS_VER="0.9.0.1"
8
9source scripts/common.sh
10getPrgDir
11
12# This should all be safe for pre existing installs that are being updated.
13
14MYSQL_PASSWORD=$1
15# Try to get old database credentials if they exist.
16if [ -f ${OS_PATH}/config/config.ini ]; then
17 # Get the database credentials.
18 declare -A creds
19 while read -d ';' p; do
20 k=$(echo ${p} | cut -d '=' -f 1)
21 v=$(echo ${p} | cut -d '=' -f 2)
22 creds[${k}]="${v}"
23 done < <(sudo grep ConnectionString ${OS_PATH}/config/config.ini | cut -d '"' -f 2)
24 # The above seems the best way to get bash to let the creds assignments survive outside the loop.
25
26 MYSQL_HOST="${creds[Data Source]}"
27 MYSQL_DB="${creds[Database]}"
28 MYSQL_USER="${creds[User ID]}"
29 MYSQL_PASSWORD="${creds[Password]}"
30fi
31if [ -z $MYSQL_PASSWORD ]; then
32 MYSQL_PASSWORD="OpenSimSucks${RANDOM}"
33fi
34
35USER=$(whoami)
36
37echo "Installing into ${OS_PATH}, as user ${OS_USER} ."
38echo "Using MySQL host:${MYSQL_HOST} database:${MYSQL_DB} user:${MYSQL_USER} password:${MYSQL_PASSWORD} ."
39
40
41echo "Installing and compiling software."
42sudo apt install mariadb-server libmariadbclient-dev tmux mono-complete mono-devel nunit uuid-runtime uuid-dev libapache2-mod-fcgid libssl1.0-dev spawn-fcgi
43# nant is done separately, coz it was removed from Debian for some mysterious reason.
44sudo apt install nant
45sudo /etc/init.d/mysql restart
46
47
48echo "Setting up OpenSim users. This next prompt asks for your MySQL root users password."
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.
50# Recent Debian based systems install with a passwordless root account, but it only works if run as the OS root user.
51# Otherwise you can't get in. Yep, the -p seems to still be needed.
52sudo mysql -u root -p -h localhost << zzzzEOFzzz
53create database if not exists $MYSQL_DB;
54create user if not exists '$MYSQL_USER' identified by '$MYSQL_PASSWORD';
55create user if not exists '$MYSQL_USER'@localhost identified by '$MYSQL_PASSWORD';
56grant all on $MYSQL_DB.* to '$MYSQL_USER';
57grant all on $MYSQL_DB.* to '$MYSQL_USER'@localhost;
58FLUSH PRIVILEGES;
59zzzzEOFzzz
60
61sudo adduser --system --shell /bin/bash --group ${OS_USER}
62sudo addgroup ${USER} ${OS_USER}
63
64
65echo "Setting up OpenSim."
66sudo rm -fr ${OS_PATH}/opensim-SC_*
67sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER}
68sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER}
69cd ${OS_PATH}
70if [ ! -h current ]; then
71 sudo ln -fs opensim-SC_${OS_VER} current
72fi
73
74cd current
75for dir in AssetFiles backups caches config db logs
76do
77 if [ ! -d ../$dir ]; then
78 sudo cp -fr example/$dir ..
79 fi
80done
81
82pushd ../config/ROBUST >/dev/null
83sudo ln -fs ../../current/scripts/common.sh common.sh
84sudo ln -fs ../../current/scripts/start-sim start-sim
85sudo ln -fs ../../current/scripts/start-sim stop-sim
86sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf
87popd >/dev/null
88
89sudo cp bin/config-include/config_* ../config/
90sudo ln -fs config_localhost.ini ../config/config.ini
91sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_DG.ini
92sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_DG.ini
93sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_DG.ini
94
95sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini
96sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini
97sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini
98
99sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini
100sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini
101sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini
102
103sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini
104sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini
105sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini
106
107sudo chmod 600 ../config/*.ini
108sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_DG.ini
109sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini
110sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini
111sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini
112sudo chmod 600 ../config/*.ini
113sudo touch ../config/ROBUST/RobustExtra.ini
114sudo chmod 600 ../config/ROBUST/RobustExtra.ini
115
116if [ ! -f /home/${OS_USER}/.tmux.conf ]; then
117 sudo cp scripts/install/opensim.tmux.conf /home/${OS_USER}/.tmux.conf
118 sudo chown ${OS_USER}:${OS_USR} /home/${OS_USER}/.tmux.conf
119 sudo chmod 644 /home/${OS_USER}/.tmux.conf
120fi
121
122
123echo "Building OpenSim."
124sudo chown -R ${USER}:${USER} ${OS_PATH} *
125./BuildIt.sh
126
127
128cd scripts/install
129sudo chmod a+x secure.sh
130sudo ./secure.sh
131
132echo "Done installing OpenSim."