aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/InstallItAll.sh
diff options
context:
space:
mode:
authoronefang2019-09-11 16:36:50 +1000
committeronefang2019-09-11 16:36:50 +1000
commit50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch)
tree52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /InstallItAll.sh
parentRenamed branch to SledjChisl. (diff)
parentBump to release flavour, build 0. (diff)
downloadopensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz
Merge branch 'SledjChisl'
Diffstat (limited to 'InstallItAll.sh')
-rwxr-xr-xInstallItAll.sh157
1 files changed, 77 insertions, 80 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh
index 81ff54f..8f9df11 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.8.2.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,81 +34,94 @@ 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 nant 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 install mariadb-server tmux mono-complete mono-devel nunit uuid-runtime monit
43# nant is done separately, coz it was removed from Debian for some mysterious reason.
44sudo apt install nant
55sudo /etc/init.d/mysql restart 45sudo /etc/init.d/mysql restart
56 46
57echo "Setting up OpenSim users." 47
48echo "Setting up OpenSim users. This next prompt asks for your MySQL root users password."
58# "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.
59mysql -u root -p -h localhost << zzzzEOFzzz 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
60create database if not exists $MYSQL_DB; 53create database if not exists $MYSQL_DB;
61create user $OS_USER identified by '$MYSQL_PASSWORD'; 54create user if not exists '$MYSQL_USER' identified by '$MYSQL_PASSWORD';
62create user $OS_USER@localhost identified by '$MYSQL_PASSWORD'; 55create user if not exists '$MYSQL_USER'@localhost identified by '$MYSQL_PASSWORD';
63grant all on $MYSQL_DB.* to $OS_USER; 56grant all on $MYSQL_DB.* to '$MYSQL_USER';
64grant all on $MYSQL_DB.* to $OS_USER@localhost; 57grant all on $MYSQL_DB.* to '$MYSQL_USER'@localhost;
65FLUSH PRIVILEGES; 58FLUSH PRIVILEGES;
66zzzzEOFzzz 59zzzzEOFzzz
67 60
68echo "Setting up OpenSim." 61sudo adduser --system --shell /bin/bash --group ${OS_USER}
69sudo adduser --system --shell /bin/false --group $OS_USER 62sudo addgroup ${USER} ${OS_USER}
70sudo addgroup $USER $OS_USER
71 63
72echo "Building OpenSim."
73./runprebuild.sh
74./nant-color
75#xbuild /target:clean
76#xbuild /p:TargetFrameworkVersion="v4.5"
77 64
78echo "Setting up OpenSim." 65echo "Setting up OpenSim."
79sudo rm -fr $OSPATH/opensim-IG_* 66sudo rm -fr ${OS_PATH}/opensim-SC_*
80sudo mkdir -p $OSPATH/opensim-IG_$OSVER 67sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER}
81sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER 68sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER}
82 69cd ${OS_PATH}
83cd $OSPATH 70if [ ! -h current ]; then
84sudo ln -fs opensim-IG_$OSVER current 71 sudo ln -fs opensim-SC_${OS_VER} current
72fi
85 73
86cd current 74cd current
87
88for dir in AssetFiles backups caches config db logs 75for dir in AssetFiles backups caches config db logs
89do 76do
90 if [ ! -f ../$dir ]; then 77 if [ ! -d ../$dir ]; then
91 sudo cp -fr $dir .. 78 sudo cp -fr example/$dir ..
92 sudo rm -fr $dir
93 sudo ln -fs ../$dir $dir
94 fi 79 fi
95done 80done
96 81
97pushd config/ROBUST >/dev/null 82pushd ../config/ROBUST >/dev/null
98sudo ln -fs ../../current/scripts/common.sh common.sh 83sudo ln -fs ../../current/scripts/common.sh common.sh
99sudo ln -fs ../../current/scripts/start-sim start-sim 84sudo ln -fs ../../current/scripts/start-sim start-sim
100sudo ln -fs ../../current/scripts/start-sim stop-sim 85sudo ln -fs ../../current/scripts/start-sim stop-sim
86sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf
101popd >/dev/null 87popd >/dev/null
102 88
103echo "Securing OpenSim." 89sudo cp bin/config-include/config_* ../config/
104sudo chown -R $OS_USER:$OS_USER $OSPATH 90sudo ln -fs config_localhost.ini ../config/config.ini
105sudo chmod -R 775 $OSPATH 91sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini
106sudo chmod -R a-x $OSPATH 92sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini
107sudo chmod -R a+X $OSPATH 93sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini
108sudo chmod -R g+w $OSPATH 94
109sudo chmod -R a+x $OSPATH/current/scripts/*.sh 95sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini
110sudo chmod a+x $OSPATH/current/scripts/show-console 96sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini
111sudo chmod a+x $OSPATH/current/scripts/start-sim 97sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini
112 98
113sudo chmod ug+rwx $OSPATH/config 99sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini
114sudo chmod g+s $OSPATH/config 100sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini
115sudo chmod 600 $OSPATH/config/config.ini 101sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini
116 102
117sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini 103sudo chmod 600 ../config/*.ini
118sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini 104sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini
119sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini 105sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini
120sudo chmod 600 config/config.ini 106sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini
121sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini 107sudo chmod 600 ../config/*.ini
122sudo chmod 600 config/config.ini 108sudo touch ../config/ROBUST/RobustExtra.ini
123 109sudo chmod 600 ../config/ROBUST/RobustExtra.ini
124sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf 110
125sudo chown $USER /home/$OS_USER/.tmux.conf 111if [ ! -f /home/${OS_USER}/.tmux.conf ]; then
126sudo chmod 644 /home/$OS_USER/.tmux.conf 112 sudo cp scripts/install/opensim.tmux.conf /home/${OS_USER}/.tmux.conf
127 113 sudo chown ${OS_USER}:${OS_USR} /home/${OS_USER}/.tmux.conf
128sudo scripts/fix_var_run.sh 114 sudo chmod 644 /home/${OS_USER}/.tmux.conf
129sudo cat scripts/opensim-crontab.txt | sudo crontab -u $OS_USER - 115fi
116
117
118echo "Building OpenSim."
119sudo chown -R ${USER}:${USER} ${OS_PATH} *
120./BuildIt.sh
121
122
123cd scripts/install
124sudo chmod a+x secure.sh
125sudo ./secure.sh
126
130echo "Done installing OpenSim." 127echo "Done installing OpenSim."