author | Dan Fuhry <dan@enanocms.org> |
Mon, 05 Jul 2010 23:57:56 -0400 | |
changeset 5 | 7d3b7009399d |
parent 4 | c6c431cf0a89 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/bin/bash |
2 |
||
3 |
## FUNCTIONS |
|
4 |
||
5 |
check_bitnami_dir() |
|
6 |
{ |
|
7 |
test -d "$1" || return 1 |
|
8 |
test -f "$1/ctlscript.sh" || return 1 |
|
9 |
test -f "$1/properties.ini" || return 1 |
|
10 |
||
11 |
mysqladmin=$bitnami/mysql/bin/mysqladmin |
|
12 |
test -x "$mysqladmin" || return 1 |
|
13 |
mysql=$bitnami/mysql/bin/mysql |
|
14 |
test -x "$mysql" || return 1 |
|
15 |
||
16 |
return 0 |
|
17 |
} |
|
18 |
||
4 | 19 |
## COMPAT |
20 |
||
21 |
# OS X sed (at least leopard and up) seem to support -E |
|
22 |
sedflags=Ee |
|
23 |
if ( sed --version 2>&1 | grep 'GNU sed' 2>&1 ) > /dev/null ; then |
|
24 |
sedflags=re |
|
25 |
fi |
|
26 |
||
0 | 27 |
## SCRIPT |
28 |
||
29 |
cd `dirname $0` |
|
30 |
||
31 |
echo "Welcome to the Enano CMS BitNami module installer." |
|
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
32 |
if [ ! -d ./enano-* ]; then |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
33 |
HG_BASE=${HG_BASE:-http://hg.enanocms.org/repos} |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
34 |
cat <<EOF |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
35 |
This is the Mercurial-based installer. It doesn't include the Enano source |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
36 |
tree - instead it's created based on the latest Mercurial sources. To use this |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
37 |
installer, you must have Mercurial on your system. |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
38 |
|
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
39 |
The current repository path is ${HG_BASE}. |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
40 |
To override it, set HG_BASE. |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
41 |
|
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
42 |
You can safely Control-C out of this installer at any time and temporary files |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
43 |
will be cleaned up. |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
44 |
|
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
45 |
EOF |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
46 |
fi |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
47 |
|
0 | 48 |
autobitnami="" |
49 |
if test -n "$HOME"; then |
|
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
50 |
autobitnami=`echo $HOME/lampstack-*` |
0 | 51 |
if test ! -d "$autobitnami"; then |
52 |
autobitnami="" |
|
53 |
fi |
|
54 |
fi |
|
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
55 |
if test -d /Applications/; then |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
56 |
autobitnami=`echo /Applications/mampstack-*` |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
57 |
if test ! -d "$autobitnami"; then |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
58 |
autobitnami="" |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
59 |
fi |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
60 |
fi |
0 | 61 |
while true; do |
62 |
if test -n "$autobitnami"; then |
|
63 |
read -p "Path to BitNami directory [$autobitnami]: " bitnami |
|
64 |
test -z "$bitnami" && bitnami="$autobitnami" |
|
65 |
else |
|
66 |
read -p "Path to BitNami directory: " bitnami |
|
67 |
fi |
|
68 |
check_bitnami_dir $bitnami && break |
|
69 |
echo "This does not seem to be the home of a BitNami LAMPStack installation." |
|
70 |
done |
|
71 |
||
72 |
if [ -d $bitnami/apps/enanocms ]; then |
|
73 |
echo "Enano is already installed as a module on this LAMPStack." |
|
74 |
exit 1 |
|
75 |
fi |
|
76 |
||
4 | 77 |
mysql_port=$(cat $bitnami/properties.ini | grep mysql_port | sed -$sedflags 's/^mysql_port=//g') |
0 | 78 |
|
79 |
while true; do |
|
80 |
read -s -p "MySQL root password: " mysqlpass |
|
81 |
echo "" |
|
82 |
out=`$mysqladmin -u root --password="$mysqlpass" ping 2>&1` |
|
83 |
test "$out" = "mysqld is alive" && break |
|
84 |
echo $out |
|
85 |
done |
|
86 |
||
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
87 |
my_tr() |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
88 |
{ |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
89 |
# this is needed under OS X, its terminal emulator tends to mess up tr |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
90 |
LC_ALL=C tr $@ |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
91 |
return $? |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
92 |
} |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
93 |
|
0 | 94 |
echo "Creating database." |
95 |
||
96 |
bitnami_db="bn_enanocms" |
|
97 |
bitnami_user="bn_enanocms" |
|
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
98 |
bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | my_tr -cd '\41-\46\50-\176' | cut -c 1-12` |
0 | 99 |
|
100 |
query='CREATE DATABASE IF NOT EXISTS `'$bitnami_db'`; GRANT ALL PRIVILEGES ON '$bitnami_db'.* TO '"$bitnami_user"'@localhost IDENTIFIED BY '"'$bitnami_pass'"'; FLUSH PRIVILEGES;' |
|
3
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
101 |
echo "$query" | $mysql -u root --password="$mysqlpass" || exit 1 |
0 | 102 |
|
103 |
echo "Installing files." |
|
104 |
mkdir -p $bitnami/apps/enanocms/{conf,licenses} || exit 1 |
|
5
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
105 |
if [ -d ./enano-* ]; then |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
106 |
cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
107 |
else |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
108 |
# There's no Enano source tree in this installer. Pull the latest from Mercurial. |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
109 |
oldpwd=`pwd` |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
110 |
cd $bitnami/apps/enanocms || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
111 |
curl -q -o mkenanodev.sh http://hg.enanocms.org/mkenanodev.sh || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
112 |
chmod u+x mkenanodev.sh || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
113 |
./mkenanodev.sh 1.1 $HG_BASE || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
114 |
rm -f mkenanodev.sh |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
115 |
mv enano-1.1 htdocs || exit 1 |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
116 |
|
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
117 |
cd $oldpwd |
7d3b7009399d
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents:
4
diff
changeset
|
118 |
fi |
0 | 119 |
cp ./COPYING $bitnami/apps/enanocms/licenses/ || exit 1 |
120 |
cat <<EOF > $bitnami/apps/enanocms/conf/enanocms.conf |
|
121 |
Alias /enanocms "$bitnami/apps/enanocms/htdocs" |
|
122 |
||
123 |
<Directory "$bitnami/apps/enanocms/htdocs"> |
|
124 |
Options -Indexes MultiViews FollowSymLinks |
|
125 |
AllowOverride All |
|
126 |
Order allow,deny |
|
127 |
Allow from all |
|
128 |
</Directory> |
|
129 |
EOF |
|
3
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
130 |
cp ./uninstall.sh $bitnami/apps/enanocms/ |
0 | 131 |
|
132 |
echo "Patching Apache configuration." |
|
4 | 133 |
if test "`cat $bitnami/apache2/conf/httpd.conf | grep '^Include' | grep enanocms | wc -l`" -eq 0; then |
0 | 134 |
echo -ne "\nInclude "'"'"$bitnami/apps/enanocms/conf/enanocms?conf"'"'"\n" >> $bitnami/apache2/conf/httpd.conf |
135 |
fi |
|
136 |
||
137 |
echo "Adding Enano to BitNami's applications.html." |
|
4 | 138 |
if test "`cat $bitnami/apache2/htdocs/applications.html | fgrep 'START BitNami Enano CMS Module enanocms' | wc -l`" -eq 0; then |
0 | 139 |
cp enanocms-module.png $bitnami/apache2/htdocs/img/ |
4 | 140 |
line=`cat $bitnami/apache2/htdocs/applications.html | fgrep -n '<!-- @@BITNAMI_MODULE_PLACEHOLDER@@ -->' | cut -d ':' -f 1` |
0 | 141 |
head -n $(($line - 1)) $bitnami/apache2/htdocs/applications.html > ./applications-temp.html |
142 |
cat application.html >> ./applications-temp.html |
|
143 |
tail -n +$line $bitnami/apache2/htdocs/applications.html >> ./applications-temp.html |
|
144 |
mv ./applications-temp.html $bitnami/apache2/htdocs/applications.html |
|
145 |
fi |
|
146 |
||
147 |
echo "Starting Enano installer." |
|
148 |
while true; do |
|
149 |
if $bitnami/php/bin/php $bitnami/apps/enanocms/htdocs/install/install-cli.php -b mysql -h 127.0.0.1 -o $mysql_port -u "$bitnami_user" -p "$bitnami_pass" -d $bitnami_db -i /enanocms -r rewrite |
|
150 |
then |
|
151 |
break |
|
152 |
else |
|
153 |
read -n 1 -p "Try installation again? [y/N] " RETRY |
|
154 |
if test "$RETRY" != "y"; then |
|
155 |
cat <<EOF |
|
156 |
||
157 |
Enano installation failed. To install Enano using the web interface, |
|
158 |
navigate to http://localhost/enanocms (or http://localhost:8080/enanocms, |
|
159 |
depending on how you installed LAMPStack), and use the following settings: |
|
160 |
||
161 |
Database type: MySQL |
|
162 |
Database hostname: localhost |
|
163 |
Database name: $bitnami_db |
|
164 |
Database username: $bitnami_user |
|
165 |
Database password: $bitnami_pass |
|
166 |
||
167 |
||
168 |
EOF |
|
169 |
break |
|
170 |
fi |
|
171 |
fi |
|
172 |
done |
|
173 |
||
174 |
echo "Restarting Apache." |
|
175 |
$bitnami/ctlscript.sh restart apache |
|
176 |
||
3
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
177 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
178 |
echo -e "Installation finished, \e[31;1mbut be warned! We are aware of a bug with BitNami's" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
179 |
echo -e "copy of GMP.\e[0m If your server doesn't support SSE2, Enano logins may fail. A" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
180 |
echo -e "symptom of this problem is messages similar to the following in your Apache" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
181 |
echo -e "error log and a blank response when you try to log in to your Enano website:" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
182 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
183 |
echo -e "\t[Mon Jul 05 14:22:10 2010] [notice] child pid 26544 exit signal" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
184 |
echo -e "\tIllegal instruction (4)" |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
185 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
186 |
echo -e "If you experience this bug, please report it to BitNami, not the Enano project." |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
187 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
188 |