aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/InstallItAll.sh
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-08 22:17:09 +1000
committerDavid Walter Seikel2016-11-08 22:17:09 +1000
commit3c279d6c3b66a7f5ad49e16180b69ffa94513dc5 (patch)
tree796f28d91cbc7339d8c5202c429bad07b4e27cd7 /InstallItAll.sh
parentNew README and TODO I forgot to commit before. (diff)
downloadopensim-SC-3c279d6c3b66a7f5ad49e16180b69ffa94513dc5.zip
opensim-SC-3c279d6c3b66a7f5ad49e16180b69ffa94513dc5.tar.gz
opensim-SC-3c279d6c3b66a7f5ad49e16180b69ffa94513dc5.tar.bz2
opensim-SC-3c279d6c3b66a7f5ad49e16180b69ffa94513dc5.tar.xz
Installation script.
Diffstat (limited to '')
-rwxr-xr-xInstallItAll.sh111
1 files changed, 111 insertions, 0 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh
new file mode 100755
index 0000000..e421d09
--- /dev/null
+++ b/InstallItAll.sh
@@ -0,0 +1,111 @@
1#!/bin/bash
2
3OSPATH="/opt/opensim"
4MYSQL_HOST="localhost"
5MYSQL_DB="InfiniteGrid"
6MYSQL_USER="opensim"
7OS_USER="opensim"
8
9OSVER="8.2.1"
10
11
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
28# This should all be safe for pre existing installs that are being updated.
29
30MYSQL_PASSWORD=$1
31# Try to get old database credentials if they exist.
32if [ -f ${OSPATH}/config/config.ini ]; then
33 # Get the database credentials.
34 declare -A creds
35 while read -d ';' p; do
36 k=$(echo ${p} | cut -d '=' -f 1)
37 v=$(echo ${p} | cut -d '=' -f 2)
38 creds[${k}]="${v}"
39 done < <(sudo grep ConnectionString ${OSPATH}/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.
41
42 MYSQL_HOST="${creds[Data Source]}"
43 MYSQL_DB="${creds[Database]}"
44 MYSQL_USER="${creds[User ID]}"
45 MYSQL_PASSWORD="${creds[Password]}"
46fi
47if [ -z $MYSQL_PASSWORD ]; then
48 MYSQL_PASSWORD="OpenSimSucks${RANDOM}"
49fi
50
51USER=$(whoami)
52
53echo "Installing software."
54sudo apt-get install mysql-server tmux mono-complete uuid-runtime monit mc
55sudo /etc/init.d/mysql restart
56
57echo "Setting up mySQL."
58mysql -u root -p -h localhost << zzzzEOFzzz
59create database if not exists '$MYSQL_DB';
60create user '$OS_USER' identified by '$MYSQL_PASSWORD';
61create user '$OS_USER'@'localhost' identified by '$MYSQL_PASSWORD';
62grant all on $MYSQL_DB.* to '$OS_USER';
63grant all on $MYSQL_DB.* to '$OS_USER'@'localhost';
64FLUSH PRIVILEGES;
65zzzzEOFzzz
66
67echo "Setting up OpenSim."
68sudo adduser --system --shell /bin/false --group $OS_USER
69sudo addgroup $USER $OS_USER
70
71sudo rm -fr $OSPATH/opensim-IG_*
72sudo mkdir -p $OSPATH/opensim-IG_$OSVER
73sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER
74
75cd $OSPATH
76sudo ln -fs opensim-IG_$OSVER current
77
78cd current
79
80sudo chown -R $OS_USER:$OS_USER $OSPATH
81sudo chmod -R 775 $OSPATH
82sudo chmod -R a-x $OSPATH
83sudo chmod -R a+X $OSPATH
84sudo chmod -R g+w $OSPATH
85sudo chmod -R a+x $OSPATH/current/scripts/*.sh
86sudo chmod a+x $OSPATH/current/scripts/show-console
87sudo chmod a+x $OSPATH/current/scripts/start-sim
88sudo chmod ug+rwx config
89sudo chmod g+s config
90sudo chmod 600 config/config.ini
91
92for dir in AssetFiles backups caches config db logs
93do
94 sudo cp -fr $dir ..
95 sudo rm -fr $dir
96 sudo ln -fs ../$dir $dir
97done
98
99sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini
100sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini
101sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini
102sudo chmod 600 config/config.ini
103sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini
104sudo chmod 600 config/config.ini
105
106sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf
107sudo chown $USER /home/$OS_USER/.tmux.conf
108sudo chmod 644 /home/$OS_USER/.tmux.conf
109
110sudo scripts/fix_var_run.sh
111sudo cat scripts/opensim-crontab.txt | sudo crontab -u $OS_USER -