diff options
Diffstat (limited to 'InstallItAll.sh')
-rwxr-xr-x | InstallItAll.sh | 132 |
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 | |||
3 | MYSQL_HOST="localhost" | ||
4 | MYSQL_DB="opensim_SC" | ||
5 | MYSQL_USER="opensim_SC" | ||
6 | |||
7 | OS_VER="0.9.0.1" | ||
8 | |||
9 | source scripts/common.sh | ||
10 | getPrgDir | ||
11 | |||
12 | # This should all be safe for pre existing installs that are being updated. | ||
13 | |||
14 | MYSQL_PASSWORD=$1 | ||
15 | # Try to get old database credentials if they exist. | ||
16 | if [ -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]}" | ||
30 | fi | ||
31 | if [ -z $MYSQL_PASSWORD ]; then | ||
32 | MYSQL_PASSWORD="OpenSimSucks${RANDOM}" | ||
33 | fi | ||
34 | |||
35 | USER=$(whoami) | ||
36 | |||
37 | echo "Installing into ${OS_PATH}, as user ${OS_USER} ." | ||
38 | echo "Using MySQL host:${MYSQL_HOST} database:${MYSQL_DB} user:${MYSQL_USER} password:${MYSQL_PASSWORD} ." | ||
39 | |||
40 | |||
41 | echo "Installing and compiling software." | ||
42 | sudo 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. | ||
44 | sudo apt install nant | ||
45 | sudo /etc/init.d/mysql restart | ||
46 | |||
47 | |||
48 | echo "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. | ||
52 | sudo mysql -u root -p -h localhost << zzzzEOFzzz | ||
53 | create database if not exists $MYSQL_DB; | ||
54 | create user if not exists '$MYSQL_USER' identified by '$MYSQL_PASSWORD'; | ||
55 | create user if not exists '$MYSQL_USER'@localhost identified by '$MYSQL_PASSWORD'; | ||
56 | grant all on $MYSQL_DB.* to '$MYSQL_USER'; | ||
57 | grant all on $MYSQL_DB.* to '$MYSQL_USER'@localhost; | ||
58 | FLUSH PRIVILEGES; | ||
59 | zzzzEOFzzz | ||
60 | |||
61 | sudo adduser --system --shell /bin/bash --group ${OS_USER} | ||
62 | sudo addgroup ${USER} ${OS_USER} | ||
63 | |||
64 | |||
65 | echo "Setting up OpenSim." | ||
66 | sudo rm -fr ${OS_PATH}/opensim-SC_* | ||
67 | sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER} | ||
68 | sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER} | ||
69 | cd ${OS_PATH} | ||
70 | if [ ! -h current ]; then | ||
71 | sudo ln -fs opensim-SC_${OS_VER} current | ||
72 | fi | ||
73 | |||
74 | cd current | ||
75 | for dir in AssetFiles backups caches config db logs | ||
76 | do | ||
77 | if [ ! -d ../$dir ]; then | ||
78 | sudo cp -fr example/$dir .. | ||
79 | fi | ||
80 | done | ||
81 | |||
82 | pushd ../config/ROBUST >/dev/null | ||
83 | sudo ln -fs ../../current/scripts/common.sh common.sh | ||
84 | sudo ln -fs ../../current/scripts/start-sim start-sim | ||
85 | sudo ln -fs ../../current/scripts/start-sim stop-sim | ||
86 | sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf | ||
87 | popd >/dev/null | ||
88 | |||
89 | sudo cp bin/config-include/config_* ../config/ | ||
90 | sudo ln -fs config_localhost.ini ../config/config.ini | ||
91 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_DG.ini | ||
92 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_DG.ini | ||
93 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_DG.ini | ||
94 | |||
95 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini | ||
96 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini | ||
97 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini | ||
98 | |||
99 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini | ||
100 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini | ||
101 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini | ||
102 | |||
103 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini | ||
104 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini | ||
105 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini | ||
106 | |||
107 | sudo chmod 600 ../config/*.ini | ||
108 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_DG.ini | ||
109 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini | ||
110 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini | ||
111 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini | ||
112 | sudo chmod 600 ../config/*.ini | ||
113 | sudo touch ../config/ROBUST/RobustExtra.ini | ||
114 | sudo chmod 600 ../config/ROBUST/RobustExtra.ini | ||
115 | |||
116 | if [ ! -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 | ||
120 | fi | ||
121 | |||
122 | |||
123 | echo "Building OpenSim." | ||
124 | sudo chown -R ${USER}:${USER} ${OS_PATH} * | ||
125 | ./BuildIt.sh | ||
126 | |||
127 | |||
128 | cd scripts/install | ||
129 | sudo chmod a+x secure.sh | ||
130 | sudo ./secure.sh | ||
131 | |||
132 | echo "Done installing OpenSim." | ||