author | Dan Fuhry <dan@enanocms.org> |
Mon, 05 Jul 2010 23:29:07 -0400 | |
changeset 4 | c6c431cf0a89 |
parent 3 | 859eeb3579b2 |
child 5 | 7d3b7009399d |
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." |
|
32 |
autobitnami="" |
|
33 |
if test -n "$HOME"; then |
|
34 |
autobitnami=$(echo $HOME/lampstack-*) |
|
35 |
if test ! -d "$autobitnami"; then |
|
36 |
autobitnami="" |
|
37 |
fi |
|
38 |
fi |
|
39 |
while true; do |
|
40 |
if test -n "$autobitnami"; then |
|
41 |
read -p "Path to BitNami directory [$autobitnami]: " bitnami |
|
42 |
test -z "$bitnami" && bitnami="$autobitnami" |
|
43 |
else |
|
44 |
read -p "Path to BitNami directory: " bitnami |
|
45 |
fi |
|
46 |
check_bitnami_dir $bitnami && break |
|
47 |
echo "This does not seem to be the home of a BitNami LAMPStack installation." |
|
48 |
done |
|
49 |
||
50 |
if [ -d $bitnami/apps/enanocms ]; then |
|
51 |
echo "Enano is already installed as a module on this LAMPStack." |
|
52 |
exit 1 |
|
53 |
fi |
|
54 |
||
4 | 55 |
mysql_port=$(cat $bitnami/properties.ini | grep mysql_port | sed -$sedflags 's/^mysql_port=//g') |
0 | 56 |
|
57 |
while true; do |
|
58 |
read -s -p "MySQL root password: " mysqlpass |
|
59 |
echo "" |
|
60 |
out=`$mysqladmin -u root --password="$mysqlpass" ping 2>&1` |
|
61 |
test "$out" = "mysqld is alive" && break |
|
62 |
echo $out |
|
63 |
done |
|
64 |
||
65 |
echo "Creating database." |
|
66 |
||
67 |
bitnami_db="bn_enanocms" |
|
68 |
bitnami_user="bn_enanocms" |
|
69 |
bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | tr -cd '\41-\46\50-\176' | cut -c 1-12` |
|
70 |
||
71 |
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
|
72 |
echo "$query" | $mysql -u root --password="$mysqlpass" || exit 1 |
0 | 73 |
|
74 |
echo "Installing files." |
|
75 |
mkdir -p $bitnami/apps/enanocms/{conf,licenses} || exit 1 |
|
76 |
cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1 |
|
77 |
cp ./COPYING $bitnami/apps/enanocms/licenses/ || exit 1 |
|
78 |
cat <<EOF > $bitnami/apps/enanocms/conf/enanocms.conf |
|
79 |
Alias /enanocms "$bitnami/apps/enanocms/htdocs" |
|
80 |
||
81 |
<Directory "$bitnami/apps/enanocms/htdocs"> |
|
82 |
Options -Indexes MultiViews FollowSymLinks |
|
83 |
AllowOverride All |
|
84 |
Order allow,deny |
|
85 |
Allow from all |
|
86 |
</Directory> |
|
87 |
EOF |
|
3
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
88 |
cp ./uninstall.sh $bitnami/apps/enanocms/ |
0 | 89 |
|
90 |
echo "Patching Apache configuration." |
|
4 | 91 |
if test "`cat $bitnami/apache2/conf/httpd.conf | grep '^Include' | grep enanocms | wc -l`" -eq 0; then |
0 | 92 |
echo -ne "\nInclude "'"'"$bitnami/apps/enanocms/conf/enanocms?conf"'"'"\n" >> $bitnami/apache2/conf/httpd.conf |
93 |
fi |
|
94 |
||
95 |
echo "Adding Enano to BitNami's applications.html." |
|
4 | 96 |
if test "`cat $bitnami/apache2/htdocs/applications.html | fgrep 'START BitNami Enano CMS Module enanocms' | wc -l`" -eq 0; then |
0 | 97 |
cp enanocms-module.png $bitnami/apache2/htdocs/img/ |
4 | 98 |
line=`cat $bitnami/apache2/htdocs/applications.html | fgrep -n '<!-- @@BITNAMI_MODULE_PLACEHOLDER@@ -->' | cut -d ':' -f 1` |
0 | 99 |
head -n $(($line - 1)) $bitnami/apache2/htdocs/applications.html > ./applications-temp.html |
100 |
cat application.html >> ./applications-temp.html |
|
101 |
tail -n +$line $bitnami/apache2/htdocs/applications.html >> ./applications-temp.html |
|
102 |
mv ./applications-temp.html $bitnami/apache2/htdocs/applications.html |
|
103 |
fi |
|
104 |
||
105 |
echo "Starting Enano installer." |
|
106 |
while true; do |
|
107 |
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 |
|
108 |
then |
|
109 |
break |
|
110 |
else |
|
111 |
read -n 1 -p "Try installation again? [y/N] " RETRY |
|
112 |
if test "$RETRY" != "y"; then |
|
113 |
cat <<EOF |
|
114 |
||
115 |
Enano installation failed. To install Enano using the web interface, |
|
116 |
navigate to http://localhost/enanocms (or http://localhost:8080/enanocms, |
|
117 |
depending on how you installed LAMPStack), and use the following settings: |
|
118 |
||
119 |
Database type: MySQL |
|
120 |
Database hostname: localhost |
|
121 |
Database name: $bitnami_db |
|
122 |
Database username: $bitnami_user |
|
123 |
Database password: $bitnami_pass |
|
124 |
||
125 |
||
126 |
EOF |
|
127 |
break |
|
128 |
fi |
|
129 |
fi |
|
130 |
done |
|
131 |
||
132 |
echo "Restarting Apache." |
|
133 |
$bitnami/ctlscript.sh restart apache |
|
134 |
||
3
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
135 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
141 |
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
|
142 |
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
|
143 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
144 |
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
|
145 |
echo |
859eeb3579b2
Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents:
0
diff
changeset
|
146 |