diff options
author | onefang | 2019-05-22 19:14:35 +1000 |
---|---|---|
committer | onefang | 2019-05-22 19:14:35 +1000 |
commit | ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5 (patch) | |
tree | 9b4dfc525c31a88014a8d7d6c223e7cd452749c6 /InstallItAll.sh | |
parent | Renamed branch to SledjChisl. (diff) | |
download | opensim-SC-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.zip opensim-SC-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.gz opensim-SC-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.bz2 opensim-SC-ca7a2ed839f8fec5a7d7abbf50fc2c031f192fb5.tar.xz |
Major tweaking of the scripts to suit the new setup.
Diffstat (limited to '')
-rwxr-xr-x | InstallItAll.sh | 137 |
1 files changed, 67 insertions, 70 deletions
diff --git a/InstallItAll.sh b/InstallItAll.sh index 0568709..6467ff8 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.9.0.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,76 +34,89 @@ 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 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-get install mariadb-server tmux mono-complete mono-devel nunit uuid-runtime monit | ||
55 | # nant is done separately, coz it was removed from Debian for some mysterious reason. | 43 | # nant is done separately, coz it was removed from Debian for some mysterious reason. |
56 | sudo apt-get install nant | 44 | sudo apt-get install nant |
57 | sudo /etc/init.d/mysql restart | 45 | sudo /etc/init.d/mysql restart |
58 | 46 | ||
59 | echo "Setting up OpenSim users." | 47 | |
48 | echo "Setting up OpenSim users. This next prompt asks for your MySQL root users password." | ||
60 | # "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. |
61 | mysql -u root -p -h localhost << zzzzEOFzzz | 50 | mysql -u root -p -h localhost << zzzzEOFzzz |
62 | create database if not exists $MYSQL_DB; | 51 | create database if not exists $MYSQL_DB; |
63 | create user $OS_USER identified by '$MYSQL_PASSWORD'; | 52 | create user '$OS_USER' identified by '$MYSQL_PASSWORD'; |
64 | create user $OS_USER@localhost identified by '$MYSQL_PASSWORD'; | 53 | create user '$OS_USER'@localhost identified by '$MYSQL_PASSWORD'; |
65 | grant all on $MYSQL_DB.* to $OS_USER; | 54 | grant all on $MYSQL_DB.* to '$OS_USER'; |
66 | grant all on $MYSQL_DB.* to $OS_USER@localhost; | 55 | grant all on $MYSQL_DB.* to '$OS_USER'@localhost; |
67 | FLUSH PRIVILEGES; | 56 | FLUSH PRIVILEGES; |
68 | zzzzEOFzzz | 57 | zzzzEOFzzz |
69 | 58 | ||
70 | echo "Setting up OpenSim." | 59 | sudo adduser --system --shell /bin/false --group ${OS_USER} |
71 | sudo adduser --system --shell /bin/false --group $OS_USER | 60 | sudo addgroup ${USER} ${OS_USER} |
72 | sudo addgroup $USER $OS_USER | ||
73 | 61 | ||
74 | echo "Building OpenSim." | ||
75 | ./BuildIt.sh | ||
76 | 62 | ||
77 | echo "Setting up OpenSim." | 63 | echo "Setting up OpenSim." |
78 | sudo rm -fr $OSPATH/opensim-IG_* | 64 | sudo rm -fr ${OS_PATH}/opensim-SC_* |
79 | sudo mkdir -p $OSPATH/opensim-IG_$OSVER | 65 | sudo mkdir -p ${OS_PATH}/opensim-SC_${OS_VER} |
80 | sudo cp -fr $PRGDIR/* $OSPATH/opensim-IG_$OSVER | 66 | sudo cp -fr $PRGDIR/* ${OS_PATH}/opensim-SC_${OS_VER} |
81 | 67 | cd ${OS_PATH} | |
82 | cd $OSPATH | 68 | if [ ! -h current ]; then |
83 | sudo ln -fs opensim-IG_$OSVER current | 69 | sudo ln -fs opensim-SC_${OS_VER} current |
70 | fi | ||
84 | 71 | ||
85 | cd current | 72 | cd current |
86 | |||
87 | for dir in AssetFiles backups caches config db logs | 73 | for dir in AssetFiles backups caches config db logs |
88 | do | 74 | do |
89 | if [ ! -f ../$dir ]; then | 75 | if [ ! -d ../$dir ]; then |
90 | sudo cp -fr example/$dir .. | 76 | sudo cp -fr example/$dir .. |
91 | fi | 77 | fi |
92 | done | 78 | done |
93 | 79 | ||
94 | pushd config/ROBUST >/dev/null | 80 | pushd ../config/ROBUST >/dev/null |
95 | sudo ln -fs ../../current/scripts/common.sh common.sh | 81 | sudo ln -fs ../../current/scripts/common.sh common.sh |
96 | sudo ln -fs ../../current/scripts/start-sim start-sim | 82 | sudo ln -fs ../../current/scripts/start-sim start-sim |
97 | sudo ln -fs ../../current/scripts/start-sim stop-sim | 83 | sudo ln -fs ../../current/scripts/start-sim stop-sim |
84 | sudo sed -i "s@OS_PATH@${OS_PATH}@g" opensim-monit.conf | ||
98 | popd >/dev/null | 85 | popd >/dev/null |
99 | 86 | ||
100 | echo "Securing OpenSim." | 87 | sudo cp bin/config-include/config_* ../config/ |
101 | sudo chown -R $OS_USER:$OS_USER $OSPATH | 88 | sudo ln -fs config_localhost.ini ../config/config.ini |
102 | sudo chmod -R 775 $OSPATH | 89 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_IG.ini |
103 | sudo chmod -R a-x $OSPATH | 90 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_IG.ini |
104 | sudo chmod -R a+X $OSPATH | 91 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_IG.ini |
105 | sudo chmod -R g+w $OSPATH | 92 | |
106 | sudo chmod -R a+x $OSPATH/current/scripts/*.sh | 93 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_MG.ini |
107 | sudo chmod a+x $OSPATH/current/scripts/show-console | 94 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_MG.ini |
108 | sudo chmod a+x $OSPATH/current/scripts/start-sim | 95 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_MG.ini |
109 | 96 | ||
110 | sudo chmod ug+rwx $OSPATH/config | 97 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" ../config/config_localhost.ini |
111 | sudo chmod g+s $OSPATH/config | 98 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" ../config/config_localhost.ini |
112 | sudo chmod 600 $OSPATH/config/config.ini | 99 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" ../config/config_localhost.ini |
113 | 100 | ||
114 | sudo sed -i "s@MYSQL_HOST@${MYSQL_HOST}@g" config/config.ini | 101 | sudo chmod 600 ../config/*.ini |
115 | sudo sed -i "s@MYSQL_DB@${MYSQL_DB}@g" config/config.ini | 102 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_IG.ini |
116 | sudo sed -i "s@MYSQL_USER@${MYSQL_USER}@g" config/config.ini | 103 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_MG.ini |
117 | sudo chmod 600 config/config.ini | 104 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" ../config/config_localhost.ini |
118 | sudo sed -i "s@MYSQL_PASSWORD@${MYSQL_PASSWORD}@g" config/config.ini | 105 | sudo chmod 600 ../config/*.ini |
119 | sudo chmod 600 config/config.ini | 106 | |
120 | 107 | if [ ! -f /home/${OS_USER}/.tmux.conf ]; then | |
121 | sudo cp scripts/opensim.tmux.conf /home/$OS_USER/.tmux.conf | 108 | sudo cp scripts/install/opensim.tmux.conf /home/${OS_USER}/.tmux.conf |
122 | sudo chown $USER /home/$OS_USER/.tmux.conf | 109 | sudo chown ${OS_USER}:${OS_USR} /home/${OS_USER}/.tmux.conf |
123 | sudo chmod 644 /home/$OS_USER/.tmux.conf | 110 | sudo chmod 644 /home/${OS_USER}/.tmux.conf |
111 | fi | ||
112 | |||
113 | |||
114 | echo "Building OpenSim." | ||
115 | sudo chown -R ${USER}:${USER} ${OS_PATH} * | ||
116 | ./BuildIt.sh | ||
117 | |||
118 | |||
119 | cd scripts/install | ||
120 | sudo ./secure.sh | ||
124 | 121 | ||
125 | echo "Done installing OpenSim." | 122 | echo "Done installing OpenSim." |