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