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