forked from reasoncms/reasoncms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·155 lines (125 loc) · 4.22 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
echo "Welcome to Reason";
echo "================="
echo "This script will walk you through the first step of installing Reason."
echo "DO NOT RUN THIS SCRIPT ON UPGRADES!"
echo "Do you wish to continue? (y/n)"
read ans
case $ans in
Y|y) ;;
[Yy][Ee][Ss]) ;;
N|n) exit ;;
[Nn][Oo]) exit ;;
*) echo "Invalid command"
esac
if ! which mysql 1> /dev/null
then
echo "No Mysql client was not found in your path."
echo "Enter the path to the mysql client"
echo "For example /Applications/MAMP/Library/bin/mysql"
read mysqlcmd
else
mysqlcmd="mysql"
fi
if ! which mysqladmin 1> /dev/null
then
echo "Mysqladmin was not found in your path."
echo "Enter the path to the mysqladmin"
echo "For example /Applications/MAMP/Library/bin/mysqladmin"
read mysqladmincmd
else
mysqladmincmd="mysqladmin"
fi
echo " "
echo "Where's your web root?";
echo "Please supply a path from the root of your server"
echo "DO NOT include a trailing slash."
echo "For example /var/www/htdocs"
read webdir
ln -ns $PWD/reason_4.0/www/ $webdir/reason
ln -ns $PWD/www/ $webdir/reason_package
ln -ns $PWD/thor/ $webdir/thor
echo "Symlinks created"
echo " "
if [ -z ${MYSQL_HOST+x} ]
then
echo "Enter the name of your mysql server."
echo "If you wish to use mysql on this server, enter localhost"
read mysqlhost
else
echo "Based on your environment, the hostname for the mysql server for Reason is '$MYSQL_HOST'"
mysqlhost=$MYSQL_HOST
fi
echo " "
echo "If you have an account that can create databases and users,"
echo "this script can create the users and databases for you."
echo "If not, you'll need to create a database and user for Reason."
echo "Should this script try to create your database and user? (y/n)"
read permission
case $permission in
Y|y)
echo "Enter the name of the database Reason should create:"
read mysqldb
echo "Enter a mysql user which can create databases:"
read mysqlroot
echo "Enter the mysql password for $mysqlroot:"
read mysqlrootpassy
#create mysql database and user now
$mysqladmincmd -u$mysqlroot -p$mysqlrootpassy create $mysqldb;
echo "Database created."
echo " "
echo "It's not recommended to run Reason as the root user"
echo "Enter a mysql username to use to run Reason:"
read mysqluser
echo "Enter a password for your Reason user:"
read mysqlpassy
case $mysqlhost in
localhost)
mysqlfrom="localhost"
;;
*)
mysqlfrom="*"
;;
esac
$mysqlcmd -u$mysqlroot -p$mysqlrootpassy -Bse "GRANT ALL ON $mysqldb.* to $mysqluser@$mysqlfrom identified by '$mysqlpassy';"
;;
N|n)
echo " "
if [ -z ${MYSQL_DATABASE+x} ]
then
echo "Enter the name of the database you have created for Reason:"
read mysqldb
else
echo "Based on your environment, the database you have created for Reason is '$MYSQL_DATABASE'"
mysqldb=$MYSQL_DATABASE
fi
if [ -z ${MYSQL_USER+x} ]
then
echo "Enter the mysql username Reason should use:"
read mysqluser
else
echo "Based on your environment, the database username for Reason is '$MYSQL_USER'"
mysqluser=$MYSQL_USER
fi
if [ -z ${MYSQL_PASSWORD+x} ]
then
echo "Enter the mysql password for $mysqluser:"
read mysqlpassy
else
echo "Based on your environment, the database username for Reason is '$MYSQL_PASSWORD'"
mysqlpassy=$MYSQL_PASSWORD
fi
;;
*) echo "Invalid command"
esac
$mysqlcmd -u$mysqluser -p$mysqlpassy -h$mysqlhost $mysqldb < $PWD/reason_4.0/data/dbs/reason4.8.sql
sed -e "s/<db>reason/<db>$mysqldb/g" -e "s/<db>thor/<db>$mysqldb/g" -e "s/reason_user/$mysqluser/g" -e "s/some_password/$mysqlpassy/g" -e "s/your.mysql.hostname.or.ip.address/$mysqlhost/g" $PWD/settings/dbs.xml.sample > $PWD/settings/dbs.xml
echo " "
echo "Database complete."
echo " "
echo "Reason will only output errors to ip addresses configured in"
echo "settings/error_handler_settings.php"
echo "Enter the ip address of your developer's workstation"
read devip
sed "s/put_your_ip_here/$devip/g" $PWD/settings/error_handler_settings.php.sample > $PWD/settings/error_handler_settings.php
echo "Great, the nerdy bits are done. Continue the installer by visiting /reason/setup.php on your Web site."