diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /InstallItAll.sh | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to 'InstallItAll.sh')
-rwxr-xr-x | InstallItAll.sh | 157 |
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 | ||
3 | OSPATH="/opt/opensim" | ||
4 | MYSQL_HOST="localhost" | 3 | MYSQL_HOST="localhost" |
5 | MYSQL_DB="InfiniteGrid" | 4 | MYSQL_DB="opensim_SC" |
6 | MYSQL_USER="opensim" | 5 | MYSQL_USER="opensim_SC" |
7 | OS_USER="opensim" | 6 | |
8 | 7 | OS_VER="0.9.0.1" | |
9 | OSVER="0.8.2.1" | 8 | |
10 | 9 | source scripts/common.sh | |
11 | 10 | getPrgDir | |
12 | # Figure out where we are, most of this mess is to troll through soft links. | ||
13 | PRG="$0" | ||
14 | while [ -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 | ||
22 | done | ||
23 | PRGDIR=$(dirname "${PRG}") | ||
24 | pushd ${PRGDIR} >/dev/null | ||
25 | PRGDIR=$(pwd) | ||
26 | popd >/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 | ||
30 | MYSQL_PASSWORD=$1 | 14 | MYSQL_PASSWORD=$1 |
31 | # Try to get old database credentials if they exist. | 15 | # Try to get old database credentials if they exist. |
32 | if [ -f ${OSPATH}/config/config.ini ]; then | 16 | if [ -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 | ||
51 | USER=$(whoami) | 35 | USER=$(whoami) |
52 | 36 | ||
53 | echo "Installing software." | 37 | echo "Installing into ${OS_PATH}, as user ${OS_USER} ." |
54 | sudo apt-get install mysql-server tmux mono-complete mono-gmcs nant nunit uuid-runtime monit mc | 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 tmux mono-complete mono-devel nunit uuid-runtime monit | ||
43 | # nant is done separately, coz it was removed from Debian for some mysterious reason. | ||
44 | sudo apt install nant | ||
55 | sudo /etc/init.d/mysql restart | 45 | sudo /etc/init.d/mysql restart |
56 | 46 | ||
57 | echo "Setting up OpenSim users." | 47 | |
48 | echo "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. |
59 | mysql -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. | ||
52 | sudo mysql -u root -p -h localhost << zzzzEOFzzz | ||
60 | create database if not exists $MYSQL_DB; | 53 | create database if not exists $MYSQL_DB; |
61 | create user $OS_USER identified by '$MYSQL_PASSWORD'; | 54 | create user if not exists '$MYSQL_USER' identified by '$MYSQL_PASSWORD'; |
62 | create user $OS_USER@localhost identified by '$MYSQL_PASSWORD'; | 55 | create user if not exists '$MYSQL_USER'@localhost identified by '$MYSQL_PASSWORD'; |
63 | grant all on $MYSQL_DB.* to $OS_USER; | 56 | grant all on $MYSQL_DB.* to '$MYSQL_USER'; |
64 | grant all on $MYSQL_DB.* to $OS_USER@localhost; | 57 | grant all on $MYSQL_DB.* to '$MYSQL_USER'@localhost; |
65 | FLUSH PRIVILEGES; | 58 | FLUSH PRIVILEGES; |
66 | zzzzEOFzzz | 59 | zzzzEOFzzz |
67 | 60 | ||
68 | echo "Setting up OpenSim." | 61 | sudo adduser --system --shell /bin/bash --group ${OS_USER} |
69 | sudo adduser --system --shell /bin/false --group $OS_USER | 62 | sudo addgroup ${USER} ${OS_USER} |
70 | sudo addgroup $USER $OS_USER | ||
71 | 63 | ||
72 | echo "Building OpenSim." | ||
73 | ./runprebuild.sh | ||
74 | ./nant-color | ||
75 | #xbuild /target:clean | ||
76 | #xbuild /p:TargetFrameworkVersion="v4.5" | ||
77 | 64 | ||
78 | echo "Setting up OpenSim." | 65 | echo "Setting up OpenSim." |
79 | sudo rm -fr $OSPATH/opensim-IG_* | 66 | sudo rm -fr ${OS_PATH}/opensim-SC_* |
80 | sudo mkdir -p $OSPATH/opensim-IG_$OSVER | 67 | sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER} |
81 | sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER | 68 | sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER} |
82 | 69 | cd ${OS_PATH} | |
83 | cd $OSPATH | 70 | if [ ! -h current ]; then |
84 | sudo ln -fs opensim-IG_$OSVER current | 71 | sudo ln -fs opensim-SC_${OS_VER} current |
72 | fi | ||
85 | 73 | ||
86 | cd current | 74 | cd current |
87 | |||
88 | for dir in AssetFiles backups caches config db logs | 75 | for dir in AssetFiles backups caches config db logs |
89 | do | 76 | do |
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 |
95 | done | 80 | done |
96 | 81 | ||
97 | pushd config/ROBUST >/dev/null | 82 | pushd ../config/ROBUST >/dev/null |
98 | sudo ln -fs ../../current/scripts/common.sh common.sh | 83 | sudo ln -fs ../../current/scripts/common.sh common.sh |
99 | sudo ln -fs ../../current/scripts/start-sim start-sim | 84 | sudo ln -fs ../../current/scripts/start-sim start-sim |
100 | sudo ln -fs ../../current/scripts/start-sim stop-sim | 85 | sudo ln -fs ../../current/scripts/start-sim stop-sim |
86 | sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf | ||
101 | popd >/dev/null | 87 | popd >/dev/null |
102 | 88 | ||
103 | echo "Securing OpenSim." | 89 | sudo cp bin/config-include/config_* ../config/ |
104 | sudo chown -R $OS_USER:$OS_USER $OSPATH | 90 | sudo ln -fs config_localhost.ini ../config/config.ini |
105 | sudo chmod -R 775 $OSPATH | 91 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini |
106 | sudo chmod -R a-x $OSPATH | 92 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini |
107 | sudo chmod -R a+X $OSPATH | 93 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini |
108 | sudo chmod -R g+w $OSPATH | 94 | |
109 | sudo chmod -R a+x $OSPATH/current/scripts/*.sh | 95 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini |
110 | sudo chmod a+x $OSPATH/current/scripts/show-console | 96 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini |
111 | sudo chmod a+x $OSPATH/current/scripts/start-sim | 97 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini |
112 | 98 | ||
113 | sudo chmod ug+rwx $OSPATH/config | 99 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini |
114 | sudo chmod g+s $OSPATH/config | 100 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini |
115 | sudo chmod 600 $OSPATH/config/config.ini | 101 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini |
116 | 102 | ||
117 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini | 103 | sudo chmod 600 ../config/*.ini |
118 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini | 104 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini |
119 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini | 105 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini |
120 | sudo chmod 600 config/config.ini | 106 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini |
121 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini | 107 | sudo chmod 600 ../config/*.ini |
122 | sudo chmod 600 config/config.ini | 108 | sudo touch ../config/ROBUST/RobustExtra.ini |
123 | 109 | sudo chmod 600 ../config/ROBUST/RobustExtra.ini | |
124 | sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf | 110 | |
125 | sudo chown $USER /home/$OS_USER/.tmux.conf | 111 | if [ ! -f /home/${OS_USER}/.tmux.conf ]; then |
126 | sudo 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 | |
128 | sudo scripts/fix_var_run.sh | 114 | sudo chmod 644 /home/${OS_USER}/.tmux.conf |
129 | sudo cat scripts/opensim-crontab.txt | sudo crontab -u $OS_USER - | 115 | fi |
116 | |||
117 | |||
118 | echo "Building OpenSim." | ||
119 | sudo chown -R ${USER}:${USER} ${OS_PATH} * | ||
120 | ./BuildIt.sh | ||
121 | |||
122 | |||
123 | cd scripts/install | ||
124 | sudo chmod a+x secure.sh | ||
125 | sudo ./secure.sh | ||
126 | |||
130 | echo "Done installing OpenSim." | 127 | echo "Done installing OpenSim." |